Converse AI

Messenger

Getting Started

Go to the Facebook for developers console and create a new app, you can find the option Add a new App under the My Apps menu.

Give your new app a name, enter your email address, and select an appropriate category like Apps for Pages or Apps for Messenger.

Next select from the products section from the left hand menu and select Messenger, if it is not there you can add it.

In the Messenger panel, scroll down to find Token Generation. Select the page you want to link to the bot to, this will generate a Page Access Token that we will use in Converse to register the channel.

In your Converse console, select Channels and Messenger to register the channel. Enter the Page Access Token from Facebook into Messenger Access Token and hit save. This will generate the Web Hook URL that you will use in Facebook if the access token is validated successfully.

In Facebook under Token Generation is Webhooks, select Setup Webhooks

Copy the Web Hook URL to the New Page Subscription form, and copy the Messenger Access Token to Verify Token. Under Subscription Fields select message and messaging_postbacks, you can also select messaging_referrals for additional functionality with the M.ME Messenger Links.

Verify and save these settings. Under Webhooks you can now select a page to subscribe these page events. Select a page from the drop down menu and click subscribe.

Additional Setup

The Messenger settings contains read-only parameters for the get started button, greeting text and persistent menu which will display any existing information that has been set before the update to Messenger version 1.4. To set the get started button, greeting text and persistent menu please follow our new Setup documentation that allows you use complex persistent menus added in Messenger version 1.4.

M.ME Messenger links

A feature available to Messenger is a trackable short link using M.ME.

A link in the format

https://m.me/{{page_name}}

Will take the user to Messenger for the given page name. We can expand on this by having Converse react to when the user opens Messenger using this link

https://m.me/{{page_name}}?ref={{ref_value}}

The ref_value can either be a template name or a URL encoded JSON object that defines the template name and state values.

When the user follows the link for the first time, they are shown the 'Get Started Button' and the interaction behaves as it would be if they started talking without the M.ME link. If they are returning using the link after previously talking to your bot they will not see if the 'Get Started Button', instead they will be informed that by following the link you have been notified they have opened Messenger and the ref_value is sent to Converse to trigger the conversation with the user.

So if the user followed this link 'https://m.me/conversebot?ref=returned' (sorry just an example at the moment, we will set it up soon), would start a new conversation with the user using the template 'returned' which could just be something simple like say 'Welcome back' or do something more complex like adding keys to the user to show they were referred from a particular link.

For more complex referrals, and to expand the 'Get Started Button' functionality further we use the URL encoded JSON object as the ref_value

{
  "intent":"template_name",
  "entities":{
  	"state_name":"state_value"
  }
}

so when URL encoded our link would look something like this

https://m.me/{{page_name}}?ref=%7B%22intent%22%3A%22template_name%22%2C%22entities%22%3A%7B%22state_name%22%3A%22state_value%22%7D%7D

This would start the template 'template_name' and set the value for the state 'state_name' as 'state_value' so whatever question 'state_name' asked would be skipped as the response 'state_value' has already been supplied.

We can also use this object to expand the 'Get Started Button' when a user first talks to your bot through the M.ME link. The entities section of the object will be used to complete the named states if the 'Get Started Button' trigger message is the template name, allowing for different behaviour if the user uses the M.ME link to talk to your bot for the first time or finds you some other way. This would allow you to have a simple conversation that can track where users have found your bot from by having different state values set by the link.

Please note, for referrals to be passed onto Converse you will need to of added the webhook permission 'messaging_referrals' when setting up your Converse webhook. Don't worry if you didn't originally you can update it it any time without having to create a new webhook.

Modules

Button Template

Add a messenger button to the conversation.

Carousel

A collection of graphical elements displayed in a Messenger Carousel.

Dynamic Carousel

A collection of graphical elements displayed in a Messenger Carousel generated from a dynamically generated array of objects.

List

A list of items displayed in a Messenger List.

Dynamic List

A list of items displayed in a Messenger List generated from a dynamically generated array of objects.

Mark Seen

Mark the last message as seen.

Quick Selection

Send a message to the user displaying quick reply items.

Send Audio

Send a message with an audio file attachment.

Send File

Send a message with a file attachment.

Send Image

Send a message with an image file attachment.

Send Receipt

Send a message displaying a receipt.

Send Video

Send a message with a video file attachment.

Typing Off

Turn the typing indicator off.

Typing On

Turn the typing indicator on.

Messenger