Fetching latest commit…
Cannot retrieve the latest commit at this time.


Multi-channel bot

This document describes how to set up a sample Express app which talks to Slack, Facebook, and Twilio bots.

Install all dependencies:

npm install

Getting credentials

Watson Assistant

  1. Sign up for an IBM Cloud account.

  2. Download the IBM Cloud CLI.

  3. Create an instance of the Watson Assistant service and get your credentials:

    • Go to the Watson Assistant page in the IBM Cloud Catalog.
    • Log in to your IBM Cloud account.
    • Click Create.
    • Click Show to view the service credentials.
    • Copy the apikey value, or copy the username and password values if your service instance doesn't provide an apikey.
    • Copy the url value.
  4. Create a workspace using the Watson Assistant service and copy the workspace_id.

  5. Open the .env file and add the service credentials that you obtained in the previous step.

    Example .env file that configures the apikey and url for a Watson Assistant service instance hosted in the US East region:

    • If your service instance uses username and password credentials, add the ASSISTANT_USERNAME and ASSISTANT_PASSWORD variables to the .env file.

    Example .env file that configures the username, password, and url for a Watson Assistant service instance hosted in the US South region:

  6. Add the WORKSPACE_ID to the previous properties



Follow the Getting Started section of this document from Botkit. Once you obtain the Slack token, paste the token in the .env file.

SLACK_TOKEN=<your token>

Facebook Messenger

Follow the Getting Started section of this document from Botkit.

Some helpful hints for Facebook Messenger:

  • Log into the Facebook App settings page. You need to add two Products- Messenger and Webhooks.
  • When setting up Messenger, make sure you have subscribed your page with your app, otherwise your app won't send back responses to your page. This step is also important cause Facebook will provide you with the FB_ACCESS_TOKEN your bot will need to communicate via Messenger.
  • When setting up the webhook,
    • You'll have to first set up localtunnel locally and start it on the same port where you plan to run your Express app. Let's say you run your app on port 5000, then in one terminal window run the following command: lt --port 5000 lt will provide you with a url, part of which will be the webhook url.
    • Add (https://<your localtunnel url>/facebook/receive) as Facebook Messenger's webhook. The webhook url must contain https://. eg: If your localtunnel url is http://litjqjglwn.localtunnel.me your webhook url will be https://litjqjglwn.localtunnel.me/facebook/receive, otherwise Facebook will show an error.
    • You need to only subscribe to Messages event under Webhooks.

Once you obtain the access token (provided by Facebook), the verify token (created by you) and the app secret key for your Facebook app (provided by Facebook), paste them in the .env file of your project.

FB_ACCESS_TOKEN=<your access token>
FB_VERIFY_TOKEN=<your verify token>
FB_APP_SECRET=<your apps secret key>

When you're ready to test your bot, go to your Facebook homepage and find the page you created. Click on Message to start chatting with your Watson Assistant bot!

Twilio IPM

Follow the Getting Started section of this document from Botkit. Copy and paste all the authentication details in the .env file.

TWILIO_ACCOUNT_SID=<your account sid>
TWILIO_AUTH_TOKEN=<your auth token>
TWILIO_IPM_SERVICE_SID=<your service sid>
TWILIO_API_KEY=<your twilio API key>
TWILIO_API_SECRET=<your twilio API secret>

You'll need to set up localtunnel and have it running on the same port as your app server. The webhook url for Twilio will then be (https://<your localtunnel url>/twilio/receive).

To test the bot, use this simple Twilio IPM server.

Starting the server

If you are connecting to a channel, you need to add USE_<channel_name> in the .env file. eg: If you would like to use Slack and Facebook Messenger, you must add the following lines in your .env file:


The value of these variables doesn't matter, as long as they're present. The middleware knows it needs to connect to these channels.

Once you have added your credentials in the .env file, start the example express app by running this command:

node server.js

Voila! You're all set! Start chatting on your social channel to test your bot.