Private Replies

This documents shows you how to programmatically add the Private Replies to your messaging experience.

How It Works

Private Replies allows an Instagram Professional account to send a single message to a person who commented on your Instagram Professional post, ads post, reel, or live story.

When you receive a comments or live_comments webhooks notification, via the Instagram Graph API, that a person has commmented on your Instagram Professional post, ads post, reel, or live story, you can use the comment ID to send a private response directly to that person. This reply will be delivered in the person's Inbox folder, if the person follows the business' Instagram Professional account, or to the person's Request folder, if the person does not follow the account.

You can send this private reply within 7 days of the creation time of the comment, excepting Instagram Live for which you can only send a private reply during the live broadcast. The message will contain a link to the post that the person commented on.

Webhooks

  • When hosting an Instagram Live story, make sure you server can handle the increased load of notifications triggered by live_comments webhooks events, via the Instagram API, and that your system can differentiate between live_comments and comments notifications.
  • Instagram Graph API comments webhooks notifications for ads posts will include the ID and title for the ad. You may need to update your webhooks server to handle these new fields.

    The ad_id and ad_title will be returned in the media object when a person comments on a boosted Instagram post or Instagram ads post. This may result in duplicate webhook notifications.

Limitations

  • Only one message can be sent to the person who commented
  • The message must be sent within 7 days from when the comment was created for comments on a post, ads post, or reel
  • Due to the transient nature of Instagram Live Stories, private replies on Instagram Live Story comments can only be sent during the live broadcast. As soon as the live broadcast has ended, private replies can no longer be sent.
  • Only when a person responds to the private message can you continue the conversation within the 24-hour messaging window.
  • Standard Access apps can only access data for people who have a role on the app
  • Private replies for IGTV comments are not supported
  • API v7.0 or older need the Human Agent feature and the Human Agent Message Tag for private replies

Before You Start

This tutorial assumes you have read the Messenger Platform Overview and the Instagram Messaging Overview and implemented the needed components.

You will need:

  • The ID for the Facebook Page linked to your Instagram Professional account
  • The ID for the comment made by the person to whom you are sending the private reply. The ID can be obtained from the Instagram comments webhooks, for posts, ads posts, and reels, and Instagram live_comments webhooks for live stories (recommended to avoid rate limiting) or an API call to the /page/feed endpoint
  • The instagram_manage_comments and pages_messaging permissions, obtained via Facebook Login
  • A Page access token requested by a person who can perform the MESSAGING task on the Facebook Page linked to your Instagram Professional account
  • The Human Agent feature
  • Advanced Access

Send a Private Reply

To send a private reply to a person who commented on your post, reel, or live story, send POST request to the /PAGE-ID/messages endpoint where the recipient parameter contains the comment ID and the message parameter contains the text you wish to send.

Formatted for readability.
curl -i -X POST "https://graph.facebook.com/PAGE-ID/messages
  ?recipient: { comment_id: COMMENT-ID }
  &message: { "text": "Thanks for reaching out, how can I help?" }
  &access_token=PAGE-ACCESS-TOKEN"
GraphRequest request = GraphRequest.newPostRequest(
  accessToken,
  "/1353269864728879/messages",
  new JSONObject("{\"recipient\":\"{comment_id: 18000158536435933}\",\"message\":\"{\\\"text\\\": \\\"It is cool\\\"}\"}"),
  new GraphRequest.Callback() {
    @Override
    public void onCompleted(GraphResponse response) {
      // Insert your code here
    }
});
request.executeAsync();
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
    initWithGraphPath:@"/1353269864728879/messages"
           parameters:@{ @"recipient": @"{comment_id: 18000158536435933}",@"message": @"{"text": "It is cool"}",}
           HTTPMethod:@"POST"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    // Insert your code here
}];
FB.api(
  '/1353269864728879/messages',
  'POST',
  {"recipient":"{comment_id: 18000158536435933}","message":"{\"text\": \"It is cool\"}"},
  function(response) {
      // Insert your code here
  }
);

On success, your app will receive the following response:

{
  "recipient_id": "526...",   // The Instagram-scoped ID 
  "message_id": "aWdfZ..."    // The message ID for your private reply
}

See Also

Developer Support