The Send API is the main API used to send messages to users, including text, attachments, templates, sender actions, and more.
Create and send messages to your customers or people interested in your Facebook Page.
You will need:
MESSAGE
task on the Pagepages_messaging
permissionNote that the Send API does not include recipient_id
in the response for messages sent using recipient.user_ref
or recipient.phone_number
to identify the message recipient.
To send a message to a person, send a POST
request to the /PAGE-ID/messsages
endpoint with the messaging_type
and recipient
parameters set, and the message content.
The following example is a response to a person's message where the message your Page is sending is text only.
curl -i -X POST "https://graph.facebook.com/LATEST-API-VERSION/PAGE-ID/messages ?recipient={'id':'PSID'} &messaging_type=RESPONSE &message={'text':'hello,world'} &access_token=PAGE-ACCESS-TOKEN
On success, your app will receive the following JSON response:
{ "recipient_id": "PAGE-SCOPED-ID", "message_id": "AG5Hz2U..." }
message
The type of message your Page is sending. Either text
or attachement
must be set when using this parameter.
attachment
object – Previews the URL. Used to send messages with media or Structured Messages. text
or attachment
must be set.
type
– Type of attachement. Can be audio
, file
, image
, template
, or video
. Maximum file size is 25MBpayload
– An object containing a template content
or file content
metadata
– A string of additional data you want to pass in the message_echo
webhook. Must be less than 1000 characters
quick_replies
– An array of quick replies to be sent in a messagetext
– A message containing text only. Must be UTF-8 and less than 2000 characters. messaging_type
Required
The type of message being sent
RESPONSE
– Message is in response to a received message. This includes promotional and non-promotional messages sent inside the 24-hour standard messaging window
. For example, use this tag to respond if a person asks for a reservation confirmation or an status update.UPDATE
– Message is being sent proactively and is not in response to a received message. This includes promotional and non-promotional messages sent inside the the 24-hour standard messaging window
.MESSAGE_TAG
– Message is non-promotional and is being sent outside the 24-hour standard messaging window
with a message tag
. The message must match the allowed use case for the tag. notification_type
Type of push notification a person will receive
NO_PUSH
– No notificationREGULAR
(default) – Sound or vibration when a message is received by a personSILENT_PUSH
– On-screen notification only recipient
Required
The person who will receive the message your Page is sending
id
– The Page-scoped ID for the person that is used to sen a message in response to a message received by your Page within the last 24 hours or for a person who has agreed to receive messages from your Page outside the standard 24 hour messaging windowuser_ref
– The reference for the person that is used to send a message in response to a Checkbox or Customer Chat Plugincomment_id
– The ID for the comment that is used to send a message as a Private Reply in response to a visitor Comment on your Page Postpost_id
– The ID for the Page Post that is used to send a message as a Private Reply in response to a visitor Post on your Page sender_action
The action icon shown in the messaging window representing the action taken by the Page on a message the Page has received from a person.
typing_on
– Display the typing bubble when the Page is preparing a responsetyping_off
– Do not display the typing bubblemark_seen
– Display the seen icon for messages that have been seen by the PageCan only be sent with the recipient
parameter. Cannot be sent with the message
parameter but must be sent as a separate request.
tag
A tag that enables your Page to send a message to a person outsde the standard 24 hour messaging window.
ACCOUNT_UPDATE
– Tags the message you are sending to your customer as a non-recurring update to their application or account. View the allowed uses.
Not available for Instagram Messaging API.
CONFIRMED_EVENT_UPDATE
– Tags the message you are sending to your customer as a reminder fo an upcoming event or an update for an event in procgres for which the customer is registered. View the allowed uses.
Not available for Instagram Messaging API.
CUSTOMER_FEEDBACK
– Tags the message you are sending to your customer as a Customer Feedback Survey
. Customer feedback messages must be sent within 7 days of the customer's last message. View the allowed uses.
Not available for Instagram Messaging API.
HUMAN_AGENT
– Required for Instagram Messaging API.
When this tag is added to a message being sent to a person, it allows a human agent to respond to the person's message. Messages can be sent within 7 days of the person's message. Human agent support is for issues that cannot be resolved within the standard messaging window. View the allowed uses.
Human Agent
permission via the Developer App dashboard. Navigate to App dashboard -> App review -> Permissions & Features -> Human Agent. Apps that were previously approved for beta access to the Human Agent permission do not need to re-apply for access. Human Agent
permission is not available in standard access or development mode. You will need to complete the app review process before you can leverage the human agent tag. During app review submission, please provide clear instructions and a demonstration for how you intend to leverage the human agent tag in your experiences.
POST_PURCHASE_UPDATE
– Tags the message you are sending to your customer as an update for a recent purchase made by the customer. View the allowed uses.
Not available for Instagram Messaging API.
The following table lists the types of messaging for each message tag.
ACCOUNT_UPDATE
Not available for Instagram Messaging API.
CONFIRMED_EVENT_UPDATE
Not available for Instagram Messaging API.
CUSTOMER_FEEDBACK
Not available for Instagram Messaging API.
HUMAN_AGENT
Required for Instagram Messaging API.
POST_PURCHASE_UPDATE
Not available for Instagram Messaging API.
You can't perform this operation on this endpoint.
To get information about conversations your Page are a part of visit the Page Conversations Reference .
You can't perform this operation on this endpoint.
You can't perform this operation on this endpoint.