# Comment to DM

Someone comments a keyword on a post; the automation sends them a direct message, replies under their comment, or both. Where the platform has a private reply the DM is that private reply to the comment, and it opens a chat in the inbox; `list_channels` says which channels have one (the "Reply to a commenter privately" row). On every other channel where a comment triggers an automation, the public reply is all it takes.

## Set one up

| Step | Call | What happens |
|---|---|---|
| Pick a ready-made one | `get_automation_catalog` with `include=templates` | Each template names its goal, its trigger and its channels. |
| Read what it needs | `get_automation_template` | Its `inputs`, required first. Ask the person only for what is missing. |
| Pick the post | `list_posts` with `filter=source:eq:external` and `connectionId` | Leave it out to answer comments on every post of the account. |
| Install it | `install_automation_template` | Created switched off; it reaches no one yet. |
| Check it | `validate_automation` | What it does, who it reaches, and anything that `blocksPublish`. |
| Turn it on | `activate_automation` | Only on the person's word. |

To build your own, read the trigger and the two reply steps with `list_automation_blocks` (`filter=key:in:<keys>&include=input,definition`) and fill their settings from it: the comment trigger (keywords, posts, `dmDelaySeconds`), the private reply (`text`, `variations`, buttons) and the public reply (`text`, `variations`, `publicReplyPolicy`, `secondsAfterTrigger`).

## Wording

- `variations`: other wordings; one is picked per comment, so the same words are not posted again and again.
- The DM takes any variable. The public reply takes only the commenter's names (`{{first_name}}`, `{{name}}`, `{{full_name}}`, `{{username}}`): everyone on the post reads it, so publish refuses any other variable.
- `publicReplyPolicy`: `after_dm` (the default) posts the public reply only once the DM went; `always` posts it whatever happened to the DM.
- `secondsAfterTrigger` delays the public reply; it never goes before the DM.

## How it behaves

- It answers only comments made after it was switched on, a late or caught-up comment included.
- Replies go out in order at each account's pace. A reply your key or AI app sends with `reply_to_inbox_comment` past that pace answers `202` with `status: queued`: it is accepted and goes in order. Read `get_inbox_comment`: `replyStatus` reads `queued` (a private reply: `privateReplyQueued`) until it goes. Never send it again.
- When the platform refuses an account's messages, its DMs and replies wait rather than fail. `get_connection` with `include=healthCheck` shows `holds`: what waits (`scope`), why, and `until`, when they go out on their own.

## If it fails

| Answer | Cause | Fix |
|---|---|---|
| `202` `status: queued` | The account's pace or the brand's budget is used for now | Nothing: it goes in order. Read `get_inbox_comment`; never resend. |
| `validate_automation` names a variable in the public reply | A variable other than the commenter's names | Use only the names above. |
| `400 platform_not_supported` on a DM | The channel has no private reply to a comment | Use the public reply only. |
| `429` with `Retry-After` | Too many requests right now | Wait `Retry-After` (on MCP, `details.retryAfterSeconds`), then retry with the same `idempotencyKey`. |
| Nothing goes, `healthCheck.holds` lists `messages` | The platform refused the account's messages | They go out at `until`. See [Rate limits](rate-limits.md). |
