Facebook Messenger

Usage Instructions

Send Messenger messages from a Facebook Page: text, images and files, quick replies, button and card templates, and typing indicators. Look up a person by their Page-scoped ID and read past conversations. The Messenger trigger runs a workflow when someone messages the Page, taps a button or quick reply, reacts, or arrives from an m.me link or ad. Replies go out within 24 hours of the person's last message, or within 7 days from a person using the Human Agent tag.

Actions

Messenger Get Conversation Messages

Get the most recent messages (up to 20) of a Messenger conversation with sender, recipients, text, attachments, and time, newest first.

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
conversationIdstringYesConversation ID from List Conversations
limitnumberNoMaximum messages to return (1-20; Meta only returns details for the 20 most recent)

Output

ParameterTypeDescription
messagesarrayMessages, newest first
↳ idstringMessage ID (mid)
↳ createdTimestringWhen the message was sent
↳ textstringMessage text (empty for attachment-only messages)
↳ fromobjectSender: the person or the Page
↳ toarrayRecipients
↳ attachmentsarrayAttached files and media
↳ idstringAttachment ID
↳ namestringFile name
↳ fileUrlstringFile URL
↳ imageUrlstringImage URL
↳ videoUrlstringVideo URL

Messenger Get User Profile

Get a Messenger user's name and profile picture (and, with extra permissions, locale, timezone, and gender) by their Page-scoped ID.

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
psidstringYesPage-scoped ID (PSID) of the person, e.g. senderPsid from the Messenger trigger
fieldsstringNoComma-separated fields: id, name, first_name, last_name, profile_pic, locale, timezone, gender. Defaults to id,name,first_name,last_name,profile_pic.

Output

ParameterTypeDescription
idstringPSID
namestringFirst and last name
firstNamestringFirst name
lastNamestringLast name
profilePicstringProfile picture URL (the URL expires)
localestringFacebook locale, e.g. en_US
timezonenumberTimezone offset from GMT in hours
genderstringGender
profileAvailablebooleanFalse when Meta returned no profile data for this person

Messenger List Conversations

List a Facebook Page's Messenger conversations with their participants and last update time, or find the conversation with one person by PSID.

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
pageIdstringNoFacebook Page ID. Defaults to the Page the access token belongs to (me).
userIdstringNoPSID of a person, to return only the conversation with them
limitnumberNoMaximum conversations to return (1-100)
afterstringNoCursor from a previous call (nextCursor) to fetch the next page

Output

ParameterTypeDescription
conversationsarrayConversations, most recently updated first
↳ idstringConversation ID; pass it to Get Conversation Messages
↳ updatedTimestringWhen the last message was added
↳ participantsarrayThe person and the Page
nextCursorstringPass as After to fetch the next page; null on the last page
hasMorebooleanWhether another page is available

Messenger Send Attachment

Send an image, audio, video, or file to a person on Messenger from a public URL that Meta downloads.

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
pageIdstringNoFacebook Page ID. Defaults to the Page the access token belongs to (me).
recipientIdstringYesPage-scoped ID (PSID) of the person, e.g. senderPsid from the Messenger trigger
messagingTypestringNoRESPONSE (default; replying within the standard messaging window), UPDATE (proactive, within the window), or MESSAGE_TAG (outside the window; needs a tag)
tagstringNoMessage tag for MESSAGE_TAG, e.g. HUMAN_AGENT (a person replying within 7 days of the last user message; needs the Human Agent permission)
notificationTypestringNoPush notification type: REGULAR (default), SILENT_PUSH, or NO_PUSH
attachmentTypestringYesimage, audio, video, or file
urlstringYesPublic URL of the media for Meta to download
isReusablebooleanNoSave the media so it can be sent again by attachment ID (returns attachmentId)

Output

ParameterTypeDescription
recipientIdstringPSID the message or action was sent to
messageIdstringID (mid) of the sent message
attachmentIdstringReusable attachment ID
senderActionstringThe sender action that was sent
idstringPSID of the looked-up person
namestringFull name
firstNamestringFirst name
lastNamestringLast name
profilePicstringProfile picture URL (expires)
localestringFacebook locale
timezonenumberTimezone offset from GMT
genderstringGender
profileAvailablebooleanWhether Meta returned profile data
conversationsjsonConversations (id, updatedTime, participants with id, name, email)
messagesjsonMessages, newest first (id, createdTime, text, from, to, attachments)
nextCursorstringCursor for the next page
hasMorebooleanWhether another page is available

Messenger Send Quick Replies

Send a Messenger text message with up to 13 quick reply buttons, or buttons that ask for the person's phone number or email.

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
pageIdstringNoFacebook Page ID. Defaults to the Page the access token belongs to (me).
recipientIdstringYesPage-scoped ID (PSID) of the person, e.g. senderPsid from the Messenger trigger
messagingTypestringNoRESPONSE (default; replying within the standard messaging window), UPDATE (proactive, within the window), or MESSAGE_TAG (outside the window; needs a tag)
tagstringNoMessage tag for MESSAGE_TAG, e.g. HUMAN_AGENT (a person replying within 7 days of the last user message; needs the Human Agent permission)
notificationTypestringNoPush notification type: REGULAR (default), SILENT_PUSH, or NO_PUSH
textstringYesMessage text shown above the quick replies
quickRepliesjsonYesArray of 1-13 quick replies. Each is a title string (also used as the payload) or { "title": "Yes" (max 20 chars), "payload": "YES" (max 1000 chars), "imageUrl": "https://..." }, or { "contentType": "user_phone_number" } / { "contentType": "user_email" }.

Output

ParameterTypeDescription
recipientIdstringPSID the message or action was sent to
messageIdstringID (mid) of the sent message
attachmentIdstringReusable attachment ID
senderActionstringThe sender action that was sent
idstringPSID of the looked-up person
namestringFull name
firstNamestringFirst name
lastNamestringLast name
profilePicstringProfile picture URL (expires)
localestringFacebook locale
timezonenumberTimezone offset from GMT
genderstringGender
profileAvailablebooleanWhether Meta returned profile data
conversationsjsonConversations (id, updatedTime, participants with id, name, email)
messagesjsonMessages, newest first (id, createdTime, text, from, to, attachments)
nextCursorstringCursor for the next page
hasMorebooleanWhether another page is available

Messenger Send Sender Action

Show a typing indicator (typing_on, typing_off) or mark the person's messages as seen (mark_seen) in a Messenger conversation.

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
pageIdstringNoFacebook Page ID. Defaults to the Page the access token belongs to (me).
recipientIdstringYesPage-scoped ID (PSID) of the person
senderActionstringYestyping_on, typing_off, or mark_seen

Output

ParameterTypeDescription
recipientIdstringPSID the action was shown to
senderActionstringThe sender action that was sent

Messenger Send Template

Send a Messenger button template (text with up to 3 URL, postback, or call buttons) or a generic template (a card or carousel of up to 10 cards).

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
pageIdstringNoFacebook Page ID. Defaults to the Page the access token belongs to (me).
recipientIdstringYesPage-scoped ID (PSID) of the person, e.g. senderPsid from the Messenger trigger
messagingTypestringNoRESPONSE (default; replying within the standard messaging window), UPDATE (proactive, within the window), or MESSAGE_TAG (outside the window; needs a tag)
tagstringNoMessage tag for MESSAGE_TAG, e.g. HUMAN_AGENT (a person replying within 7 days of the last user message; needs the Human Agent permission)
notificationTypestringNoPush notification type: REGULAR (default), SILENT_PUSH, or NO_PUSH
templateTypestringYesbutton or generic
textstringNoButton template text shown above the buttons (max 640 characters)
buttonsjsonNoButton template buttons, 1-3, e.g. [{ "type": "web_url", "url": "https://...", "title": "Book" }, { "type": "postback", "title": "Talk to us", "payload": "TALK" }, { "type": "phone_number", "title": "Call", "payload": "+16505551234" }]. Titles max 20 characters.
elementsjsonNoGeneric template elements, 1-10, each { "title" (max 80), "subtitle" (max 80), "image_url", "default_action": { "type": "web_url", "url" }, "buttons": [up to 3 buttons] }

Output

ParameterTypeDescription
recipientIdstringPSID the message or action was sent to
messageIdstringID (mid) of the sent message
attachmentIdstringReusable attachment ID
senderActionstringThe sender action that was sent
idstringPSID of the looked-up person
namestringFull name
firstNamestringFirst name
lastNamestringLast name
profilePicstringProfile picture URL (expires)
localestringFacebook locale
timezonenumberTimezone offset from GMT
genderstringGender
profileAvailablebooleanWhether Meta returned profile data
conversationsjsonConversations (id, updatedTime, participants with id, name, email)
messagesjsonMessages, newest first (id, createdTime, text, from, to, attachments)
nextCursorstringCursor for the next page
hasMorebooleanWhether another page is available

Messenger Send Text

Send a text message from a Facebook Page to a person on Messenger by their Page-scoped ID (PSID).

Input

ParameterTypeRequiredDescription
pageAccessTokenstringYesLong-lived Page access token from someone who can perform the MESSAGING task on the Page, with pages_messaging, pages_manage_metadata, and pages_read_engagement
pageIdstringNoFacebook Page ID. Defaults to the Page the access token belongs to (me).
recipientIdstringYesPage-scoped ID (PSID) of the person, e.g. senderPsid from the Messenger trigger
messagingTypestringNoRESPONSE (default; replying within the standard messaging window), UPDATE (proactive, within the window), or MESSAGE_TAG (outside the window; needs a tag)
tagstringNoMessage tag for MESSAGE_TAG, e.g. HUMAN_AGENT (a person replying within 7 days of the last user message; needs the Human Agent permission)
notificationTypestringNoPush notification type: REGULAR (default), SILENT_PUSH, or NO_PUSH
textstringYesMessage text
replyToMessageIdstringNoMessage ID (mid) to reply to, shown as a quoted reply in the thread

Output

ParameterTypeDescription
recipientIdstringPSID the message or action was sent to
messageIdstringID (mid) of the sent message
attachmentIdstringReusable attachment ID
senderActionstringThe sender action that was sent
idstringPSID of the looked-up person
namestringFull name
firstNamestringFirst name
lastNamestringLast name
profilePicstringProfile picture URL (expires)
localestringFacebook locale
timezonenumberTimezone offset from GMT
genderstringGender
profileAvailablebooleanWhether Meta returned profile data
conversationsjsonConversations (id, updatedTime, participants with id, name, email)
messagesjsonMessages, newest first (id, createdTime, text, from, to, attachments)
nextCursorstringCursor for the next page
hasMorebooleanWhether another page is available

Triggers

A Trigger is a block that starts a workflow when an event happens in this service.

Messenger Webhook

Trigger workflow when someone messages your Facebook Page on Messenger, taps a button or quick reply, reacts, reads, or arrives from an m.me link or ad

Configuration

ParameterTypeRequiredDescription
messengerVerifyTokenstringYesEnter the same string in the Verify Token field of the Messenger webhook in the Meta App Dashboard.
messengerAppSecretstringYesUsed to check the X-Hub-Signature-256 header Meta signs every delivery with. Deliveries that do not match are rejected.
messengerEventTypesstringNoRun only for the selected events. Leave empty for everything except read receipts, which fire for every message the person reads.
messengerIncludeEchoesbooleanNoAlso run for messages your Page sends (Meta marks them is_echo; subscribe to message_echoes). Off by default so a reply sent by this workflow does not trigger it again.
messengerPageIdsstringNoPage IDs

Output

ParameterTypeDescription
eventTypestringmessage, postback, reaction, read, or referral
pageIdstringFacebook Page ID that received the event
senderPsidstringPage-scoped ID (PSID) of the person. Pass it as the Recipient ID of a send operation. For echoes it is your Page ID.
userRefstringUser ref instead of a PSID, sent for some plugin and Get Started postbacks before the person has a PSID
recipientIdstringRecipient of the event: your Page ID, or the person for echoes
textstringMessage text (the tapped quick reply title), or the title of the tapped postback button
messageIdstringMessage ID (mid) of the message or postback, or of the message reacted to
attachmentsjsonMessage attachments, each { type, url, title, stickerId } (image, audio, video, file, sticker, fallback, ...)
quickReplyPayloadstringPayload of the tapped quick reply (the phone number or email for those quick replies)
postbackPayloadstringPayload of the tapped postback button
postbackTitlestringTitle of the tapped postback button
referraljsonReferral from an m.me link, Click-to-Messenger ad, or Shops product page: { ref, source, type, adId, refererUri, adsContextData, productId }
reactionjsonFor reactions: { action: react | unreact, reaction, emoji }
readWatermarkstringFor read receipts: every message sent at or before this time (ms) was read
isEchobooleanTrue when the message was sent by your Page (only with Include Sent Messages)
timestampstringWhen the event happened (ISO 8601)
rawjsonThis event as Meta sent it: { sender, recipient, timestamp, message | postback | reaction | read | referral }
eventsjsonEvery matching event in this delivery (Meta can batch several), each with the fields above
eventCountnumberNumber of matching events in this delivery
deliveryjsonThe whole webhook payload exactly as Meta sent it: { object, entry }