The Messenger Platform allows you to create and manage personas for your business messaging experience. The persona may be backed by a human agent or a bot. A persona allows conversations to be passed from bots to human agents seemlessly. When a persona is introduced into a conversation, the persona's profile picture will be shown and all messages sent by the persona will be accompanied by an annotation above the message that states the persona name and business it represents.
"Adam from Jasper's Market"
name
of a persona is freeform, but a first name and last name or initial, such as "John Z.", is recommendedname
field. You will need the following:
MESSAGING
task on the Pagepages_messaging
permissionTo create a persona, send a POST
request to the /PAGE-ID/personas
endpoint with the name
and profile_picture_url
parameters set for the persona.
curl -i -X POST "https://graph.facebook.com/PAGE-ID/personas ?name=Adam &profile_picture_url=https://www.facebook.com/photo.php/fbid/adam-image.jpg &access_token=PAGE-ACCESS-TOKEN"
Upon success, your app will receive the following JSON response:
{ "id": "PERSONA-ID" }
To get a list of a Page's personas, including the name and profile picture for each, send a GET
request to the PAGE-ID/PERSONA-ID
endpoint:
curl -i -X GET "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/personas?access_token=PAGE-ACCESS-TOKEN"
Upon success, your app will receive the following JSON response:
{ "data": [ { "name": "Adam", "profile_picture_url": "https://facebook.com/adam-image.jpg", "id": "PERSONA-A-ID" }, { "name": "David Mark", "profile_picture_url": "https://facebook.com/david-image.jpg", "id": "PERSONA-B-ID" }, ], "paging": { "cursors": { "before": "QVFIUlMtR2ZATQlRtVUZALUlloV1", "after": "QVFIUkpnMGx0aTNvUjJNVmJUT0Yw" } } }
To retrieve all the personas associated with a Page, send a GET
request to the /PAGE-ID/personas
endpoint:
curl -i -X GET "https://graph.facebook.com/LATEST-API-VERSION/PERSONA-ID ?access_token=PAGE-ACCESS-TOKEN"
Upon success, your app will receive the following JSON response:
{ "name": "Adam", "profile_picture_url": "https://facebook.com/adam-image.jpg", "id": "PERSONA-ID" }
To send a message as a Persona, send a POST
request to the PAGE-ID/messages
endpoint with the persona_id
parameter with the recipient
and message
parameters.
curl -i -X POST https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/messages ?recipient={ "id":"PSID" } &message={ "text":"Hello world!" } &persona_id=PERSONA-ID &access_token=PAGE-ACCESS-TOKEN"
If persona_id
is not included, the message will be sent using the Page's ID.
You can add the typing indicator for the persona to show that actions are being taken by the persona. Only typing_on
and typing_off
sender actions are supported for personas.
To add the typing indicator as a Persona in the conversation, send a POST
request to the /PAGE-ID/messages
endpoint with the persona_id
parameter.
curl -i -X POST "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/messages ?recipient={ 'id':'PSID' } &sender_action=typing_on &persona_id=PERSONA-ID &access_token=PAGE-ACCESS-TOKEN"
To delete a persona, send a DELETE
request to the /PERSONA-ID
endpoint.
curl -X DELETE "https://graph.facebook.com/LATEST-API-VERSION/PERSONA-ID ?access_token=PAGE-ACCESS-TOKEN"
Messages previously sent by this persona will continue to appear in the chat history of the thread. Once deleted, a persona will no longer be able to send new messages.
Upon success, your app will receive the following JSON response:
{ "success": true }