Oct 20, 2026 · AI Automation · Dr. Marcus Lim

Instagram Comment-to-DM Automation for RM0

I've been quiet on Instagram. Not ghosting, just busy teaching AI classes offline and doing on-site AI audits for clients. And when I did post, "link in bio" got basically zero clicks. Fair enough. I wouldn't click it either.

So I built my own "comment a keyword, get it in your DMs" automation. No ManyChat, no subscription. Just Meta's free official API and my Oracle Always Free instance. Here's the exact checklist, plus the 8 traps that kept it broken for 3 weeks.

What it does

  1. Someone comments a keyword on your post.
  2. Your account replies publicly: "Sent! Check your DMs 🙌"
  3. A few seconds later, they get a DM with the link you promised.

Under the hood: Meta sends each new comment to your Oracle Always Free instance (a webhook). It checks for the keyword, replies to the comment, then sends a private reply DM.

What it costs

PieceCost
Meta Graph API (Instagram via Facebook Login)RM0
An Oracle Always Free instance running the webhookRM0
Cloudflare Tunnel to expose it over HTTPSRM0
The code~30 lines for the core logic

The setup checklist

  1. Connect the accounts. Your Instagram must be a Professional account linked to a Facebook Page.
  2. Create a Meta developer app using Instagram via Facebook Login, with the comments and messaging permissions.
  3. Build the webhook. One endpoint that answers Meta's verification check (GET) and receives comment events (POST). Put it behind HTTPS, e.g. with a Cloudflare Tunnel.
  4. Subscribe the app to the "comments" field in the webhook settings.
  5. Subscribe your Page to the app via the subscribed_apps Graph API call. (Trap 1. Skip this and nothing arrives.)
  6. Publish a Privacy Policy and a Data Deletion page, add both URLs to the app, then switch the app to Live.
  7. Handle each comment: read id, mark it as handled, whole-word match the keyword, reply via /{comment-id}/replies, then send a private reply via /me/messages with recipient: { comment_id }. Use a 20-second timeout.
  8. Test from an account with no role on your app. Your own account always works. That proves nothing.

The 8 traps (none of them throw an obvious error)

  1. "Verified" doesn't mean connected. My webhook passed Meta's check and received zero comments in 3 weeks. The Page also has to be subscribed to the app, and nothing in the dashboard tells you.
  2. Development mode drops real events. The "Send test" button works perfectly. Real comments from real people never arrive.
  3. Going Live needs paperwork. Publish stays greyed out until you add a Privacy Policy URL and a Data Deletion URL. Once Live, events arrived within minutes.
  4. The field is called id. My code looked for comment_id, so every comment was silently skipped.
  5. You can't just DM a commenter. A normal DM fails if they've never messaged you. It has to be a private reply: one per comment, within 7 days.
  6. Meta sends the same event twice. Mark the comment as handled before any API call, or people get double replies.
  7. 5-second timeouts give blank errors. Meta is sometimes slow. Give it 20 seconds.
  8. "ciao" contains "aio". Substring matching fires on the wrong comments. Match whole words only.

Bonus red herring: one error claimed I needed the pages_messaging permission. I didn't. The test comment had been deleted. Meta's errors can point you the wrong way.

Honest caveats

  • Depending on your app, DMs to the general public may need Meta's Advanced Access (App Review) for the comments and messaging permissions.
  • Each comment gets at most one DM, within 7 days of the comment. That's Meta's rule.

The best part

My free guides, checklists and templates are now one comment away. See a keyword on my Instagram post, comment it, and it lands in your DMs. Even when I'm stuck in a classroom.

Want automations like this for your business? Start with where you stand.

Take the AI Readiness Index →