Facebook Messenger channel testing and channel management
The following sections provide information on testing and managing the Facebook Messenger channel of your Conversation API app.
Testing the integration
To test the integration after setting up a Facebook Messenger channel on your Conversation API app:
-
Add a webhook to your Conversation API
app
using the
Sinch Customer Dashboard
, or the API itself, if you haven't done so already. For more information on how to do this using the Customer Dashboard, see
How to add a webook to a Conversation API app
. Below is an example of how to create the webhook programmatically:
{ "app_id": "{{APP}}", "target": "{{WEBHOOK_URL}}", "target_type": "HTTP", "triggers": [ "MESSAGE_DELIVERY", "EVENT_DELIVERY", "MESSAGE_INBOUND", "EVENT_INBOUND", "CONVERSATION_START", "CONVERSATION_STOP", "UNSUPPORTED" ] }
-
An end-user must start the conversation. This creates a contact which can be used as a recipient in the Facebook Messenger channel. To send a message, visit your Facebook Page as a user with adequate permissions (for example, the user who created the Page) and try sending a message to the Page. You should receive two callbacks, one with
conversation_start_notification
:{ "app_id": "01E9DQJFPWGZ2T05XTVZAD0BYB", "conversation_start_notification": { "conversation": { "id": "01E9DV2N8C6CK41XFPGQPN0NWE", "app_id": "01E9DQJFPWGZ2T05XTVZAD0BYB", "contact_id": "01E9DV2N7TYPJ50V0FYC08110D", "last_received": "2020-05-28T14:30:48Z", "active_channel": "CHANNEL_UNSPECIFIED", "active": true, "metadata": "", "active_channel_senders": [] } } }
and one with the message you've just sent:
{ "app_id": "01E9DQJFPWGZ2T05XTVZAD0BYB", "accepted_time": "2020-05-28T14:30:47.850538Z", "project_id": "ab5536b1-31b0-45e8-aec6-b35f13c41d0b", "message": { "id": "01E9DV2N92BMDD034JZ0AQ0VKB", "direction": "TO_APP", "contact_message": { "text_message": { "text": "Hello World" } }, "channel_identity": { "channel": "MESSENGER", "identity": "3630555555589", "app_id": "01E9DQJFPWGZ2T05XTVZAD0BYB" }, "conversation_id": "01E9DV2N8C6CK41XFPGQPN0NWE", "contact_id": "01E9DV2N7TYPJ50V0FYC08110D", "metadata": "", "accept_time": "2020-05-28T14:30:47.841429Z" }, "message_metadata": "" }
-
With a conversation created automatically, you can use the received
contact_id
to send a response to the user:{ "app_id": "{{APP_ID}}", "recipient": { "contact_id": "{{CONTACT_ID}}" }, "message": { "text_message": { "text": "Text message from Sinch Conversation API." } }, "channel_priority_order": ["MESSENGER"] }
-
You should receive callbacks with information that the message has been delivered and read. Successfully sending a message to the user indicates that the channel is configured correctly.
Warning (from 16th December)
Regarding the changes introduced by Facebook Messenger to comply with new privacy rules in Europe, delivered and read callbacks won't be shipped.
This condition impacts you if:
- Your app points to messenger bot which is created for a European Page.
- Your app points to messenger bot which is created for a Page that has European admins.
- You send a message to customers in Europe.
Restrictions will be revised by Facebook Messenger in the future.
Removing the Facebook Messenger integration
To completely delete the Messenger integration, you need to remove the integration from the Conversion API using the Sinch Customer Dashboard:
- Navigate to your Conversation API app and select the Facebook Messenger channel.
- Click the Reset Integration button to detach your Facebook page from the Conversation API:
- The permissions you have granted to the Conversation API app can only be revoked from your Facebook account. Follow this guide to revoke the permissions granted to the Conversation API app. If you have multiple pages connected to the Conversation API app, make sure you only revoke the permission for the Page you are detaching from Conversation API.