The Comment Moderation API is a subset of Instagram Graph API endpoints that allow you to reply to comments, delete comments, hide/unhide comments, and disable/enable comments on media objects owned by Instagram Business and Instagram Creator Accounts.
The API consists of the following endpoints:
POST /{ig-comment-id}
— to hide/unhide comments.DELETE /{ig-comment-id}
— to delete comments.GET /{ig-comment-id}/replies
— to get replies to comments.POST /{ig-comment-id}/replies
— to reply to comments.POST /{ig-media-id}
— to disable/enable comments on a media objectRefer to each endpoint's reference documentation for parameter and permission requirements.
You can get all of the comments on a media object, analyze and filter the returned data set against specific criteria, then reply to any comments that match your criteria.
First, query the GET /{ig-media-id}/comments
endpoint to get all of the comments and their IDs on the media object:
GET graph.facebook.com /17895695668004550/comments
{ "data": [ { "timestamp": "2017-08-31T18:10:30+0000", "text": "I love this!", "id": "17873440459141021" }, { "timestamp": "2017-08-31T19:16:02+0000", "text": "This is awesome!", "id": "17870913679156914" }, ... // results truncated for brevity ] }
Next, parse the returned results for comments that match whatever criteria you are using and use the matching comments to reply in the comment thread to the Instagram users who made the comments:
POST graph.facebook.com /17870913679156914/replies?message=Thanks%20for%20sharing!
{ "id": "17873440459141029" }
If you have a lot of comments that you want to reply to, you could batch the replies into a single request.