Webhook 模式
Webhook 模式
GPTBots Agent currently supports three message response modes: blocking, streaming, and webhook. When developers use the webhook mode to receive response messages, both AI responses and human responses will be submitted to the specified webhook URL.
| Response Mode | Supported Message Types |
|---|---|
| blocking | AI responses |
| streaming | AI responses |
| webhook | Human responses, AI responses |
Request Method
POST
Endpoint
Please configure your message receiving address on the Agent - Integration - API - webhook page.
Authentication
Refer to API Overview for authentication instructions.
Request
Request Example
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
}
}
}'
Dieser Codeblock im schwebenden Fenster
Request Headers
| Field | Type | Description |
|---|---|---|
| Authorization | Bearer or Basic ${token} | If authentication is enabled, use Authorization: Bearer OR Basic ${token} for call verification. Optional if authentication is disabled. |
| Content-Type | application/json | Data type, set to application/json. |
Request Body
| Field | Type | Description |
|---|---|---|
| conversation_id | string | Unique identifier for the conversation. |
| message_id | string | Unique identifier for a specific message within a conversation. |
| create_time | long | Timestamp when the message was generated. |
| output | JSON Array | AI Agent response content. |
| from_component_branch | string | FlowAgent branch. |
| from_component_name | string | Upstream component name in FlowAgent. |
| content | object | AI Agent response message content, currently includes text and audio message types. |
| usage | object | Usage consumption. |
| tokens | JSON Array | Total tokens consumed by the Agent in this conversation. |
| total_tokens | integer | Total tokens consumed for input + output in this conversation. |
| prompt_tokens | integer | Total tokens consumed for input in this conversation. |
| completion_tokens | integer | Total tokens consumed for output in this conversation. |
| prompt_tokens_details | object | Token consumption details for input in this conversation. |
| completion_tokens_details | object | Token consumption details for output in this conversation. |
| credits | object | Total credits consumed by the Agent in this conversation. |
| text_input_credits | double | Credits consumed for input text messages in this conversation. |
| text_output__credits | double | Credits consumed for output text messages in this conversation. |
| audio_input_credits | double | Credits consumed for input audio messages in this conversation. |
| audio_output_credits | double | Credits consumed for output audio messages in this conversation. |
Response
Response Example
{
"code": 200,
"msg": "success"
}
{
"code": 200,
"msg": "success"
}
Dieser Codeblock im schwebenden Fenster
