/slack-watson-bot

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Sample Bots for Slack and Facebook Messenger using IBM Watson and Botkit

This project contains sample code that shows how to build chatbots for Slack and Facebook Messenger that leverage IBM Watson Conversation and Botkit.

In order to provide the best possible user experience Slack buttons and Facebook Messenger quick replies are used. Slack messages can be defined via the Slack Message Builder. For the format of Facebook messages check out the documentation. The definitions of the Slack and Facebook messages are stored in the dialog definition.

The project also demostrates how to invoke REST APIs, for example to find current weather conditions via Weather Company Data. In order to do this, nodes in the dialog are marked as 'action nodes' via context information. The implementation of the actions is done in the Node.js application.

Check out the presentation for more details.

Serverless Web Apps

This screenshot shows a simple sample conversation in Slack:

alt text

This screenshot shows a simple sample conversation in Facebook Messenger:

alt text

Prerequisites and Setup

You need three different sets of credentials.

Put all of these credentials in a file '.env'. See .env-template for an example.

In addition to the Slack client id and secret additional configuration needs to be done for the Slack app. See the screenshots 'slack-config1-5.png' in the screenshots folder for details.

The Watson workspace needs to be imported into the Conversation service.

In order to run the application locally, you can use tools like localtunnel.

If you want to deploy the application to Bluemix, you need a Bluemix account. Sign up if you don't have an account yet.

Run the Sample

From the root directory run these commands to start the Slack bot:

$ npm install
$ node watson-slack.js

Open up the login page http://localhost:3000/login to add the bot to the team. After this you can send direct messages to the bot 'watson-bot' in your Slack team.

From the root directory run these commands to start the Facebook Messenger bot:

$ npm install
$ node watson-facebook.js