Send a Private Message as a Page

This document explains how to message a person who commented on Page posts or messaged your Page.

Before You Start

You will need:

Reply to a Comment

Send a private message to a visitor who wrote a post on your Page or commented on a Page post.

Limitations

  • Only one reply can be sent per comment.
  • You can not reply to your own comments.
  • The Page being queried must be published.
  • If you app is in development mode, you can only reply to a comment made by a person who has a role on your app.
  • can_reply_privately must be true.

Step 1. Get Comments from a Page Post

Send a GET request to the /{page-id}/feed endpoint with the can_reply_privately, from, 'message, and comments fields:

curl -i -X GET "https://graph.facebook.com/{page-id}/feed/
     ?fields=can_reply_privately,from,message,comments{can_reply_privately,from,message}
     &access_token={page-access-token}"

On success, your app will receive the following response:

{
  "data": [
    {    // Page post with a Comment
      "can_reply_privately": false,  //Can't reply to your own post
      "from": {
        "name": "Clean Slate Page",
        "id": "{page-id}"
      },
      "message": "Hello World!",   //Page post message
      "comments": {
        "data": [
          {
            "can_reply_privately": true,   //Can reply to a visitor comment
            "from": {
              "name": "Cindy Hoover",
              "id": "{user-id}"
            },
            "message": "Keep up the good work!",   //Comment on the post
            "id": "{comment-id}"
          }
        ],
      },
      "id": "{page-post-id}"
    },
    {    //Page post by a Page visitor
      "can_reply_privately": true,       //Can reply to a visitor post
      "from": {
        "name": "Cinder Hoover",
        "id": "156407155145863"
      },
      "message": "Hello Clean Slate Page!"    //Visitor post message
      "id": "1983306698425200_2883179105104617"
    }
  ],
}

Step 2. Send a Private Message

Send a POST request to the {page-id}/messages endpoint where recipient is the comment_id:{comment-id} or post_id:{page-post-id} of the comment or post the visitor made on your Page:

curl -i -X POST "https://graph.facebook.com/{page-id}/messages
     ?recipient={post_id:{page-post-id}}
     &message={text:Thanks, Cindy!}
     &message_type=RESPONSE
     &access_token={page-access-token}"

Reply to a Message

Step 1. Get a Conversation Thread

Send a GET request to the /{page-id}/conversations endpoint:

curl -i -X GET "https://graph.facebook.com/{page-id}/conversations
  ?fields=id,messages{message,from}
  access_token={page_access_token}"

On success, your app receives this response:

{
  "data": [
    {
      "id": "t_100023297371310",      // The Conversation ID
      "messages": {
        "data": [
          {
            "message": "Thanks, Kerry!",
"from": {
              "name": "Page Name",
              "email": "{page-id}@facebook.com",
              "id": "{page-id}"
            },
            "id": "m_glADDQqH2yRWzcXI2wu7_S7ARkXcpFndCC-noYLufbGR-TfBy6yyEts5PwqLia1qJ_3OorlB55QgxG5EuERP8g"    //The Message ID
          },
          {
            "message": "I love coffee! Keep up the good work!",
"from": {
              "name": "Kerry Smith",
              "email": "{user-id}@facebook.com",
              "id": "{user-id}"
            },
            "id": "m_P7PeTWv6ctJ7QIw1MPzLbi7ARkXcpFndCC-noYLufbGLZo92oEJnqRfo605ScNxzaqBCWlOk1nlpqM73OZqYdQ"
          },

...
  ]
}

Step 2. Reply to a Message

Send a POST request to the conversation_id/messages endpoint and set the message parameter to your message text.

Sample Request

curl -i -X POST "https://graph.facebook.com/{conversation-id}/messages
  &message=Thanks, Kerry!
  &access_token={page_access_token}"

On success, your app receives this response:

{
  "id": "m_P7PeTW...",
  "uuid": "P7PeTWv6..."
}