Skip to content

NotBot-Automation-Bots/Messenger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Messenger

The Send API is the main API used to send messages to users, including text, attachments, structured message templates, sender actions, and more.

Permissions

A page access token with pages_messaging permission is required to interact with this endpoint.

Apps in Development Mode, are restricted to message people that have a role in the app. Additionally Pages in unpublished status will only be allowed to message people with a role on the Page.

Steps to get page access token

  1. Create a Facebook page : https://www.facebook.com/help/104002523024878/

  2. Create a Facebook app https://developers.facebook.com/docs/development/create-an-app/

  3. Go to your Facebook app dashboard

    image

  4. Click on Messenger > Settings

  5. In the newly opened page, go to the Access Tokens section image

  6. Add the page created in Step 1 and generate an Access Token

  7. Now, go to the Webhooks section image

  8. Edit the callback URL, and provide the same Verify Token that you have used in your app.

  9. For more details, visit: https://developers.facebook.com/docs/messenger-platform/getting-started/app-setup/

  10. Make sure to select all the fields in the webhooks section image

Send API Reference

https://developers.facebook.com/docs/messenger-platform/send-messages#send_api_basics

Request URI

https://graph.facebook.com/v11.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "messaging_type": "<MESSAGING_TYPE>",
  "recipient": {
    "id": "<PSID>"
  },
  "message": {
    "text": "hello, world!"
  }
}' "https://graph.facebook.com/v11.0/me/messages?access_token=<PAGE_ACCESS_TOKEN>"

Properties

  • messaging_type : String

    The messaging type of the message being sent. https://developers.facebook.com/docs/messenger-platform/send-messages/#messaging_types

  • recipient : Object

    recipient object

  • message : Object

    message object. Cannot be sent with sender_action.

  • sender_action : Object

    Message state to display to the user:

    • typing_on: display the typing bubble
    • typing_off: remove the typing bubble
    • mark_seen: display the confirmation icon

    Cannot be sent with message. Must be sent as a separate request.

    When using sender_action, recipient should be the only other property set in the request.

API Response

A successful Send API request to a PSID returns a JSON string containing identifiers for the message and its recipient.

{
  "recipient_id": "1008372609250235",
  "message_id": "m_AG5Hz2Uq7tuwNEhXfYYKj8mJEM_QPpz5jdCK48PnKAjSdjfipqxqMvK8ma6AC8fplwlqLP_5cgXIbu7I3rBN0P"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published