OmniSocialsOmniSocials
DocumentationAPI reference
Help centerSupport
  • Documentation
  • API reference
Developers
  • Quickstart
  • API reference
  • SDKs
  • MCP server
  • CLI
For AI agents
  • Docs for AI agents
  • llms.txt
  • OpenAPI spec
  • Postman collection
Product
  • OmniSocials
  • Pricing
  • Changelog
  • Help center
Company
  • Support
  • Privacy policy
  • Terms of service

© 2026 OmniSocials

OmniSocials on GitHubOmniSocials on XOmniSocials on LinkedIn
Overview
Get started
SDKs
CLI
MCPDocs for AI agentsWebhooks
Guides
    PostsStoriesReelsCross-postingMediaAnalyticsX statistics and creditsPost tagsSocial inboxAutomations
Platforms
Integrations
Migrate
Plans and billing
GlossaryChangelogAPI reference
Guides

Comment-to-DM Automations API: Instagram, Facebook and X keyword DMs

A comment-to-DM automation answers a keyword with a private message. When somebody comments "guide" on your post, the account sends them the guide in a DM, once per person, and can post a public reply under the comment ("Sent you a DM!"). The same automation can listen to a keyword in a DM to the account, and on Instagram to a keyword in a reply to a story.

An automation runs on one channel, set by platform:

  • instagram (the default): the connected Instagram account.
  • facebook: the connected Facebook Page. The DM lands in the person's Messenger.
  • x: the connected X account. It answers DMs only, never a post. See On X.

Automations are managed with the Automations endpoints (GET/POST /automations, GET/PATCH/DELETE /automations/:id, GET /automations/:id/events), or attached to a new post with comment_dm_automation on POST /posts/create. Everything you create here shows up on the Automations page in the dashboard, and the other way round.

Enabling automation access

The scopes are opt-in, like the inbox scopes: an automation sends DMs in your account's name, and its activity carries what people wrote. When you create an API key, turn on Automations to grant automations:read (list, get, activity) and automations:write (create, update, delete, and comment_dm_automation on posts). Existing keys are not given these scopes automatically; without them every endpoint answers 403 insufficient_scope.

Creating an automation

JSON
POST /automations { "name": "Free guide", "post_id": "83778183", "trigger": { "keywords": ["guide", "link"], "match": "word" }, "actions": { "dm": { "text": "Here is the guide: https://example.com/guide" }, "public_reply": { "enabled": true, "variations": ["Sent you a DM!", "Check your inbox"] } }, "limits": { "max_sends": 500 } }
FieldMeaning
platforminstagram (default), facebook (the connected Facebook Page) or x (the connected X account, DMs only). Set at create; it never changes. instagram_media_id implies instagram and facebook_post_id implies facebook.
trigger.kindsWhat starts the automation: comment (default) = a comment on a post or reel, dm = a keyword in a DM to the account (on Facebook: a Messenger message to the Page), story_reply = a keyword in a reply to an Instagram story. One automation can listen to several. Facebook has no story replies: story_reply on a Facebook automation answers 400 validation_error. On X only dm exists: pass ["dm"], since comment or story_reply there answers 400 validation_error.
trigger.scopeFor the comment kind: post (default) = one post, next_post = the next post the workspace publishes on the automation's platform, any = every post of the account or Page.
post_idFor scope post: an OmniSocials post that goes to the automation's platform, scheduled or already live. A scheduled post starts listening once it is live. One automation per post and platform: a post that goes to Instagram and Facebook can have one of each.
instagram_media_idFor scope post on Instagram: the numeric id of a post or reel that was published outside OmniSocials (from Instagram's API, GET /me/media). OmniSocials reads it from Instagram to check it belongs to the connected account.
facebook_post_idFor scope post on Facebook: the id of a post that was published on the Page outside OmniSocials, as {page-id}_{post-id} or the post id alone (OmniSocials puts the Page id in front). OmniSocials reads it from Facebook to check it belongs to the connected Page.
trigger.keywordsUp to 20 keywords, matched case-insensitively. Required unless match is any.
trigger.matchword (default): the keyword stands on its own ("guide", "Guide!" match; "linkedin" does not match "link"). contains: the keyword appears anywhere. any: every comment or message with text.
actions.dm.textThe DM, max 1000 characters. Sent once per person per automation.
actions.public_replyA public reply under the comment, for the comment kind only. One of variations (up to 10) is picked at random per comment.
actions.follow_gateFollow first, Instagram only: the DM goes out only to people who follow the account. See Follow first.
limits.max_sendsStop after this many DMs; the automation becomes completed.
limits.stop_atStop at this time (ISO 8601).
statusactive (default) or paused to create it without turning it on. An active X automation needs X DMs on for the workspace (409 x_dms_off); paused always saves.

Pass at most one of post_id, instagram_media_id and facebook_post_id. All three need scope post.

The response is the automation with platform, the live id of the post (instagram_media_id on Instagram, facebook_post_id on Facebook; set once the post is live, null on the other channel), a post snapshot (source is omnisocials, instagram or facebook, with caption, thumbnail_url, permalink), actions.follow_gate (with its texts; null on Facebook and X) and stats (matched, sent, skipped, failed, followed, last_event_at).

A keyword in any DM or story reply, no post needed:

JSON
POST /automations { "trigger": { "kinds": ["dm", "story_reply"], "keywords": ["menu"] }, "actions": { "dm": { "text": "Our menu: https://example.com/menu" } } }

On a Facebook Page

The same body with platform: "facebook". For a Page post that was published outside OmniSocials, pass facebook_post_id:

JSON
POST /automations { "platform": "facebook", "facebook_post_id": "104857600123456_987654321098765", "trigger": { "keywords": ["guide"] }, "actions": { "dm": { "text": "Here is the guide: https://example.com/guide" }, "public_reply": { "enabled": true, "variations": ["Sent you a message!"] } } }

A keyword in a Messenger message to the Page, no post needed:

JSON
POST /automations { "platform": "facebook", "trigger": { "kinds": ["dm"], "keywords": ["menu"] }, "actions": { "dm": { "text": "Our menu: https://example.com/menu" } } }

On X

On X an automation answers a DM. When somebody sends your X account a DM with one of the keywords, the account answers with actions.dm.text, once per person. With "match": "any" it answers the first message of every person who writes.

JSON
POST /automations { "platform": "x", "trigger": { "kinds": ["dm"], "keywords": ["pricing"] }, "actions": { "dm": { "text": "Our plans: https://example.com/plans" } } }
  • DMs only. X allows an automated DM only after the person wrote to you first, so trigger.kinds is ["dm"]. A comment or story_reply trigger answers 400 validation_error. An X automation has no post fields (post_id, scope) and no public reply.
  • X DMs must be on. The automation answers the DMs that X sends to OmniSocials, so the workspace needs X DMs turned on in the dashboard: the X DMs card in the Social Inbox, or the automation editor. See X direct messages. Without them, creating an active X automation, or a PATCH to status: "active", answers 409 x_dms_off. status: "paused" always saves, so you can create the automation first and turn it on later. No X account in the workspace answers 409 x_not_connected.
  • The stop line and the stop list. Every X answer ends with the line "Reply STOP to stop automatic messages." A person who replies with only "stop" (or "unsubscribe", "opt out", "cancel", "end", "quit") goes on the stop list of that X account: no automation sends them a DM from that account again. The stop list belongs to the X account, not to one automation: it holds after the automation is deleted, for automations made later, and in every workspace that has the same X account. Another X account still answers the person. Their message shows in the activity with outcome opted_out, and an answer that was waiting in the queue when they said stop is skipped with reason opted_out.
  • Send caps. OmniSocials sends at most 15 automatic answers per 15 minutes and 450 a day per X account (X's own limit is 500 DMs a day, the team's DMs included). An answer over a cap waits in the queue (see Send caps and the queue).
  • Credits. X DMs run on credits: each received DM uses 1 credit and each answer 2, like a reply from the inbox. When the credits ran out before an answer, it is skipped with reason no_credits: top up, then answer that person in the Social Inbox. See What it costs.
  • Encrypted chats get no answer. X does not give apps the messages of a conversation that runs in its encrypted X Chat, so an automation never sees those messages. See Encrypted chats.

Follow first

Follow first sends the link only to people who follow your Instagram account. It works on Instagram only: Facebook and X do not tell apps who follows an account.

What the person sees:

  1. They comment the keyword. The private reply is a short first message with one button, for example "Tap the button and I'll send you the link 👇" with the button Send me the link. The public reply under the comment goes out at once, as always.
  2. They tap the button. OmniSocials asks Instagram whether they follow the account.
  3. They follow: the DM with the link (actions.dm.text) goes out. They do not follow yet: they get the not-following message with its own button ("Almost there! Follow us first, then tap the button again.", I follow now). Every later tap checks again.

Why a button first: Meta lets an app read whether someone follows only after that person messaged the account or tapped a button. A private reply alone is not enough.

A DM or story reply trigger needs no first message: the person wrote first, so the check runs at once. A follower gets the link at once; anyone else gets the not-following message with its button.

When Instagram gives no answer to the check, the link goes out anyway, marked not checked. After 10 taps that say "not yet", that person's taps get no answer.

JSON
PATCH /automations/:id { "actions": { "dm": { "text": "Here is the guide: https://example.com/guide" }, "follow_gate": { "enabled": true, "first_message": { "text": "Tap the button and I'll send you the link 👇", "button": "Send me the link" }, "not_following": { "text": "Almost there! Follow @yourbrand first, then tap the button again.", "button": "I follow now" } } } }
FieldMeaning
follow_gate.enabledtrue turns Follow first on. null or false in place of the object turns it off and keeps the texts.
follow_gate.first_messagetext (max 640 characters) and button (max 20 characters, Meta's limit for a button title). Default: "Tap the button and I'll send you the link 👇" and "Send me the link".
follow_gate.not_followingThe answer to a tap from someone who does not follow yet, with the same limits. Default: "Almost there! Follow us first, then tap the button again." and "I follow now". Naming the account reads better: "Follow @yourbrand first".

Every key is optional, and a text or button you leave out is the default. A text over 640 characters or a button over 20 answers 400 validation_error with the field in the message (follow_gate.first_message.button can hold 20 characters). enabled: true on a Facebook or X automation answers 400 follow_gate_instagram_only.

The response always shows the gate with its texts filled in, null on Facebook and X:

JSON
"follow_gate": { "enabled": true, "first_message": { "text": "Tap the button and I'll send you the link 👇", "button": "Send me the link" }, "not_following": { "text": "Almost there! Follow @yourbrand first, then tap the button again.", "button": "I follow now" } }

Good to know:

  • Waiting people. Someone who got the first message but has no link yet shows in the activity with outcome waiting; the event's follow_gate says how far they got (see Activity). stats.followed counts the people who followed after the ask, then got the link.
  • One DM per person. That rule stays. A second comment from someone who is waiting is skipped with reason already_waiting ("Already asked to follow. The link goes out after the follow"). A new keyword DM from them checks again.
  • The send cap. The first message counts as one DM against the hourly cap, as before. The follow ask and the link go out inside the 24-hour window that the tap opens.
  • Paused automations. A tap on a paused automation is skipped with reason automation_off, and nothing is sent.
  • No active plan. While your organisation has no active plan or trial, a tap gets no answer. The person keeps waiting and gets the link on a tap after the plan is back.

Meta rules

The rules are the same on Instagram and on a Facebook Page:

  • One private reply per comment, and only within 7 days of the comment. A comment older than 7 days is skipped (window_passed).
  • Meta refuses a private reply to a comment made by a Page (a Page cannot message another Page) and to a person whose settings block messages. That comment is skipped (cannot_message). To test an automation, comment from a personal profile, not as a Page.
  • A follow-up message is possible only after the person answers or taps a button (Meta's 24-hour window). Follow first uses the tap.
  • The DM goes to each person once per automation (already_sent).
  • OmniSocials sends at most 180 DMs an hour per account and platform; Meta's own limit for private replies is 750 an hour. An answer over the cap waits in the queue (see below).
  • Public replies belong to comments; a DM or story-reply trigger has none.
  • Facebook has no story replies. On a Page, dm means a keyword in a Messenger message.

Send caps and the queue

Each channel has a send cap per account: 180 answers an hour on Instagram and on a Facebook Page, and 15 per 15 minutes plus 450 a day on X. An answer over the cap is not dropped: it waits in a queue (outcome queued) and goes out as soon as there is room, within the hour. When X itself answers with its rate limit (HTTP 429), the answer goes back to the queue until X's reset time. An answer that found no room within an hour becomes skipped with reason rate_limited; answer that person by hand in the Social Inbox. An answer that waits while the automation is paused or finishes is skipped with reason automation_off, one to a person who said stop meanwhile with reason opted_out, and one whose organisation's plan or trial ended meanwhile with reason plan_inactive.

Updating, pausing, deleting

PATCH /automations/:id takes the same fields. status: "paused" pauses, "active" resumes. trigger, actions and limits are merged into the stored sections: keys you omit keep their value, so { "trigger": { "keywords": ["pdf"] } } keeps the kinds, the scope and the match, and a new dm.text keeps the public reply. public_reply.enabled: false (or variations: []) turns the public reply off; limits.max_sends: null removes that limit. follow_gate merges too: { "enabled": false } keeps the texts, new texts keep the switch, null turns it off, and a body without follow_gate keeps the stored one. Another post_id, instagram_media_id or facebook_post_id moves the automation to that post. The platform cannot change: a body that names another platform (or instagram_media_id on a Facebook automation, facebook_post_id on an Instagram one) answers 400 platform_immutable; create a new automation instead. A completed automation starts again when its limits or trigger change. DELETE /automations/:id removes it and its activity; DMs already sent stay sent.

Setting an X automation to status: "active" needs X DMs on for the workspace (409 x_dms_off).

GET /automations takes ?status=, ?post_id= and ?platform=instagram|facebook|x.

Activity

GET /automations/:id/events returns one row per comment or message the automation acted on, newest first, with counts per outcome and offset pagination:

JSON
{ "data": [{ "id": "1", "kind": "comment", "outcome": "sent", "person": { "id": "1784...", "username": "jane" }, "trigger_text": "guide please", "message": "Here is the guide: https://example.com/guide", "public_reply": "Sent you a DM!", "sent_at": "2026-10-10T21:40:12.000Z" }], "counts": { "sent": 12, "skipped": 3 }, "pagination": { "total": 15, "limit": 25, "offset": 0, "has_more": false } }

outcome is sent, skipped (with reason: already_sent, limit_reached, stopped, window_passed, rate_limited (the send cap stayed full for an hour), cannot_message, already_replied, dm_window_passed, and on X dms_closed (X refused: the person does not accept DMs from your account), no_credits (credits ran out before the answer), opted_out (the person replied STOP before, or while the answer waited), plus automation_off (the automation was paused or finished while the answer waited) and plan_inactive (your organisation had no active plan or trial, so nothing was sent; automations send only while the plan runs), with reason_label in plain words), failed (with the platform's error in reason), pending, queued (waits in the queue, see Send caps and the queue), opted_out (the person replied STOP on X) or waiting (Follow first: asked to follow, the link goes out after the follow). Follow first adds the skip reason already_waiting. queued and opted_out rows carry a reason_label too ("Waiting for room under the send limit. It goes out within the hour", "Said stop. No automatic DMs to this person from this account"). Filter with ?outcome=. The text of a DM or story reply is private: trigger_text on dm and story_reply rows is returned only to a key with the inbox:read scope; a comment is public and always returned.

With Follow first on, an event carries follow_gate (else null):

JSON
{ "id": "2", "kind": "comment", "outcome": "waiting", "person": { "id": "1784...", "username": "sam" }, "follow_gate": { "state": "waiting", "asked_at": "2026-11-03T10:02:11.000Z", "taps": 1, "followed": false, "checked": true, "after_ask": false } }

state is waiting (asked, no link yet), done (the link went out) or null (the row was skipped or failed). taps counts the button taps. followed is true when a confirmed follower got the link and null when the link went out unchecked because Instagram gave no answer. checked says whether Instagram answered. after_ask is true when the person followed after the ask, and false with followed: true when they already followed. counts gets a waiting key, and ?outcome=waiting lists the people still waiting. A person who waits counts against limits.max_sends, so "stop after 50" asks at most 50 people, and still gets the link when the limit or the end date finishes the automation, or when you switch Follow first off (then without a check). Only a paused or deleted automation leaves their tap without an answer.

On Facebook, person.id is the person's id as the Page sees it, and person.username is their name: Facebook has no @handle. kind is comment or dm. On X, person.username is the X handle and kind is always dm.

On a new post

Pass comment_dm_automation on POST /posts/create to bind automations to the post you are creating (Instagram or Facebook must be in accounts; an X automation answers DMs and is never bound to a post, so create it with POST /automations). It is the create body without post_id, scope and kinds (always this post, comment trigger), plus an optional platforms: ["instagram"], ["facebook"] or both. Each listed channel gets its own automation with the same keywords, DM, public reply and limits. Without platforms the post gets one automation: on Instagram when the post goes there, else on Facebook. actions.follow_gate works here too: with platforms: ["instagram", "facebook"] it applies to the Instagram automation, and the Facebook one sends the DM at once (no error).

The post comes back with comment_dm_automation: the first automation's fields (Instagram first), plus platforms and automations (id, platform and status of each). GET /posts/:id returns it. PATCH /posts/:id replaces the setup with a new object (a channel no longer in platforms loses its automation, and an object without follow_gate turns Follow first off) or removes every automation with null. See Creating posts.

Errors

StatusCodeMeaning
400validation_errorBad input; the message says what (for example "Write the DM", "Add at least one keyword, or choose any comment", "Facebook has no story replies", "Pass one of post_id, instagram_media_id or facebook_post_id."), also a comment or story_reply trigger on X
400post_not_instagram, post_not_facebookThe post does not go to the automation's platform
400post_requiredScope post without post_id, instagram_media_id or facebook_post_id
400platform_immutableA PATCH names another platform
400follow_gate_instagram_onlyfollow_gate.enabled: true on a Facebook or X automation: "Follow first works on Instagram only: Facebook does not tell apps who follows an account"
403insufficient_scopeThe key has no automations:read / automations:write
404post_not_found, instagram_media_not_found, facebook_post_not_found, not_foundNo such post, Instagram media, Page post or automation in this workspace
409instagram_not_connected, instagram_needs_reauthConnect or reconnect Instagram first
409facebook_not_connected, facebook_needs_reauthConnect or reconnect a Facebook Page first
409x_not_connectedConnect an X account first
409x_dms_offX DMs are off for the workspace: turn them on in the Social Inbox (or the automation editor), or save the automation with status: "paused"
409automation_existsThe post already has an automation on this platform; the response carries its automation_id

Using it from an AI assistant

The MCP server has list_automations, get_automation, create_automation, update_automation, delete_automation and get_automation_activity (each takes platform where it applies, x included), and create_post takes comment_dm_automation with platforms. Follow first is flat fields there: follow_gate (true or false), follow_gate_text, follow_gate_button, not_following_text and not_following_button. The CLI has the automations:* commands (Follow first: --follow-first on|off) and the --dm-* flags on posts:create (Follow first: --dm-follow-first).

Last modified on November 8, 2026
Social inboxOverview
On this page
  • Enabling automation access
  • Creating an automation
    • On a Facebook Page
    • On X
  • Follow first
  • Meta rules
  • Send caps and the queue
  • Updating, pausing, deleting
  • Activity
  • On a new post
  • Errors
  • Using it from an AI assistant
JSON
JSON
JSON
JSON
JSON
JSON
JSON
JSON
JSON