chatwoot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChatwoot
Chatwoot
Use Chatwoot via direct calls to manage customer support across multiple channels (website, email, WhatsApp, etc.).
curlOfficial docs:https://developers.chatwoot.com/api-reference/introduction
通过直接调用来使用Chatwoot,实现跨多渠道(网站、邮件、WhatsApp等)的客户支持管理。
curl官方文档:https://developers.chatwoot.com/api-reference/introduction
When to Use
使用场景
Use this skill when you need to:
- Manage contacts - create, search, and update customer profiles
- Handle conversations - create, assign, and track support conversations
- Send messages - reply to customers or add internal notes
- List agents - get support team information
- Automate workflows - integrate with CRM, ticketing, or notification systems
当你需要以下操作时,可使用该技能:
- 管理联系人 - 创建、搜索和更新客户资料
- 处理对话 - 创建、分配和跟踪支持对话
- 发送消息 - 回复客户或添加内部备注
- 列出客服人员 - 获取支持团队信息
- 自动化工作流 - 与CRM、工单系统或通知系统集成
Prerequisites
前置条件
- Set up Chatwoot (Cloud or Self-hosted)
- Log in and go to Profile Settings to get your API access token
- Note your Account ID from the URL (e.g., )
/app/accounts/1/...
bash
export CHATWOOT_API_TOKEN="your-api-access-token"
export CHATWOOT_ACCOUNT_ID="1"
export CHATWOOT_BASE_URL="https://app.chatwoot.com" # or your self-hosted URL- 搭建Chatwoot(云端或自托管版本)
- 登录后进入个人资料设置获取API访问令牌
- 从URL中记录你的账户ID(例如:)
/app/accounts/1/...
bash
export CHATWOOT_API_TOKEN="your-api-access-token"
export CHATWOOT_ACCOUNT_ID="1"
export CHATWOOT_BASE_URL="https://app.chatwoot.com" # 或你的自托管URLAPI Types
API类型
| API Type | Auth | Use Case |
|---|---|---|
| Application API | User access_token | Agent/admin automation |
| Client API | inbox_identifier | Custom chat interfaces |
| Platform API | Platform App token | Multi-tenant management (self-hosted only) |
Important: When usingin a command that pipes to another command, wrap the command containing$VARin$VAR. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq .
| API类型 | 认证方式 | 使用场景 |
|---|---|---|
| Application API | 用户access_token | 客服/管理员自动化 |
| Client API | inbox_identifier | 自定义聊天界面 |
| Platform API | Platform App token | 多租户管理(仅自托管版本可用) |
重要提示: 当在包含管道的命令中使用时,请将包含$VAR的命令用$VAR包裹。由于Claude Code的bug,直接使用管道时环境变量会被静默清除。bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq .
How to Use
使用方法
All examples use the Application API with user access token.
所有示例均使用Application API及用户访问令牌。
1. Create a Contact
1. 创建联系人
Create a new contact in your account:
Write to :
/tmp/chatwoot_request.jsonjson
{
"inbox_id": 1,
"name": "John Doe",
"email": "john@example.com",
"phone_number": "+1234567890",
"identifier": "customer_123",
"additional_attributes": {
"company": "Acme Inc",
"plan": "premium"
}
}Then run:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'在账户中创建新联系人:
写入:
/tmp/chatwoot_request.jsonjson
{
"inbox_id": 1,
"name": "John Doe",
"email": "john@example.com",
"phone_number": "+1234567890",
"identifier": "customer_123",
"additional_attributes": {
"company": "Acme Inc",
"plan": "premium"
}
}然后运行:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'2. Search Contacts
2. 搜索联系人
Search contacts by email, phone, or name:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts/search?q=john@example.com" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.payload[] | {id, name, email}'通过邮箱、电话或姓名搜索联系人:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts/search?q=john@example.com" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.payload[] | {id, name, email}'3. Get Contact Details
3. 获取联系人详情
Get a specific contact by ID. Replace with the actual contact ID from the "Search Contacts" or "Create a Contact" response:
<contact-id>bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts/<contact-id>" -H "api_access_token: ${CHATWOOT_API_TOKEN}"'通过ID获取特定联系人的详情。将替换为“搜索联系人”或“创建联系人”响应中的实际联系人ID:
<contact-id>bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/contacts/<contact-id>" -H "api_access_token: ${CHATWOOT_API_TOKEN}"'4. Create a Conversation
4. 创建对话
Create a new conversation with a contact:
Write to :
/tmp/chatwoot_request.jsonjson
{
"source_id": "api_conversation_123",
"inbox_id": 1,
"contact_id": 123,
"status": "open",
"message": {
"content": "Hello! How can I help you today?"
}
}Then run:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'与联系人创建新对话:
写入:
/tmp/chatwoot_request.jsonjson
{
"source_id": "api_conversation_123",
"inbox_id": 1,
"contact_id": 123,
"status": "open",
"message": {
"content": "Hello! How can I help you today?"
}
}然后运行:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'5. List Conversations
5. 列出对话
Get all conversations with optional filters:
bash
undefined获取所有对话,可添加可选筛选条件:
bash
undefinedList open conversations
列出未关闭的对话
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations?status=open" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.data.payload[] | {id, status, contact: .meta.sender.name}'
---bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations?status=open" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.data.payload[] | {id, status, contact: .meta.sender.name}'
---6. Get Conversation Details
6. 获取对话详情
Get details of a specific conversation. Replace with the actual conversation ID from the "List Conversations" or "Create a Conversation" response:
<conversation-id>bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>" -H "api_access_token: ${CHATWOOT_API_TOKEN}"'获取特定对话的详情。将替换为“列出对话”或“创建对话”响应中的实际对话ID:
<conversation-id>bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>" -H "api_access_token: ${CHATWOOT_API_TOKEN}"'7. Send a Message
7. 发送消息
Send a message in a conversation. Replace with the actual conversation ID from the "List Conversations" response:
<conversation-id>Write to :
/tmp/chatwoot_request.jsonjson
{
"content": "Thank you for contacting us! Let me help you with that.",
"message_type": "outgoing",
"private": false
}Then run:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/messages" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'在对话中发送消息。将替换为“列出对话”响应中的实际对话ID:
<conversation-id>写入:
/tmp/chatwoot_request.jsonjson
{
"content": "Thank you for contacting us! Let me help you with that.",
"message_type": "outgoing",
"private": false
}然后运行:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/messages" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'8. Add Private Note
8. 添加私人备注
Add an internal note (not visible to customer). Replace with the actual conversation ID from the "List Conversations" response:
<conversation-id>Write to :
/tmp/chatwoot_request.jsonjson
{
"content": "Customer is a VIP - handle with priority",
"message_type": "outgoing",
"private": true
}Then run:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/messages" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'添加内部备注(对客户不可见)。将替换为“列出对话”响应中的实际对话ID:
<conversation-id>写入:
/tmp/chatwoot_request.jsonjson
{
"content": "Customer is a VIP - handle with priority",
"message_type": "outgoing",
"private": true
}然后运行:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/messages" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'9. Assign Conversation
9. 分配对话
Assign a conversation to an agent. Replace with the actual conversation ID and with the agent ID from the "List Agents" response:
<conversation-id><agent-id>Write to :
/tmp/chatwoot_request.jsonjson
{
"assignee_id": 1
}Then run:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/assignments" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'将对话分配给客服人员。将替换为实际对话ID,替换为“列出客服人员”响应中的客服ID:
<conversation-id><agent-id>写入:
/tmp/chatwoot_request.jsonjson
{
"assignee_id": 1
}然后运行:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/assignments" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'10. Update Conversation Status
10. 更新对话状态
Change conversation status (open, resolved, pending). Replace with the actual conversation ID from the "List Conversations" response:
<conversation-id>Write to :
/tmp/chatwoot_request.jsonjson
{
"status": "resolved"
}Then run:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/toggle_status" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'更改对话状态(open、resolved、pending)。将替换为“列出对话”响应中的实际对话ID:
<conversation-id>写入:
/tmp/chatwoot_request.jsonjson
{
"status": "resolved"
}然后运行:
bash
bash -c 'curl -s -X POST "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/<conversation-id>/toggle_status" -H "api_access_token: ${CHATWOOT_API_TOKEN}" -H "Content-Type: application/json" -d @/tmp/chatwoot_request.json'11. List Agents
11. 列出客服人员
Get all agents in the account:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/agents" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.[] | {id, name, email, role, availability_status}'获取账户中的所有客服人员:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/agents" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.[] | {id, name, email, role, availability_status}'12. List Inboxes
12. 列出收件箱
Get all inboxes (channels) in the account:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/inboxes" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.payload[] | {id, name, channel_type}'获取账户中的所有收件箱(渠道):
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/inboxes" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.payload[] | {id, name, channel_type}'13. Get Conversation Counts
13. 获取对话统计
Get counts by status for dashboard:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/meta" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.meta.all_count, .meta.mine_count'按状态获取对话数量,用于仪表盘展示:
bash
bash -c 'curl -s -X GET "${CHATWOOT_BASE_URL}/api/v1/accounts/${CHATWOOT_ACCOUNT_ID}/conversations/meta" -H "api_access_token: ${CHATWOOT_API_TOKEN}"' | jq '.meta.all_count, .meta.mine_count'Conversation Status
对话状态
| Status | Description |
|---|---|
| Active conversation |
| Closed/completed |
| Waiting for response |
| Temporarily paused |
| 状态 | 描述 |
|---|---|
| 活跃对话 |
| 已关闭/已完成 |
| 等待回复 |
| 暂时暂停 |
Message Types
消息类型
| Type | Value | Description |
|---|---|---|
| Outgoing | | Agent to customer |
| Incoming | | Customer to agent |
| Private | | Internal note (not visible to customer) |
| 类型 | 值 | 描述 |
|---|---|---|
| Outgoing | | 客服发送给客户 |
| Incoming | | 客户发送给客服 |
| 私人消息 | | 内部备注(对客户不可见) |
Response Fields
响应字段
Contact
联系人
| Field | Description |
|---|---|
| Contact ID |
| Contact name |
| Email address |
| Phone number |
| External system ID |
| Custom fields |
| 字段 | 描述 |
|---|---|
| 联系人ID |
| 联系人姓名 |
| 邮箱地址 |
| 电话号码 |
| 外部系统ID |
| 自定义字段 |
Conversation
对话
| Field | Description |
|---|---|
| Conversation ID |
| Channel/inbox ID |
| Current status |
| Assigned agent |
| Customer info |
| 字段 | 描述 |
|---|---|
| 对话ID |
| 渠道/收件箱ID |
| 当前状态 |
| 被分配的客服 |
| 客户信息 |
Message
消息
| Field | Description |
|---|---|
| Message ID |
| Message text |
| incoming/outgoing |
| Is internal note |
| sent/delivered/read/failed |
| 字段 | 描述 |
|---|---|
| 消息ID |
| 消息文本 |
| incoming/outgoing |
| 是否为内部备注 |
| sent/delivered/read/failed |
Guidelines
注意事项
- Get API token from Profile Settings: Log into Chatwoot → Profile → Access Token
- Account ID is in URL: Look at in your browser
/app/accounts/{id}/... - Inbox ID is required: Get inbox IDs first with the list inboxes endpoint
- Use source_id for conversations: Required to create conversations via API
- Private messages: Set for internal notes
private: true - Self-hosted: Change to your instance URL
CHATWOOT_BASE_URL - Webhooks recommended: Use webhooks for real-time updates instead of polling
- 从个人资料设置获取API令牌:登录Chatwoot → 个人资料 → 访问令牌
- 账户ID位于URL中:在浏览器中查看路径
/app/accounts/{id}/... - 需要收件箱ID:先通过列出收件箱的接口获取收件箱ID
- 对话需使用source_id:通过API创建对话时必须提供source_id
- 私人消息:设置来创建内部备注
private: true - 自托管版本:将改为你的实例地址
CHATWOOT_BASE_URL - 推荐使用Webhooks:使用Webhooks获取实时更新,而非轮询