Webhook 模式
最新更新:2024-12-19

Webhook 模式

当前 GPTBots Agent 的消息响应模式支持:blocking,streamingwebhook三种方式。当开发者使用 webhook 模式 接收响应消息时, 会将Agent或人工客服所回复的消息内容提交到指定的 webhook 地址。

请求方式

POST

调用地址

请在 Agent - 集成 - 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。

请求体

字段 类型 描述
message_id string 消息唯一ID。
message_type string 消息类型,值:ANSWER,QUESTION。
text string 智能体回复的文本内容。
flow_output JSON Array Flow模式智能体的回复内容。
content string Flow模式智能体组件回复文本。
branch string Flow模式智能体分支。
from_component_name string Flow模式智能体上游组件名称。
create_time long 回复消息创建的时间戳。
conversation_id string 会话ID。

响应

响应示例

{ "code": 200, "msg": "success" }
          {
  "code": 200,
  "msg": "success"
}

        
此代码块在浮窗中显示