Warning: This document is for an old version of Rasa Platform.

Input / Output Channels

Facebook Messenger

This is a collection of useful information about connecting a bot to Facebook.

All of these instructions assume your instance is running on the domain https://rasa.example.com.

Connecting the bot

If your bot uses Facebook Messenger, you need to set up a Facebook app and page.

To create the app go to: https://developers.facebook.com/ and

  1. click on Add a new app
  2. go onto the dashboard for the app
  3. under Products, click Add Product and add Messenger
  4. Under the settings for Messenger, scroll down to Token Generation and click on the link to create a new page for your app.

Webhooks

Finally you need to set up your Webhooks on the Facebook developers page. Go to the Messenger tab in Products again and scroll down to Webhooks, click on Setup Webhooks:

  1. Under the ‘Callback URL’ you put in the following: https://rasa.example.com/app/webhook
  2. In the Verify Token field you put the value you specified in your .yaml file for FB_VERIFY
  3. In Subscription Fields make sure messages and messaging_postbacks are ticked.
  4. Click Verify and Save

Hopefully that worked and your app should now be ready for testing! It can be accessed on https://www.messenger.com/t/PAGE_ID, where PAGE_ID is the ID of your page as mentioned above.

Start screen for chats

You need to send two API requests to create a welcome message and a get started button. These will be displayed when a user starts his first interaction with the bot (i.e. on subsequent visits they will not show up).

Change welcome message to show <WELCOME_MESSAGE>:

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"greeting",
  "greeting":{
    "text":"<WELCOME_MESSAGE>"
  }
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=XXXX"

Add get started button (you can not change the title of the button. You can only define the message that will be send to the bot once the user clicks on the button. in this case /get_started):

curl -X POST -H "Content-Type: application/json" -d '{
  "setting_type":"call_to_actions",
  "thread_state":"new_thread",
  "call_to_actions":[
    {
      "payload":"/get_started"
    }
  ]
}' "https://graph.facebook.com/v2.6/me/thread_settings?access_token=XXX"

Bot is not responding

Make sure

  1. bot is up and running and listening on the correct port
  2. go to developers.facebook.com –> your app –> webhooks and check the correct hook is entered (someone else might have changed it!)
  3. got to developers.facebook.com –> your app –> messenger and make sure your facebook page shows up in the bottom of the section Webhooks (every time you get an email that your bot did not respond to a webhook for too long, you need to add the page in this section again)

Rasa Chat

Rasa Chat provides a minimal chat interface shipped with the Platform. The chat interface is by default available at /chat once the app is deployed.

Configuring the Rasa Chat UI

Here is an example of how to configure the RasaChatInput, taken from the example app. RASA_API_ENDPOINT_URL refers to the endpoint Rasa NLU on which RasaNLU listens (typically http://<hostname>/api).

from rasa_extensions.core.channels.rasa_chat import RasaChatInput
HOSTNAME = os.environ.get("RASA_PLATFORM_HOSTNAME", "http://localhost")
input_channel = HttpInputChannel(5001,
                                 "/",
                                 RasaChatInput(urlparse.urljoin(HOSTNAME,
                                                                os.environ.get("RASA_API_ENDPOINT"))))

Using the Rasa Chat UI

To access the UI go to: https://<hostname>/chat. Log in by using one of the accounts created when you configured replicated (Create a User).

Custom Input / Output Channels

Connecting the bot