Webhook 接收消息
最新更新:2024-12-19
Webhook 接收消息
当使用 webhook 模式请求发送消息 API 时,将Bot或人工客服响应的消息内容提交到指定的 webhook 地址。
请求方式
POST
调用地址
请在 Bot - 集成 - API - webhook 页面配置你的消息接受地址
调用验证
详情参见 API 概述的鉴权方式说明。
请求
请求示例
curl -X POST YOUR_API \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"message_id": "65a4ccfC7ce58e728d5897e0",
"message_type": "ANSWER",
"text": "Hi, is there anything I can help you?",
"flow_output": [
{
"content": "你好",
"branch": "1",
"from_component_name": "User Input"
}
],
"create_time": 1679587005,
"conversation_id": "657303a8a764d47094874bbe"
}
'
curl -X POST YOUR_API \
-H 'Authorization: Bearer your_apikey' \
-H 'Content-Type: application/json' \
-d '{
"message_id": "65a4ccfC7ce58e728d5897e0",
"message_type": "ANSWER",
"text": "Hi, is there anything I can help you?",
"flow_output": [
{
"content": "你好",
"branch": "1",
"from_component_name": "User Input"
}
],
"create_time": 1679587005,
"conversation_id": "657303a8a764d47094874bbe"
}
'
此代碼塊在浮窗中顯示
请求头
字段 | 类型 | 描述 |
---|---|---|
Authorization | Bearer or Basic ${token} | 使用 Authorization: Bearer OR Basic ${token}进行调用验证,请在 API 密钥页面获取密钥作为 token。 |
Content-Type | application/json | 数据类型,取值为 application/json。 |
请求体
| 字段 | 类型 | 必填 | 描述 |
Field | Type | Description |
---|---|---|
message_id | string | Unique message ID. |
message_type | string | Message type, value: ANSWER, QUESTION. |
text | string Reply text. | |
flow_output | JSON Array | flow bot reply content. |
content | string | flow bot component reply text. |
branch | string | flow bot branch. |
from_component_name | string | flow bot upstream component name. |
create_time | long | Timestamp when reply message was created. |
conversation_id | string | Conversation ID. |
响应
响应示例
{
"code": 200,
"msg": "success"
}
{
"code": 200,
"msg": "success"
}
此代碼塊在浮窗中顯示