How to Auto-Reply to Instagram Comments via API
Reply to Instagram comments programmatically — comment webhooks in, replies out, with author signals for routing. One Comments API for Instagram, Facebook, and Threads.
The auto-reply loop
Three pieces: a webhook that delivers new comments, logic that decides the reply, and one POST that sends it.
Postproxy syncs comments on your published posts and fires a comment.created webhook for each new one. Your handler replies through the Comments API — the same endpoints work on Instagram, Facebook, and Threads.
Reply to a comment
curl -X POST "https://api.postproxy.dev/api/posts/POST_ID/comments?profile_id=PROFILE_ID" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "body": "Sizes run true — check the chart in our bio link.", "parent_id": "COMMENT_ID" }'parent_id accepts the Postproxy hashid or Instagram’s native comment ID. Omit it to comment on the post itself. The reply is created with status: "pending" and published asynchronously; once live, external_id and permalink are populated.
Instagram comments are text-only — media in a reply returns an error. Captions max out where Instagram caps them, so keep replies short anyway.
The webhook handler
app.post("/webhooks/postproxy", async (req, res) => { res.sendStatus(200);
const event = req.body; if (event.type !== "comment.created") return;
const c = event.data.object; if (c.platform !== "instagram") return; if (c.author_external_id === MY_PROFILE_EXTERNAL_ID) return; // never reply to yourself
const reply = decideReply(c.body); // your logic: keyword map, FAQ matcher, LLM if (!reply) return;
await fetch( `https://api.postproxy.dev/api/posts/${c.post_id}/comments?profile_id=${PROFILE_ID}`, { method: "POST", headers: { Authorization: `Bearer ${process.env.POSTPROXY_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ body: reply, parent_id: c.id }), } );});The self-check matters: your own replies also sync and fire comment.created. Skip anything authored by your profile or you’ve built an infinite loop with yourself.
Decide who gets a reply
Each synced comment carries author signals in metadata, fetched from Meta after ingestion:
is_verified_user— verified accountfollower_count— author’s audience sizeis_user_follow_business/is_business_follow_user— follow relationship
A common policy: auto-reply to questions, route verified or high-follower authors to a human, and hide anything that trips your spam filter.
Backfill and audit with list
Webhooks are the real-time path; GET covers everything else — backfills after downtime, dashboards, reply audits:
curl "https://api.postproxy.dev/api/posts/POST_ID/comments?profile_id=PROFILE_ID&per_page=50" \ -H "Authorization: Bearer YOUR_API_KEY"Top-level comments are paginated; each carries a flat replies array with parent_external_id preserved, so threads reconstruct cleanly.
What works where
| Action | Threads | ||
|---|---|---|---|
| List | Yes | Yes | Yes |
| Reply | Yes | Yes | Yes |
| Hide / Unhide | Yes | Yes | Yes |
| Delete | Yes | Yes | No |
| Like / Unlike | No | Yes | No |
Unsupported actions return 405, so a cross-platform handler can just try and fall through.
Going further
- Turn a comment into a DM with a private reply — the highest-converting follow-up to a public reply.
- Auto-hide spam and slurs with the moderation guide.
- Full field reference and error shapes: Comments API.