This documents shows you how to programmatically send a private reply to a person who commented on your Instagram professional post, reel, story, Live, or ad post. How It Works
|
This guide assumes you have set up your webhooks server to receive notifications and subscribed your app to Instagram comments
and live_comments
events.
Note: When hosting an Instagram Live story, make sure your server can handle the increased load of notifications triggered by live_comments
webhooks events and that your system can differentiate between live_comments
and comments
notifications.
You will need:
instagram_business_basic
and instagram_business_manage_messages
permissions
From the comments
or live_comments
webhook notification (recommended)
or
Instagram Comment Moderation API:
<IG_PRO_USER_ID>
<COMMENT_ID>
https://graph.instagram.com
To send a private reply to a person who commented on your app user's Instagram professional post, reel, or story, send a POST
request to the <IG_PRO_USER_ID>/messages
endpoint where the recipient
parameter contains the comment's ID and the message
parameter contains the text you wish to send.
curl -i -X POST "https://graph.instagram.com/<IG_PRO_USER_ID>/messages" -H "Content-Type: application/json" -H "Authorization: Bearer <INSTAGRAM_USER_ACCESS_TOKEN>" -d '{ "recipient":{ "comment_id": "<COMMENT_ID>" }, "message": { "text": "<COMMENT_TEXT>" } }'
On success, your app will receive a JSON response with the recipient's Instagram-scoped ID and the ID for the message.
{ "recipient_id": "526...", // The Instagram-scoped ID "message_id": "aWdfZ..." // The ID for your private reply message }