Solutions / Conversations

Comment to DM API, your logic.

Outstand turns an Instagram, Facebook or X comment into a direct message with one call. The comment.received webhook tells you about the comment, your code decides whether it deserves an answer, and POST /v1/conversations sends the DM. That is comment to DM automation as infrastructure: no visual flow builder to work around, no separate Meta integration per network, and the conversation stays addressable through the same API after the commenter replies.

✓ Instagram, Facebook and X · Quick replies and buttons · Billed per conversation, not per message

Where this works, and where it does not

Starting a conversation is supported on Instagram, Facebook Pages and X, so Instagram comment to DM, Facebook comment to DM and X comment to DM all run through the same endpoint. On the two Meta networks the first message is a private reply, which is the only way Meta lets a business open a thread; on X it is an ordinary direct message to the reply's author. A request against any other connected account is rejected with 400 and the message Conversations are not supported on <network>.

So there is no TikTok, LinkedIn or Threads comment-to-DM here. Threads is the interesting near miss: Threads replies do arrive on comment.received, so you can read them and act on them however you like, but there is no DM surface to answer them in, and the payload's authorId is null on Threads regardless.

Availability runs opposite ways on the two sides. On Instagram and Facebook, Direct Messages work on both Outstand's Managed Keys and your own Meta app (BYOK): with Managed Keys there is nothing to configure at the app level, and on your own Meta app you subscribe it once to the messages webhook field on its per-app callback, which Outstand verifies against your own app secret. On Instagram BYOK, also subscribe the app to messaging_postbacks for postback button taps; quick-reply selections arrive through messages. The app-level subscription must include both fields even though Outstand subscribes the connected Instagram account for you. Comment events also need Instagram's comments field or Facebook's feed field. X is the inverse: there are no managed X credentials, so X comment-to-DM runs on your own X app, with Outstand's webhook URL registered on it before you connect the account, and each request looks the reply up, which X bills to your app as a post read. Publishing to Instagram and Facebook is unaffected either way.

Before the first campaign

  • Instagram needs a Business or Creator account, Allow access to messages enabled, and the instagram_business_manage_messages and instagram_business_manage_comments scopes. Reconnect if messaging access was not granted. Passing custom scopes replaces the defaults, so retain the publishing scopes you still need.
  • Facebook Pages need pages_messaging and pages_manage_metadata. X needs your own app with its webhook registered before connection, plus tweet.read, dm.write and dm.read.
  • Use a server-side API key with conversations:send and access to the connected account's organization. Verify signed webhooks and subscribe to comment.received, message.received, message.sent and message.failed. A publishing connection alone is not proof that messaging is ready.

Posts created in the native Instagram or Facebook app work too. Your application chooses which accounts and posts belong to each campaign, matches keywords and stores its reply copy. Filter by accountId and platformPostId, not only postId: that Outstand ID is null for posts published elsewhere. In a multi-customer SaaS, map these IDs to your own customer records. The webhook's orgId identifies the Outstand organization, not an automatically isolated tenant in your application.

01 / The flow

Webhook in, DM out.

Two pieces of API surface, and everything interesting happens in the middle, where your code lives.

  • Someone commentsOn a post owned by a connected account. Posts published outside Outstand count too.
  • comment.received firesWith the comment text, its author, the post, and whether it is a top-level comment or a reply.
  • Your code decidesChoose the campaign by account and platform post ID, then match the keyword and select the reply.
  • POST /v1/conversationsThe commenter gets the DM, and Outstand stores it as the conversation's first message.
  • They replymessage.received fires. On Meta, their reply opens the 24-hour window. X has no such window.
  • It is one conversationA later comment from the same person joins their existing thread instead of starting a new one.
02 / Integration skeleton

Comment to DM, end to end.

// Integration skeleton: implement signature, queue, campaign and storage helpers.
// Verify the raw request body using your webhook signing secret.

const KEYWORD = /\blink\b/i;

app.post('/webhooks/outstand', async (req, res) => {
  if (!verifySignature(req)) return res.sendStatus(401);
  if (req.body.event !== 'comment.received') return res.sendStatus(200);

  const c = req.body.data;
  if (!['instagram', 'facebook', 'x'].includes(c.network)) return res.sendStatus(200);
  // Campaign selection is YOUR application logic, not an Outstand setting.
  const campaign = await findActiveCampaign(c.orgId, c.accountId, c.platformPostId);
  if (!campaign || c.isLive || c.parentCommentId || !KEYWORD.test(c.text ?? '')) {
    return res.sendStatus(200);
  }
  if (c.network === 'instagram' && !c.authorId) return res.sendStatus(200);

  // Atomically deduplicate and durably enqueue BEFORE acknowledging.
  // If storage fails, return a non-2xx so delivery can be retried.
  await enqueueOnce([c.orgId, c.accountId, c.commentId], { c, campaign });
  return res.sendStatus(200);
});

// Run from your durable worker, not after returning an HTTP response.
async function sendCampaignReply({ c, campaign }) {
  // Instagram needs the author id; Facebook and X take the comment alone.
  const addressing =
    c.network === 'instagram'
      ? { instagram: { comment_id: c.commentId, author_id: c.authorId } }
      : { [c.network]: { comment_id: c.commentId } };

  const response = await fetch('https://api.outstand.so/v1/conversations', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.OUTSTAND_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      social_account_id: c.accountId,
      content: campaign.replyText,
      ...addressing,
    }),
  });
  // Classify errors; do not blindly retry a send with an unknown outcome.
  if (!response.ok) return recordSendFailure(c, response);
  const { conversation, message } = await response.json();
  await saveReplyResult(c, conversation.id, message.id, message.status);
}

// 201 is the start-conversation response, not a webhook enqueue receipt.
// Store the returned IDs and status. A timeout is not proof that no DM was sent.
// X has no one-reply-per-comment guard, so reconcile before resending.

Three fields off the webhook address the DM: accountId becomes social_account_id, commentId becomes instagram.comment_id, and authorId becomes instagram.author_id. On a Facebook Page or an X account the comment id alone is enough - facebook.comment_id or x.comment_id. Full reference in Start a conversation.

The signature, campaign lookup, durable queue and storage helpers above are yours to implement. This example handles top-level comments on regular posts and skips Instagram Live comments. A webhook 2xx acknowledges your durable receipt, not delivery of a DM. Starting a conversation returns 201 with the conversation and message; inspect the returned status. Follow-up messages use POST /v1/conversations/{id}/messages, which returns 202 with a pending message. Track message.sent or message.failed, or poll the message list. Sent is not seen: message.read is a separate event. Deduplicate comment deliveries and classify failures before retrying, especially after a timeout or on X, where repeating the same comment can send another DM.

03 / Why an API

Built for the builder.

The category is full of drag-and-drop canvases. This is the layer underneath one.

Your logic, not a flow chart

The webhook hands you the comment text, its author and the post it sits on. What deserves a reply, and what that reply says, is ordinary code in your own stack - a regex, a database lookup, a model call, or an agent deciding for itself.

One shape for every network

Instagram, Facebook and X disagree about who may message whom, what identifies the recipient, and how long you have to do it. Outstand normalises the surrounding flow: the same endpoint, the same conversation and message objects, the same webhooks. Only the addressing object and the network's own limits differ.

The thread survives the reply

A private reply is the first message of a real conversation, not a fire-and-forget send. When the commenter answers, message.received fires and the thread continues through the same API, so your inbox or agent keeps full context.

Priced per conversation

A billable conversation is counted once per billing period, however many messages it carries. Answering a comment and then holding a twenty-message exchange costs exactly the same as the single reply.

04 / One-tap answers

Quick replies and buttons.

A private reply cannot be followed up until the contact answers. Make answering a single tap.

  • ✓instagram.quick_replies: up to 13 tappable options, each labelled up to 20 characters. A tap sends the label back as the contact's reply.
  • ✓instagram.buttons: up to 3 buttons, either postback (a tap is their reply) or url (opens a link and sends nothing back).
  • ✓Each quick reply or postback button carries your own id, up to 1,000 characters, returned as interaction.id on their reply and its message.received event. URL buttons carry a URL instead.
  • ✓Buttons cap content at 640 characters and cannot be combined with quick replies. Pick one or the other per message.
  • ✓A quick reply or postback tap counts as the contact's reply and opens the 24-hour window. Opening a URL button does not.
  • ✓Worth knowing before you design around them: Instagram does not show quick replies on desktop.

Instagram request examples

Use either body with POST /v1/conversations and replace the account, comment and author IDs with the webhook values. These are Instagram options, not cross-network button support. Offer a product link, a discount code or a choice of resources; keep useful text in the message for people who cannot see quick replies on desktop.

Quick reply: ask which resource they want

{
  "social_account_id": "x8Kp2",
  "content": "Want the guide? Tap Send guide or reply GUIDE.",
  "instagram": {
    "comment_id": "17865799348089039",
    "author_id": "17841400000000000",
    "quick_replies": [
      {
        "title": "Send guide",
        "id": "SEND_GUIDE"
      }
    ]
  }
}

Buttons: open the offer or reply for help

{
  "social_account_id": "x8Kp2",
  "content": "Here is the offer you asked for. Need help choosing?",
  "instagram": {
    "comment_id": "17865799348089039",
    "author_id": "17841400000000000",
    "buttons": [
      {
        "type": "url",
        "title": "View offer",
        "url": "https://shop.example.com/offer"
      },
      {
        "type": "postback",
        "title": "Help me choose",
        "id": "PRODUCT_HELP"
      }
    ]
  }
}

For follow-to-unlock, ask the commenter to reply first and inspect the sender's follow relationship on message.received. Unknown is not false, and following the account alone does not open the window. The follow check and resource release remain your application's logic, not a built-in campaign builder.

05 / FAQ

Frequently asked questions.

What is comment to DM automation?

Comment-to-DM automation answers a public comment in the commenter's direct messages. Someone comments "LINK" on a post and your application sends them the link, a discount code or a sign-up form as a DM, then keeps the thread going when they reply. On Instagram and Facebook, Meta calls the first message a private reply: a business cannot message someone out of the blue there, but it can answer a comment privately. X has no such restriction - the reply's author simply receives a direct message, subject to their own DM settings. Outstand exposes that as two pieces of API surface - the comment.received webhook and POST /v1/conversations - so the logic in between is yours.

How do I set up comment to DM on Instagram?

Connect an Instagram Business or Creator account with the instagram_business_manage_messages and instagram_business_manage_comments scopes and "Allow access to messages" enabled, subscribe a webhook endpoint to comment.received and message.received, then call POST /v1/conversations with instagram.comment_id and instagram.author_id taken straight off the webhook payload. The commenter receives your text as a DM. The full walkthrough, with a worked Node.js handler, is in the Comment-to-DM guide.

Does comment to DM work on Facebook?

Yes. Facebook comment to DM sends a private reply from the Page with facebook.comment_id, and the Page needs the pages_messaging scope, which Outstand requests by default on Managed Keys. Facebook needs only the comment id, not the author id, because the Page replies to the comment rather than addressing the person directly. Otherwise Instagram comment to DM and Facebook comment to DM are the same call against the same endpoint, and they return the same conversation and message objects.

How do I set up comment to DM on X?

X comment-to-DM runs on your own X app, because there are no managed X credentials. Register Outstand's webhook URL on that app, connect the account with the tweet.read, dm.write and dm.read scopes - dm.read is not a default, so an account connected without it will never receive the commenter's answer - subscribe a webhook endpoint to comment.received and message.received, then call POST /v1/conversations with x.comment_id taken straight off the webhook payload. The reply's author receives your text as an ordinary direct message, and each request looks the reply up, which X bills to your app as a post read. The full walkthrough is in the Comment-to-DM guide.

Is there a TikTok comment to DM automation?

Not through Outstand, and we would rather say so here than at integration time. Starting a conversation is supported on Instagram, Facebook Pages and X; a request against a TikTok, LinkedIn or Threads account is rejected with 400 and the message "Conversations are not supported on <network>", as is any other connected account on a network without conversations. Threads is a near miss worth understanding: Threads replies do arrive on the comment.received webhook, so you can read and act on them, but there is no DM surface to answer them in, and the payload's authorId is null on Threads anyway.

How is this different from a no-code DM builder?

A builder gives you a visual canvas and owns the logic. Outstand gives you a REST endpoint and owns nothing above it. If your keyword matching is a database query, your copy comes from your own CMS, your decisions run through a model, or the whole flow belongs to an agent you are building, then a drag-and-drop flow chart is the wrong shape and you end up fighting it. The trade is real in both directions: there is no dashboard here where a marketer assembles a funnel without you.

What are the limits on a private reply?

They come from the networks, not from us, and Instagram and Facebook share one set. One private reply per comment, and a second request for the same comment returns 409. Within seven days of the comment, after which the request returns 422. Text only on that first message, with no media. And the private reply does not open the 24-hour messaging window - the commenter's answer does, so POST /v1/conversations/{id}/messages returns 422 until they reply. Quick replies and buttons exist largely to make that answer one tap. X has none of those limits, which cuts both ways: there is no cap per reply, so a duplicate webhook delivery sends a second DM unless you deduplicate on the comment id yourself, and there is no window to wait for. On X a send fails with 422 only when the author's DM settings do not accept messages from the account. X also reports direct replies to your own posts only - not replies to replies, and not replies from protected accounts.

What does comment-to-DM cost?

Billing is per billable conversation, not per message. A conversation counts once in a billing period when at least one message in it was sent through the API and delivered by the platform. Pay as you go is $19 USD/month with 500 billable conversations included per billing period, then $0.025 USD per additional billable conversation. Business is $129 USD/month with 10,000 included, then $0.015 USD per additional billable conversation. Connected accounts are unlimited. X app usage is billed separately by X.

Can I tell whether a commenter follows the account?

On Instagram, the comment.received author object can carry the follow relationship and follower count, but Instagram only reveals that after the person has messaged the connected account. It is null for most first-time commenters. Treat null as unknown, never as "not a follower". A follow-to-unlock flow should first invite a reply, then inspect the sender on message.received. Following alone is not a DM reply and does not open the messaging window; your application owns the check and unlock decision.

Do my own replies trigger the webhook?

No, and that is deliberate. Comments written by the connected account itself, including replies sent through the API, do not fire comment.received. Without that suppression an auto-responder would answer itself in a loop. Comments are not stored by Outstand, so the webhook is the only record we pass on - deduplicate on commentId, since a comment can occasionally be delivered more than once.

Answer the comment, in their inbox.

$19 USD/month, with 500 billable conversations included per billing period, then $0.025 USD per additional billable conversation. Unlimited connected accounts. See the facts page for current pricing and coverage.