Pages

Cisco Spark Bot with IBM Watson Conversation API

Recently I attended TechCrunch Disrupt in San Francisco as part of the Cisco Spark team. TC puts on a great hackathon before the main 3 day event that most would know for the Startup Battlefield shown on the HBO series Silicon Valley. This year over 1000 hackers participated in a 24hr hackathon in San Francisco. In preparation for the event I created a simple Cisco Spark bot skeleton written in Javascript for Nodejs.

My aim for the bot skeleton was not to show any mastery of Javascript, far from it, but to enable the hackers to be able to quickly assemble and deploy a chatbot for Spark. This would allow the hackers to focus more on their project’s use case versus having to work out the particulars of the Spark API. There is plenty documentation around for the various pieces but to bring a bot like this together getting it altogether in a quick format without the research is a little harder. I wanted something quick and easy for the hackers that if needed I could quickly help them get it going.

The bot skeleton consists of a number of node modules. While all the modules provide some important function the main module responsible for Spark functions such as webhooks, posting messages and emitting bot events is the Flint framework. Flint is being constantly updated by it creator Nick Marus. Nick has done a great job on creating an easy to use framework. Once you have done the setup once or twice creating new bots is a matter of minutes project.

The skeleton I created also contains a simple integration to IBM Watson’s Conversation API. Unfortunately the documentation on the Conversation API for the node module is a little low on details. I am hoping to in follow up post to go more into depth around using context with Watson’s Conversation API. There is some good info and examples out there from a few of the IBM folks which I am using right now to build out a more complex bot integration. There are a lot of high level demo’s and videos out there but there isn’t much informaiton on doing something a little more complex. If you are looking to do a Spark bot or a bot on another platform, the Watson context object is critical to get complex dialogs working but for now lets look at something a little simpler.

Spark Bot Information

A lot of the info below comes from the readme on my GitHub repo but I have extended some of the details here in case you need some extra help.

Required accounts

Spark user/developer account – Pretty simple. Download the mobile app or go to the web and signup for an account if you don’t have one already. Once complete sign into the developers portal using the same account details.

Spark bot account – Once you are in the Spark developers portal head to “My Apps”. Its right next to your avatar. Creating the Spark bot account is very simple just fill out the form. The hardest part is finding the right avatar. Once you filled everything out and saved your bot don’t forget to grab the bots access token from the page. you will need it a little later.

IBM Watson credentials – Rather than rewriting the great work of others at IBM, here are some quick pointers to info.

IBM Watson Conversation API's

For those of you that are actually at any of the TechCrunch hackathons there are alternatives obviously to Watson but you don’t have a chance of winning any prizes if you use them. This is just the start of integrating with Watson’s Conversation API’s, in a follow up I will talk more about using MongoDB to track conversation context based on room and email ID’s. This simple use of the Nodejs module will get you started but for more complex interactions you need context. But for now here is a little more help:

Cloud 9 hosting by Amazon

This is one of the coolest development cloud IDE’s out there. You can use a variety of languages and the Cloud 9 team have done a great job at making it easy to add additional components to a container. Its integrated with Github Oauth to make it easy to signup and sign in.

***Ensure to upgrade the default version of Express if using Cloud 9 per the dependencies below which is also in the package.json file. The default version of Express if using the predefined workspace is below the requirements for the Flint frame work. So make sure to run the “npm install express –save’’ after removing the old Express version from your package.json file.

Dependencies for Spark Skeleton-

"async": "~0.2.8",

"body-parser": "^1.15.2",

"express": "^4.14.0",

"fs": "0.0.1-security",

"node-flint": "^4.1.1",

"path": "^0.12.7",

"watson-developer-cloud": "^2.2.0"

Note – there is a later version of the Flint framework (4.2) but I have not tested it with this Skeleton.

Setting up config.example.js

Below is the config example file from Github. To enable this file on your real project make sure to fill in all the expected access tokens and keys and rename the file to config.js. Pretty simple really but I thought I would highlight it as some people may not realize this needs to occur.

Running the server with debug

DEBUG=flint,bot,sparky node server.js

Helpful Links

I am working on Using MongoDB to Capture Context right now so I will publish a follow up in the near future along with an expanded explanation of how to use the flint.hears method. This is the main method used by the framework to capture text for by the bot to perform its duty.

Join Node-Flint Support

Email Subscription

Subscribe To VoIPNorm

Followers

Disclaimer

This is my personal weblog. The opinions expressed in this blog are my own views and not those of Cisco. And yes from time to time my opinion can change.

All information provided on this site is for informational purposes only. VoIPNorm (Chris Norman) makes no representitive as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delay in this information or any losses, injuries, or damages arising from its use. All information is provided on an as-is basis.