logo
开发者文档
搜索
Webhook 模式

Webhook 模式

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

响应模式 该模式所支持的消息回复类型
blocking Agent回复消息
streaming Agent回复消息
webhook 人工客服回复消息、Agent回复消息

请求方式

POST

调用地址

请在 Agent - 集成 - API - webhook 页面配置你的消息接收地址

调用验证

详情参见 API 概述的鉴权方式说明。

请求

请求示例

curl -X POST 'YOUR_API_URL' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "create_time": 1679587005, "conversation_id": "657303a8a764d47094874bbe", "message_id": "65a4ccfC7ce58e728d5897e0", "output": [ { "from_component_branch": "1", "from_component_name": "Component Name", "content": { "text": "Hi, is there anything I can help you?", "audio": [ { "audio": "http://gptbots.ai/example.mp3", "transcript": "The transcribed content of the audio" } ] } } ], "usage": { "tokens": { "total_tokens": 29, "prompt_tokens": 19, "prompt_tokens_details": { "audio_tokens": 0, "text_tokens":0 }, "completion_tokens": 10, "completion_tokens_details": { "reasoning_tokens": 0, "audio_tokens": 0, "text_tokens": 0 } }, "credits": { "total_credits":0.0, //prompt + completion "text_input_credits": 0.0, "text_output_credits": 0.0, "audio_input_credits": 0.0, "audio_output_credits": 0.0 } } }'
                      
                      curl -X POST 'YOUR_API_URL' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "create_time": 1679587005,
    "conversation_id": "657303a8a764d47094874bbe",
    "message_id": "65a4ccfC7ce58e728d5897e0",
    "output": [
        {
            "from_component_branch": "1",
            "from_component_name": "Component Name",
            "content": {
                "text": "Hi, is there anything I can help you?",
                "audio": [
                    {
                        "audio": "http://gptbots.ai/example.mp3",
                        "transcript": "The transcribed content of the audio"
                    }
                ]
            }
        }
    ],
    "usage": {
        "tokens": {
           "total_tokens": 29,
            "prompt_tokens": 19,
            "prompt_tokens_details": 
                {  
                    "audio_tokens": 0,
                    "text_tokens":0
                },
            "completion_tokens": 10,
            "completion_tokens_details": 
                {
                    "reasoning_tokens": 0,
                    "audio_tokens": 0,
                    "text_tokens": 0
                }
        },
        "credits": {
            "total_credits":0.0,  //prompt + completion
            "text_input_credits": 0.0,
            "text_output_credits": 0.0,
            "audio_input_credits": 0.0,
            "audio_output_credits": 0.0
        }
    }
}'

                    
此代码块在浮窗中显示

请求头

字段 类型 描述
Authorization Bearer or Basic ${token} 若开发者启用鉴权,使用 Authorization: Bearer OR Basic ${token}进行调用验证,否则可不填写。
Content-Type application/json 数据类型,取值为 application/json。

请求参数

字段 类型 描述
conversation_id string 对话的唯一标识符
message_id string 一条对话中,某条消息的唯一标识符。
create_time long 回复的这条消息产生的时间戳。
output JSON Array AI Agent 回复内容。
from_component_branch string FlowAgent 分支。
from_component_name string FlowAgent 上游组件名称。
content object AI Agent回复的消息内容,当前包含了textaudio 2 个类型的消息。
usage object 使用消耗。
tokens JSON Array 本次对话该 Agent 所消耗的总 tokens。
total_tokens integer 本次对话 input + output 所消耗的总 tokens。
prompt_tokens integer 本次对话 input 所消耗的总 tokens。
completion_tokens integer 本次对话 output 所消耗的总 tokens。
prompt_tokens_details object 本次对话 input Token 消耗明细。
completion_tokens_details object 本次对话 output Token 消耗明细。
credits object 本次对话该 Agent 所消耗的总积分。。
text_input_credits double 本次对话 input text message 所消耗的积分。
text_output__credits double 本次对话 output text message 所消耗的积分。
audio_input_credits double 本次对话 input audio message 所消耗的积分。
audio_output_credits double 本次对话 input audio message 所消耗的积分。

响应

响应示例

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

                    
此代码块在浮窗中显示