Webhook Mode
Last updated:2025-03-19

Webhook Mode

The current message response modes of GPTBots Agent support: blocking, streaming, and webhook. When developers use the webhook mode to receive response messages, the message content provided by the Agent or human customer service will be submitted to the specified webhook address.

Request Method

POST

Call Address

Please configure your message receiving address on the Agent - Integration - API - webhook page.

Call Verification

For details, refer to the authentication method description in the API Overview.

Request

Request Example

curl -X POST YOUR_API \ -H 'Authorization: Bearer your_apikey' \ -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 text content of the audio" } ] } } ], "usage": { "tokens": { "total_tokens": 29, //prompt + completion "prompt_tokens": 19, //prompt "prompt_tokens_details": { "audio_tokens": 0, "text_tokens":0 }, "completion_tokens": 10, //completion "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 \ 
  -H 'Authorization: Bearer your_apikey' \ 
  -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 text content of the audio"
                    }
                ]
            }
        }
    ],
    "usage": {
        "tokens": {
           "total_tokens": 29,  //prompt + completion
            "prompt_tokens": 19, //prompt
            "prompt_tokens_details": {  
                "audio_tokens": 0,
                "text_tokens":0
            },
            "completion_tokens": 10, //completion
            "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
        }
    }
}
'

        
This code block in the floating window

Request Header

Field Type Description
Authorization Bearer or Basic ${token} Use Authorization: Bearer OR Basic ${token} for call verification. Please obtain the token from the API key page.
Content-Type application/json Data type, the value is application/json.

Request Body

Field Type Description
conversation_id string The unique identifier of the dialogue.
message_id string The unique identifier of a specific message in a dialogue.
create_time long The timestamp when this reply message was generated.
output JSON Array AI Agent reply content.
from_component_branch string FlowAgent branch.
from_component_name string Upstream component name of FlowAgent.
content object Message content replied by the AI Agent, currently including text and audio message types.
usage object Usage consumption.
tokens JSON Array Total tokens consumed by the Agent in this dialogue.
total_tokens integer Total tokens consumed by input + output in this dialogue.
prompt_tokens integer Total tokens consumed by input in this dialogue.
completion_tokens integer Total tokens consumed by output in this dialogue.
prompt_tokens_details object Token consumption details for input in this dialogue.
completion_tokens_details object Token consumption details for output in this dialogue.
credits object Total credits consumed by the Agent in this dialogue.
text_input_credits double Credits consumed by input text messages in this dialogue.
text_output__credits double Credits consumed by output text messages in this dialogue.
audio_input_credits double Credits consumed by input audio messages in this dialogue.
audio_output_credits double Credits consumed by output audio messages in this dialogue.

Response

Response Example

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

        
This code block in the floating window