Sample Bots for Slack and Facebook Messenger using IBM Watson 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.
This screenshot shows a simple sample conversation in Slack:
This screenshot shows a simple sample conversation in Facebook Messenger:
Prerequisites and Setup
You need three different sets of credentials.
- Watson Conversation: To get the credentials follow these instructions
- Weather Company Data: To get the credentials follow these instructions
- Slack App: Create a new app and copy the client id and client secret from this page
- Facebook App and Facebook Page: You need 1. the app secret, 2. the page token and 3. the verify token (which you can chose). See the documentation for details. You can define the verify token after you've defined the webhook, for example 'xxx.localtunnel.me/facebook/receive'.
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.
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
From the root directory run these commands to start the Facebook Messenger bot:
$ npm install $ node watson-facebook.js