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
- Someone comments a keyword on your post.
- Your account replies publicly: "Sent! Check your DMs 🙌"
- 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
| Piece | Cost |
|---|---|
| Meta Graph API (Instagram via Facebook Login) | RM0 |
| An Oracle Always Free instance running the webhook | RM0 |
| Cloudflare Tunnel to expose it over HTTPS | RM0 |
| The code | ~30 lines for the core logic |
The setup checklist
- Connect the accounts. Your Instagram must be a Professional account linked to a Facebook Page.
- Create a Meta developer app using Instagram via Facebook Login, with the comments and messaging permissions.
- 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.
- Subscribe the app to the "comments" field in the webhook settings.
- Subscribe your Page to the app via the
subscribed_appsGraph API call. (Trap 1. Skip this and nothing arrives.) - Publish a Privacy Policy and a Data Deletion page, add both URLs to the app, then switch the app to Live.
- 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/messageswithrecipient: { comment_id }. Use a 20-second timeout. - 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)
- "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.
- Development mode drops real events. The "Send test" button works perfectly. Real comments from real people never arrive.
- 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.
- The field is called
id. My code looked forcomment_id, so every comment was silently skipped. - 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.
- Meta sends the same event twice. Mark the comment as handled before any API call, or people get double replies.
- 5-second timeouts give blank errors. Meta is sometimes slow. Give it 20 seconds.
- "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 →