Webhook-Modus
Webhook-Modus
Der GPTBots-Agent unterstützt aktuell drei Modi für Nachrichtenantworten: blocking, streaming und webhook. Wenn Entwickler:innen den webhook-Modus nutzen, um Antwortnachrichten zu empfangen, werden sowohl KI-Antworten als auch Menschliche Antworten an die angegebene Webhook-URL übermittelt.
| Antwortmodus | Unterstützte Nachrichtentypen |
|---|---|
| blocking | KI-Antworten |
| streaming | KI-Antworten |
| webhook | Menschliche Antworten, KI-Antworten |
Anfragemethode
POST
Endpoint
Bitte konfigurieren Sie Ihre Empfangsadresse für Nachrichten auf der Seite Agent – Integration – API – Webhook.
Authentifizierung
Beachten Sie die Hinweise zur Authentifizierung im API-Überblick.
Anfrage
Beispielanfrage
curl -X POST 'IHRE_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": "Komponentenname",
"content": {
"text": "Hallo, kann ich Ihnen irgendwie helfen?",
"audio": [
{
"audio": "http://gptbots.ai/example.mp3",
"transcript": "Der transkribierte Inhalt der Audiodatei"
}
]
}
}
],
"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 'IHRE_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": "Komponentenname",
"content": {
"text": "Hallo, kann ich Ihnen irgendwie helfen?",
"audio": [
{
"audio": "http://gptbots.ai/example.mp3",
"transcript": "Der transkribierte Inhalt der Audiodatei"
}
]
}
}
],
"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
Anfrage-Header
| Feld | Typ | Beschreibung |
|---|---|---|
| Authorization | Bearer oder Basic ${token} | Wenn die Authentifizierung aktiviert ist, verwenden Sie Authorization: Bearer ODER Basic ${token} zur Verifizierung. Optional, falls Authentifizierung deaktiviert ist. |
| Content-Type | application/json | Datentyp, auf application/json setzen. |
Anfrage-Body
| Feld | Typ | Beschreibung |
|---|---|---|
| conversation_id | string | Eindeutige Kennung der Konversation. |
| message_id | string | Eindeutige Kennung einer bestimmten Nachricht innerhalb einer Konversation. |
| create_time | long | Zeitstempel, zu dem die Nachricht generiert wurde. |
| output | JSON-Array | Antwortinhalt des KI-Agenten. |
| from_component_branch | string | FlowAgent-Branch. |
| from_component_name | string | Name der vorgelagerten Komponente im FlowAgent. |
| content | object | Antwortnachricht des KI-Agenten; aktuell werden die Nachrichtentypen „Text“ und „Audio“ unterstützt. |
| usage | object | Verbrauchsdaten. |
| tokens | JSON-Array | Gesamtzahl der vom Agent in dieser Konversation verbrauchten Tokens. |
| total_tokens | integer | Gesamtzahl der verbrauchten Tokens für Eingabe + Ausgabe in dieser Konversation. |
| prompt_tokens | integer | Gesamtzahl der für die Eingabe verbrauchten Tokens in dieser Konversation. |
| completion_tokens | integer | Gesamtzahl der für die Ausgabe verbrauchten Tokens in dieser Konversation. |
| prompt_tokens_details | object | Details zum Tokenverbrauch für die Eingabe in dieser Konversation. |
| completion_tokens_details | object | Details zum Tokenverbrauch für die Ausgabe in dieser Konversation. |
| credits | object | Insgesamt vom Agent in dieser Konversation verbrauchte Credits. |
| text_input_credits | double | Verwendete Credits für Texteingaben in dieser Konversation. |
| text_output_credits | double | Verwendete Credits für Textausgaben in dieser Konversation. |
| audio_input_credits | double | Verwendete Credits für Audioeingaben in dieser Konversation. |
| audio_output_credits | double | Verwendete Credits für Audioausgaben in dieser Konversation. |
Antwort
Beispielantwort
{
"code": 200,
"msg": "success"
}
{
"code": 200,
"msg": "success"
}
Dieser Codeblock im schwebenden Fenster
