Comment to DM Automation API: Build Instagram Auto-DMs in Code
Instagram comment-to-DM automation drives 90%+ open rates vs 20% for email. Tools like ManyChat are no-code only and can't embed in your own app. With Zernio's API, you get keyword triggers, auto-dedup, contact tracking, and real-time webhook processing. One API call to create an automation. No drag-and-drop builder required.
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 Triggers
Set exact or contains matching on comment text. Trigger on specific keywords like 'LINK', 'FREE', or 'PRICE', or leave keywords empty to trigger on any comment.
Instant Private Reply DM
When a keyword matches, Zernio sends a DM to the commenter via Meta's Private Reply API within 1-3 seconds. Include links, discount codes, lead magnets, or any text.
Optional Public Comment Reply
Automatically reply to the comment publicly (e.g. 'Check your DMs!') in addition to sending the private DM. Drives engagement and social proof on the post.
Built-in Deduplication
Won't DM the same person twice per automation. Tracks unique commenters automatically so you never spam a user who comments multiple times on the same post.
Automatic Contact Creation
Every commenter who triggers an automation is auto-added to your Zernio contact CRM with tags, custom fields, and cross-platform identity linking. Build your audience automatically.
Real-Time Webhook Processing
Zernio subscribes to Meta's comment webhooks and processes them in real-time. No polling, no delays. Comments are detected and DMs sent within seconds.
Stats and Logging
Track triggered count, DMs sent, DMs failed, and unique contacts per automation. View detailed logs for every trigger event to debug and optimize.
Instagram + Facebook
Comment-to-DM works on both Instagram and Facebook posts. Same API, same webhook flow, same automation object. Every competitor is Instagram-only.
How It Works
- 1.Create an automation via APIPOST to /api/v1/comment-automations with your account ID, keywords, DM message, and optional public reply. One API call, done in seconds.
- 2.User comments on your postWhen someone comments a matching keyword on any of your posts or Reels, Zernio's webhook listener detects it in real-time via Meta's Graph API.
- 3.DM sent automaticallyZernio sends a private DM to the commenter within 1-3 seconds, optionally posts a public reply, creates a contact in your CRM, and logs the event.
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 to set up a keyword-triggered comment-to-DM automation. When someone comments 'guide', 'free', or 'link' on any of your posts, they instantly receive a DM with your link.
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({
accountId: 'your-instagram-account-id',
name: 'Free Guide Giveaway',
keywords: ['guide', 'free', 'link'],
matchMode: 'contains',
dmMessage: 'Thanks for your interest! Here is your free guide: https://example.com/guide',
commentReply: 'Check your DMs!'
})
});
const automation = await response.json();
console.log(automation.id); // Use this ID to update, pause, or view logsFetch all your automations with their performance stats: total triggers, DMs sent, DMs failed, and unique contacts reached.
const response = await fetch('https://zernio.com/api/v1/comment-automations', {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
const { data } = await response.json();
data.forEach(automation => {
console.log(automation.name);
console.log(' Triggered:', automation.stats.triggered);
console.log(' DMs sent:', automation.stats.dmsSent);
console.log(' Unique contacts:', automation.stats.uniqueContacts);
});If you prefer building directly on Meta's API, here is the webhook handler and Private Reply call. This is what Zernio abstracts away for you.
// 1. Webhook handler for incoming comments
app.post('/webhook/instagram', (req, res) => {
const { entry } = req.body;
for (const page of entry) {
for (const change of page.changes) {
if (change.field === 'comments') {
const comment = change.value;
const text = comment.text.toLowerCase();
// 2. Keyword matching
const keywords = ['guide', 'free', 'link'];
const matches = keywords.some(kw => text.includes(kw));
if (matches) {
// 3. Send DM via Private Reply API
await fetch(
`https://graph.facebook.com/v21.0/${PAGE_ID}/messages`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
recipient: { comment_id: comment.id },
message: { text: 'Here is your free guide: https://...' }
})
}
);
}
}
}
}
res.sendStatus(200);
});
// With Zernio: one API call replaces all of the aboveSupported 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

Schedule and manage posts across all platforms.

Connect all your social accounts in one place.

Simple dashboard with powerful API access.
Common Questions About Comment-to-DM Automation
- What is comment-to-DM automation?
- └Comment-to-DM is a social media automation that sends a Direct Message to users who comment on your posts. When someone comments a specific keyword (e.g. 'LINK' or 'FREE'), the automation instantly delivers a pre-written DM containing a link, discount code, or lead magnet. DMs have 90%+ open rates compared to 20% for email, making this one of the highest-converting lead capture methods on Instagram.
- Is comment-to-DM automation safe for my Instagram account?
- └Yes, when using Meta's official API (not browser automation or unofficial tools). Zernio and ManyChat are both Meta Business Partners using the official Graph API. The Private Reply API is Meta's approved method for sending DMs in response to comments. Unofficial tools that scrape or automate the browser can get your account restricted.
- Do I need a Business account for comment-to-DM?
- └Yes. Instagram requires a Business or Creator account connected to a Facebook Page to use the Messaging API for private replies. Personal accounts cannot use the comment-to-DM API.
- How fast are automated DMs sent?
- └With webhook-based systems like Zernio, DMs are sent within 1-3 seconds of the comment being posted. Zernio subscribes to Meta's real-time webhooks, so there is no polling delay.
- Does comment-to-DM work for Instagram Reels?
- └Yes. Instagram Reels are treated as posts by Meta's API, so the same comment webhook and Private Reply endpoints work for Reel comments, feed post comments, and carousel comments.
- Can I trigger on any comment or just specific keywords?
- └Both. Zernio supports keyword triggers with exact or contains matching. You can also leave keywords empty to trigger the automation on any comment, regardless of what the user types.
- What is the difference between comment-to-DM and auto-reply to DMs?
- └Comment-to-DM triggers when someone comments on a post and sends them a DM. Auto-reply to DMs triggers when someone sends you a direct message and responds automatically. They are different automation types. Zernio supports both via separate API endpoints.
- Why use an API instead of ManyChat or Inro?
- └ManyChat and Inro are no-code tools for creators and marketers. They have no public API, so you cannot build comment-to-DM into your own SaaS product, white-label it, or control it programmatically. Zernio's API lets developers embed comment-to-DM as a feature inside their own applications with full programmatic control.
- Does comment-to-DM work on Facebook too?
- └Yes. Zernio supports comment-to-DM on both Instagram and Facebook. Both use Meta's Graph API with the same Private Reply endpoint. Most competitors only support Instagram.
- How much does comment-to-DM automation cost?
- └Zernio's comment automation is included with the Inbox add-on. No per-contact billing, no per-message fees. ManyChat charges per contact ($0.025/contact overage) which can get expensive with viral posts. Zernio charges per social account with flat, predictable pricing.
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.

