Comment to DM Automation API: Build Instagram Auto-DMs in Code

Zernio's comment-to-DM automation lets developers build Instagram and Facebook auto-reply flows with a single API call. Get keyword triggers, auto-dedup, contact tracking, and real-time webhook processing.

Meta Business Partner

Zernio uses Meta's official Graph API for all comment-to-DM automations. No browser automation, no unofficial tools, no risk to your account.

Key Features

Keyword match

Match anywhere, on a whole word, or on the exact comment. Add exclusion keywords to veto a match, and typo tolerance so "giude" still fires.

Instant private reply DM

Meta's Private Reply API delivers the DM seconds after the comment. Send text, up to 3 buttons, or a swipeable product card.

Story-reply trigger

Fire the same automation when someone replies to an Instagram story with your keyword. One field on the automation, no separate flow to build.

Public comment reply

Post a public reply ("Check your DMs") alongside the private one. Add message variations so repeat commenters don't all get the same line.

Delay you control

Send instantly, or wait anything up to 24 hours. The match and the dedup still happen the moment the comment lands, only the send moves.

Built-in deduplication

Nobody gets the same automation's DM twice, however many times they comment.

Automatic contact creation

Every commenter who triggers becomes a contact with tags and custom fields, ready to segment for broadcasts and sequences.

Real-time webhooks

Zernio subscribes to Meta's comment webhooks, so a comment is picked up as it happens. No polling loop to run or pay for.

How It Works

  1. 1.
    Create an automation via API
    POST to /api/v1/comment-automations with your account ID, keywords, DM message, and optional public reply. One API call, done in seconds.
  2. 2.
    Someone comments on your post or reel
    A matching keyword on any post or reel is picked up in real time through Meta's comment webhook. Instagram story replies trigger the same way.
  3. 3.
    DM sent automatically
    You decide the timing: send right away, or set a delay of anything up to 24 hours. Zernio then sends the DM, optionally posts the public reply, and creates the contact.

Why Developers Choose API Over No-Code

Embed in Your Own Product

ManyChat and Inro are end-user tools. With Zernio's API, you can build comment-to-DM as a feature inside your own SaaS, white-label it, and offer it to your customers.

Programmatic Control

Create, update, pause, and delete automations via API. No manual clicking through a GUI. Integrate with your CI/CD pipeline, cron jobs, or admin dashboard.

No Per-Contact Billing

ManyChat charges $0.025 per contact with unpredictable overages. One viral post can double your bill. Zernio charges per social account, so your costs stay flat.

Built-in Contact CRM

Every commenter becomes a contact with tags, custom fields, and cross-platform identity. Build segmented audiences automatically from comment engagement.

Works with Reels, Feed Posts, and Carousels

Instagram Reels are treated as posts by Meta's API. The same comment webhook and DM endpoints work for Reels, feed posts, carousels, and Stories.

Meta-Approved and Safe

Uses Meta's official Private Reply API, not browser automation or unofficial tools. Your account stays safe. Zernio is a Meta Business Partner.

Code Examples

One API call sets up a keyword-triggered automation. Someone comments "guide" on any post or reel, they get the DM. Match on the whole word so "guidelines" doesn't fire it, and hold the send for 30 seconds so it doesn't look like a bot.

Create a comment-to-DM automation
javascript
const response = await fetch('https://zernio.com/api/v1/comment-automations', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    profileId: 'your-profile-id',
    accountId: 'your-instagram-account-id',
    name: 'Free Guide Giveaway',
    keywords: ['guide', 'free', 'link'],
    matchMode: 'word',
    typoTolerance: true,
    excludeKeywords: ['guidelines'],
    dmMessage: 'Thanks for your interest! Here is your free guide: https://example.com/guide',
    commentReply: 'Check your DMs!',
    dmDelaySeconds: 30
  })
});

const { automation } = await response.json();
console.log(automation.id); // Use this ID to update, pause, or view logs

The same automation object, pointed at a different door. Set trigger to story_reply and a keyword reply to your story sends the DM. Instagram only, and there is no public reply on a story.

Trigger on Instagram story replies
javascript
await fetch('https://zernio.com/api/v1/comment-automations', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    profileId: 'your-profile-id',
    accountId: 'your-instagram-account-id',
    name: 'Story link drop',
    trigger: 'story_reply',
    keywords: ['link'],
    matchMode: 'word',
    dmMessage: 'Here you go: https://example.com/drop'
    // platformPostId: omit to answer replies to any story
  })
});

Every automation comes back with its counters: triggers, DMs sent, DMs failed, unique contacts, and link clicks when link tracking is on.

List automations and check stats
javascript
const response = await fetch('https://zernio.com/api/v1/comment-automations', {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});

const { automations } = await response.json();
automations.forEach(automation => {
  console.log(automation.name, '·', automation.trigger);
  console.log('  Triggered:', automation.stats.triggered);
  console.log('  DMs sent:', automation.stats.dmsSent);
  console.log('  Unique contacts:', automation.stats.uniqueContacts);
  console.log('  Link clicks:', automation.stats.linkClicks);
});

Agents

Comment automations are on Zernio's MCP server, so an agent can set one up from a sentence. Same endpoints as above, no dashboard involved.

MCP server

Claude Code v2.1.19

Opus 4.5 · Claude Max

~/software

✓ found @studio.rivet · reel posted 2h ago

✓ created automation · word match · 30s delay

✓ live · commenters get the DM, replies stay deduped

Supported Platforms

Comment-to-DM automation works on Instagram and Facebook via Meta's Graph API. Both platforms use the same webhook flow and Private Reply endpoint.

See it in action

Comment triggers

Detect keywords in comments and trigger DM flows instantly.

Auto-DM conversations

Automated conversations that convert commenters into leads.

Common Questions About Comment-to-DM Automation

What is comment-to-DM automation?
Comment-to-DM automation automatically sends a private DM to anyone who comments a specific keyword on your Instagram or Facebook post. It's commonly used for lead magnets, discount codes, and giveaways. Zernio lets you set this up with one API call.
Does comment-to-DM work on Instagram reels?
Yes. Meta treats reels as posts, so the same automation covers reels, feed posts, and carousels. Stories work too, through the story-reply trigger: set the trigger to story_reply and a keyword reply to your story sends the DM. That one is Instagram only.
Can I delay the DM instead of sending it instantly?
Yes. Set dmDelaySeconds to anything from 0 to 86,400 (24 hours), and commentReplyDelaySeconds for the public reply. The keyword match and the dedup happen the moment the comment arrives, so a delay only moves when the message goes out. The public reply is never posted before the DM it announces.
How does keyword matching work?
Three modes. Contains matches anywhere, even inside another word, so "app" fires on "happy". Word matches the keyword on its own. Exact requires the whole comment to be the keyword. You can add exclusion keywords that veto a match, and turn on typo tolerance in word mode to catch close misspellings. Leave keywords empty and every comment triggers.
How is Zernio different from ManyChat for comment-to-DM?
ManyChat is a no-code tool for end users. Zernio's API is a ManyChat alternative that lets developers embed comment-to-DM as a feature inside their own applications with full programmatic control.
How fast are DMs sent after a comment?
Within seconds by default. Zernio subscribes to Meta's real-time comment webhooks, so there is no polling loop to wait on. If you'd rather it didn't look instant, set a delay of up to 24 hours and the send moves without changing when the match happens.
Is comment-to-DM automation safe for my Instagram account?
Yes, when it runs on Meta's official API rather than browser automation. Zernio is a Meta Business Partner and uses the Private Reply API, which is Meta's approved way to DM someone in response to a comment. Tools that scrape or drive the browser are what get accounts restricted.
What is the difference between comment-to-DM and auto-reply to DMs?
Comment-to-DM starts from a comment on a post. Auto-reply starts from someone messaging you. Zernio does both, and one automation can cover both doors: turn on alsoMatchInDms and the same keywords answer people who DM the word instead of commenting it.
How much does comment-to-DM automation cost?
You pay to connect social accounts, and nothing else. The first 2 are free, then it's $6 per account per month, dropping to $3 from 11 accounts and $1 from 101. Posting, commenting, and messaging are unlimited, so a post that goes viral costs you the same as one that doesn't.

Related

Add comment-to-DM to your app today

One API call to create an automation. Keyword triggers, auto-dedup, contact CRM, real-time webhooks. No drag-and-drop builder required.

SOC 2 CompliantGDPR Compliant