Create comment-to-DM automation
Create a keyword-triggered DM automation on an Instagram or Facebook account. When someone comments a matching keyword, they automatically receive a DM. Two modes: * **Per-post** — set `platformPostId` to scope the automation to one specific post. Only one active per-post automation is allowed per post. * **Account-wide ("any post")** — omit `platformPostId` (and `postId`). 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.
API key authentication - use your Zernio API key as a Bearer token
In: header
Instagram or Facebook account ID
Platform media/post ID. Omit for an account-wide (any-post) 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
Optional public reply to the comment
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",
"platformPostId": "string",
"keywords": [
"string"
],
"matchMode": "exact",
"dmMessage": "string",
"commentReply": "string",
"isActive": true,
"stats": {
"totalTriggered": 0,
"totalSent": 0,
"totalFailed": 0
},
"createdAt": "2019-08-24T14:15:22Z"
}
}{
"error": "Unauthorized"
}