# Inbox 和 Automation (/zh/growsocmed/docs/developers/inbox-and-automations)

通过 API 读取和回复 Instagram DM，并设置自动回复。

## Inbox [#inbox]

Inbox 保存您账号的 Instagram DM 对话。

- [`GET /inbox/conversations`](/zh/growsocmed/docs/api-reference/inbox/list-conversations)：最新消息在前。`status` 为 `open`（默认）、`needs_you`（AI agent 已将对话转交给团队）、`done` 或 `all`；`q` 用于搜索。
- [`GET /inbox/conversations/{id}/messages`](/zh/growsocmed/docs/api-reference/inbox/list-messages)：最早的在前；读取后对话会被标记为已读。
- [`POST /inbox/conversations/{id}/messages`](/zh/growsocmed/docs/api-reference/inbox/send-message)：发送 `text`（最多 1,000 个字符）和/或媒体库中的一个 `media_id`（最大 8 MB 的照片或最大 25 MB 的视频）。
- [`PATCH /inbox/conversations/{id}`](/zh/growsocmed/docs/api-reference/inbox/update-conversation)：`status` 为 `open` 或 `done`；`needs_you: false` 会把对话交还给 AI agent。[`POST /inbox/conversations/resolve`](/zh/growsocmed/docs/api-reference/inbox/resolve-conversations) 可对多个对话执行相同操作。
- 另外还有：[重试失败的 DM](/zh/growsocmed/docs/api-reference/inbox/retry-message)、[用爱心回应](/zh/growsocmed/docs/api-reference/inbox/react-to-message)、[显示输入中](/zh/growsocmed/docs/api-reference/inbox/send-typing)、[下载附件](/zh/growsocmed/docs/api-reference/inbox/download-attachment)、[快捷回复](/zh/growsocmed/docs/api-reference/inbox/list-saved-replies)，以及[让 agent 起草回复](/zh/growsocmed/docs/api-reference/inbox/draft-message-reply)。

Instagram 只允许商家在对方最后一条消息后的 24 小时内回复。被 Instagram 拒绝的消息会保存为失败状态，以便您重试。

## Automation [#automation]

Automation 会在一个账号上回复它开启之后收到的内容。使用 [`POST /automations`](/zh/growsocmed/docs/api-reference/automations/create-automation) 创建：

```json
{
  "account_id": "6b1e…",
  "name": "Price list by DM",
  "kind": "comment_to_dm",
  "trigger": { "posts": "all", "match": "contains", "keywords": ["price", "harga"] },
  "actions": {
    "dmText": "Here is our price list.",
    "buttons": [{ "title": "Price list", "url": "https://example.com/prices" }],
    "trackClicks": true,
    "replyVariants": ["Sent you a DM!"]
  },
  "delay": "natural",
  "once_per_person": true,
  "enabled": true
}
```

| `kind` | 作用 | 平台 |
| --- | --- | --- |
| `comment_to_dm` | 向发表评论的人发送 DM。 | Instagram |
| `dm_keyword` | 回复包含关键词的 DM。 | Instagram |
| `default_reply` | 回复其他 Automation 未回复的 DM，每人每个 `frequency` 最多一次。 | Instagram |
| `story_reply` | 回复对您 Stories 的回复。 | Instagram |
| `story_mention` | 回复在其 Stories 中提及您的人。 | Instagram |
| `ice_breaker` | 有人打开聊天时显示的问题，每个问题都有对应的答案（1–4 个）。 | Instagram |
| `comment_reply` | 公开回复评论（Threads、Facebook 等至少需要 3 个 `replyVariants`）。 | Instagram、Facebook Page、Threads、YouTube、TikTok、Telegram |
| `comment_hide` | 隐藏包含所列词语的评论。 | Instagram、Facebook Page、Threads、YouTube、TikTok、Telegram |
| `comment_like` | 点赞评论。 | Facebook Page、TikTok |

TikTok 的 Automation 需要该账号已连接 TikTok Business。

`trigger`：`posts`（`all`、表示下一个 post 的 `next`，或平台 post id 列表）、`match`（`any`、`contains`、`exact`）、`keywords`（最多 200 个）、`includeReplies`、`frequency`（`hour`、`day`、`week`）。`actions`：`dmText`（最多 1,000 个字符，带按钮时为 640 个）、`replyVariants`（最多 5 个）、`agentId`（改由 AI agent 回复）、`buttons`（最多 3 个链接）、`trackClicks`、`requireFollow`（对方关注后才发送 DM）、`heart`、`markAutomated`、`iceBreakers`。`delay` 为 `fast`、`natural`（默认）或 `relaxed`。除非您发送 `enabled: true`，否则 Automation 创建后处于关闭状态。

[`GET /automations`](/zh/growsocmed/docs/api-reference/automations/list-automations) 返回每个 Automation 及其计数（已发送、已跳过、失败、点击、关注、点击率），[`GET /automations/{id}/runs`](/zh/growsocmed/docs/api-reference/automations/list-automation-runs) 返回最近的运行记录及其结果和原因。[`automation.run`](/zh/growsocmed/docs/developers/webhooks) webhook 会在每次运行结束时进行报告。