Create comment-to-DM automation
Create a keyword-triggered DM automation on an Instagram or Facebook account.
When someone comments a matching keyword (or, with trigger: story_reply, replies
to your Instagram story with one), they automatically receive a DM.
Triggers (trigger):
comment(default): fires on keyword comments on a post or reel.story_reply: fires when someone replies to your Instagram story with a keyword, and answers them with a DM. SetplatformPostIdto a story media id to scope to one story, or omit it to match replies to any story.
Targeting (comment trigger):
- Per-post: set
platformPostIdto scope to one specific post (only one active per-post automation is allowed per post). - Account-wide ("any post"): omit
platformPostId(andpostId). The automation evaluates every comment on every post on the account. You can stack unlimited account-wide automations, each with its own keyword set, and they all run independently. Per-post automations take priority on their post.
Links in the DM's buttons can be click-tracked (linkTracking, on by default) and
clickers optionally tagged (clickTag) for segmentation. Stats returned include
delivered, read, and link clicks.
API key authentication - use your Zernio API key as a Bearer token
In: header
Instagram or Facebook account ID
What fires the automation. 'comment' (keyword comment on a post) or 'story_reply' (keyword reply to an Instagram story). For 'story_reply', platformPostId is the story media id (omit for any story).
"comment""comment" | "story_reply"Platform media/post ID (or story media id when trigger=story_reply). Omit for an account-wide (any-post / any-story) automation.
Zernio post ID. Required only when also targeting a specific post via platformPostId.
Post content snippet for display
Automation label
Trigger keywords (empty = any comment triggers)
"contains""exact" | "contains"DM text to send to commenter. Max 640 chars when buttons are set, otherwise ~1000.
Optional inline DM buttons (1-3). Phone buttons are Facebook-only. Omit or pass [] for a plain-text DM.
items <= 3Optional public reply to the comment
Wrap link buttons in the DM in a tracked redirect so clicks are counted (Link Clicks / CTR). Pass false to send links exactly as written. Defaults to on.
trueOptional tag applied to a contact when they click a tracked link (requires linkTracking). Lets you segment clickers for broadcasts/sequences.
Response Body
application/json
application/json
import Zernio from '@zernio/node';const zernio = new Zernio({ apiKey: process.env.ZERNIO_API_KEY });const { data } = await zernio.commentautomations.createCommentAutomation({ body: { profileId: 'profile_abc123', accountId: 'account_abc123', name: 'Example', dmMessage: 'string', },});console.log(data);{
"success": true,
"automation": {
"id": "string",
"name": "string",
"platform": "string",
"trigger": "comment",
"platformPostId": "string",
"keywords": [
"string"
],
"matchMode": "exact",
"dmMessage": "string",
"buttons": [
{
"type": "url",
"title": "string",
"url": "http://example.com",
"payload": "string",
"phone": "string"
}
],
"commentReply": "string",
"linkTracking": true,
"clickTag": "string",
"isActive": true,
"stats": {
"totalTriggered": 0,
"totalSent": 0,
"totalFailed": 0
},
"createdAt": "2019-08-24T14:15:22Z"
}
}{
"error": "Unauthorized"
}