# Inbox และ automation (/th/growsocmed/docs/developers/inbox-and-automations)

อ่านและตอบ DM ของ Instagram และตั้งค่าการตอบอัตโนมัติผ่าน API

## Inbox [#inbox]

Inbox เก็บการสนทนา DM ของ Instagram จากบัญชีของคุณ

- [`GET /inbox/conversations`](/th/growsocmed/docs/api-reference/inbox/list-conversations): ข้อความล่าสุดก่อน `status` เป็น `open` (ค่าเริ่มต้น), `needs_you` (AI agent ส่งต่อการสนทนาให้ทีม), `done` หรือ `all` และ `q` ใช้ค้นหา
- [`GET /inbox/conversations/{id}/messages`](/th/growsocmed/docs/api-reference/inbox/list-messages): เก่าสุดก่อน การอ่านจะทำเครื่องหมายว่าการสนทนาอ่านแล้ว
- [`POST /inbox/conversations/{id}/messages`](/th/growsocmed/docs/api-reference/inbox/send-message): ส่ง `text` (ไม่เกิน 1,000 ตัวอักษร) และ/หรือ `media_id` หนึ่งรายการจากคลังสื่อ (รูปภาพไม่เกิน 8 MB หรือวิดีโอไม่เกิน 25 MB)
- [`PATCH /inbox/conversations/{id}`](/th/growsocmed/docs/api-reference/inbox/update-conversation): `status` เป็น `open` หรือ `done` และ `needs_you: false` จะส่งการสนทนากลับให้ AI agent [`POST /inbox/conversations/resolve`](/th/growsocmed/docs/api-reference/inbox/resolve-conversations) ทำแบบเดียวกันกับหลายรายการ
- นอกจากนี้: [ส่ง DM ที่ล้มเหลวอีกครั้ง](/th/growsocmed/docs/api-reference/inbox/retry-message), [รีแอ็กด้วยหัวใจ](/th/growsocmed/docs/api-reference/inbox/react-to-message), [แสดงสถานะกำลังพิมพ์](/th/growsocmed/docs/api-reference/inbox/send-typing), [ดาวน์โหลดไฟล์แนบ](/th/growsocmed/docs/api-reference/inbox/download-attachment), [คำตอบที่บันทึกไว้](/th/growsocmed/docs/api-reference/inbox/list-saved-replies) และ[ให้ agent ร่างคำตอบ](/th/growsocmed/docs/api-reference/inbox/draft-message-reply)

Instagram อนุญาตให้ธุรกิจตอบได้ภายใน 24 ชั่วโมงหลังข้อความล่าสุดของบุคคลนั้นเท่านั้น ข้อความที่ Instagram ปฏิเสธจะถูกเก็บไว้เป็นข้อความที่ล้มเหลว เพื่อให้คุณส่งอีกครั้งได้

## Automation [#automation]

automation จะตอบสิ่งที่เข้ามาหลังจากเปิดใช้งาน บนบัญชีเดียว สร้างได้ด้วย [`POST /automations`](/th/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` | ตอบ DM ที่ไม่มี automation อื่นตอบ ไม่เกินหนึ่งครั้งต่อคนต่อ `frequency` | Instagram |
| `story_reply` | ตอบการตอบกลับ Stories ของคุณ | Instagram |
| `story_mention` | ตอบคนที่เมนชันคุณใน Stories ของเขา | Instagram |
| `ice_breaker` | คำถามที่แสดงเมื่อมีคนเปิดแชต แต่ละข้อมีคำตอบ (1–4) | Instagram |
| `comment_reply` | ตอบกลับคอมเมนต์แบบสาธารณะ (Threads, Facebook และแพลตฟอร์มอื่นต้องมี `replyVariants` อย่างน้อย 3 รายการ) | Instagram, Facebook Page, Threads, YouTube, TikTok, Telegram |
| `comment_hide` | ซ่อนคอมเมนต์ที่มีคำที่ระบุ | Instagram, Facebook Page, Threads, YouTube, TikTok, Telegram |
| `comment_like` | กดถูกใจคอมเมนต์ | Facebook Page, TikTok |

automation ของ TikTok ต้องเชื่อมต่อ TikTok Business กับบัญชีก่อน

`trigger`: `posts` (`all`, `next` สำหรับ post ถัดไป หรือรายการ id ของ post บนแพลตฟอร์ม), `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` automation จะถูกสร้างในสถานะปิด เว้นแต่คุณส่ง `enabled: true`

[`GET /automations`](/th/growsocmed/docs/api-reference/automations/list-automations) ส่งกลับแต่ละ automation พร้อมตัวเลข (ส่งแล้ว ข้าม ล้มเหลว คลิก การติดตาม อัตราการคลิก) และ [`GET /automations/{id}/runs`](/th/growsocmed/docs/api-reference/automations/list-automation-runs) ส่งกลับการทำงานล่าสุดพร้อมผลลัพธ์และเหตุผล webhook [`automation.run`](/th/growsocmed/docs/developers/webhooks) จะรายงานการทำงานแต่ละครั้งเมื่อจบ