AI 대화 서버 콜백 2.0
This document describes the event notifications generated by the AI Conversation 2.0 cloud API. These notifications are sent to your server via HTTP requests. During each task, TRTC pushes real-time event webhook callbacks to your configured callback URL, delivering key events from the AI conversation process directly to your backend. This enables your system to receive conversation content, state transitions, and task lifecycle updates without polling API endpoints.
Note:
AI Conversation 2.0 introduces a new event group set that is completely independent from 1.0 callback events. The two sets do not interact or interfere with each other.
Feature Overview
Capability | Corresponding Event | Business Value |
Conversation Content Archiving | ASR Recognition Result, LLM Reply Result | Archive user and AI utterances in real time for quality review, compliance audit, and further analysis. |
State Synchronization | AI State Transition | Receive real-time updates of chatbot conversation states (Listening/Thinking/Speaking, etc.) for status display in your application. |
Task Monitoring & Alerts | Task Started, Task Ended | Get immediate notifications for task start results and end reasons ( LeaveCode), supporting timely alerts and troubleshooting. |
Visual Understanding Archiving | Screenshot Upload Result | Receive notifications when screenshots are uploaded to cloud storage, enabling archiving of visual materials. |
Configuration Information
Set your backend callback URL and SecretKey in the TRTC Real-Time Audio/Video console, or contact Tencent Cloud technical support for assistance. Once configured, you will begin receiving event webhook notifications. For detailed setup instructions, see Callback Configuration.
Note:
Prepare the following information before configuring:
Required: The HTTP/HTTPS server address that will receive webhook notifications. This address must be publicly accessible and only supports POST requests.
Required: The SecretKey for
Sign signature verification. Keep this key secure and confidential. It is intended for server-side signature verification only and must not be exposed to clients or included in frontend code.Configuration Item | Requirement |
Callback URL | Public HTTP(S) address; POST requests only. |
SecretKey | Used for Sign signature verification; keep confidential. |
Timeout & Retry
Webhook events may be delivered multiple times due to network retransmissions. Your backend should deduplicate events using
TaskId, event type, and timestamp (EventMsTs). After processing a callback, immediately respond with HTTP 200. For operations that may take longer (such as archiving or analysis), handle them asynchronously to prevent blocking and repeated delivery.Event Webhook Message Format
Event webhook messages are sent to your server via HTTP POST requests:
Request: The HTTP request header includes signature and other metadata; the body is JSON-formatted.
Response: Respond with HTTP status code 200. The server ignores the response body, but for compatibility, it is recommended to reply with JSON:
{"code":0}.Payload Example: All webhook events share the same message structure. Each event is distinguished by
EventType, and event-specific content is contained in EventInfo.Payload. Below is the general structure. The JSON in each event section provides a complete example with the relevant Payload.Note:
Your HTTP response (header + body) must not exceed 2000 bytes.Fields in the POST request JSON will not be removed, but new fields may be added. Ensure your integration can accommodate additional fields.
{"EventGroupId": 15,"EventType": 1501,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": { }}}
Parameter Description
Webhook Message Parameters
The event webhook request header includes the following fields:
Field Name | Description |
Content-Type | application/json |
Sign | Signature value |
SdkAppId | SdkAppId assigned when creating the application |
The event webhook request body includes the following fields:
Field Name | Type | Description |
EventGroupId | Integer | Event group ID. For AI Conversation 2.0, always 15. |
EventType | Integer | Event notification type. |
CallbackTs | Integer | Unix timestamp (ms) when the webhook server sent the callback. |
EventInfo.EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
EventInfo.TaskId | String | AI Task ID. |
EventInfo.RoomId | String | TRTC Room ID. |
EventInfo.RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
EventInfo.Payload | Object | Event content (varies by event type; see event details below) |
Event Group ID
Field Name | Value | Description |
EVENT_GROUP_CLOUD_CONVERSATION | 15 | AI Conversation 2.0 event group |
Event Types
Field Name | Value | Description | Trigger Timing | Key Payload Fields |
EVENT_TYPE_CONVERSATION_SERVICE_START | 1501 | Task Started | Triggered when AI service startup completes (success or failure) | Status, ConversationMode |
EVENT_TYPE_CONVERSATION_SERVICE_STOP | 1502 | Task Ended | Triggered when task exits (manual end, kicked, exception, etc.) | LeaveCode |
EVENT_TYPE_CONVERSATION_ASR_MSG | 1503 | ASR Recognition Result | Triggered after user utterance is recognized (final state) | UserId, Text, RoundId, Start/End Time |
EVENT_TYPE_CONVERSATION_LLM_MSG | 1504 | LLM Reply Result | Triggered after AI generates a single-turn reply (final state) | Text, RoundId |
EVENT_TYPE_CONVERSATION_AI_STATUS | 1505 | AI State Transition | Triggered when chatbot conversation state changes | State.Code, State.Desc, Timestamp |
EVENT_TYPE_CONVERSATION_VISION_FRAME_UPLOADED | 1506 | Screenshot Upload Result | Triggered when screenshots are periodically uploaded to cloud storage | Count, Frames[] |
Stable State Callback Note:
ASR Recognition Result and LLM Reply Result events are sent only once, delivering the entire text in the final state. Intermediate streaming fragments are not pushed.
1501: Task Started
Sent after the AI service startup completes (Bot joins room, connection ready).
Field Name | Type | Description |
EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
TaskId | String | AI Task ID. |
RoomId | String | TRTC Room ID. |
RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
Payload.Status | Integer | Startup result: 0: Task started successfully; 1: Task startup failed. |
Payload.ConversationMode | String | Conversation mode: Cascade; S2S. |
{"EventGroupId": 15,"EventType": 1501,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": {"Status": 0,"ConversationMode": "Cascade"}}}
1502: Task Ended
Sent when the task exits. The
LeaveCode field indicates the reason.Field Name | Type | Description |
EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
TaskId | String | AI Task ID. |
RoomId | String | TRTC Room ID. |
RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
Payload.LeaveCode | Integer | 0: Normal exit (backend called Delete Task API); 1: Backend manually kicked Bot; 2: Backend dissolved room; 3: TRTC server kicked Bot; 4: TRTC server dissolved room; 98: Internal error, retry recommended; 99: Only Bot in room; timeout exit. |
{"EventGroupId": 15,"EventType": 1502,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": {"LeaveCode": 0}}}
1503: ASR Recognition Result
Sent after a user's utterance is recognized (final state). The
Text field contains the complete recognized text.Field Name | Type | Description |
EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
TaskId | String | AI Task ID. |
RoomId | String | TRTC Room ID. |
RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
Payload.UserId | String | ID of the speaking user. |
Payload.Text | String | Complete recognized text (final state). |
Payload.StartTimeMs | Integer | Utterance start time (ms). |
Payload.EndTimeMs | Integer | Utterance end time (ms). |
Payload.StartUtcMs | Integer | Utterance start UTC time (ms). |
Payload.EndUtcMs | Integer | Utterance end UTC time (ms). |
Payload.RoundId | String | Round ID, links ASR and LLM results for the same turn. |
{"EventGroupId": 15,"EventType": 1503,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": {"UserId": "user123","Text": "Why can't I click this button?","StartTimeMs": 1751196058500,"EndTimeMs": 1751196060100,"StartUtcMs": 1751196058500,"EndUtcMs": 1751196060100,"RoundId": "2b7d223d-35b8-4d29-bd1a-69ec8cb89f0b-0"}}}
1504: LLM Reply Result
Sent after the AI generates a single-turn reply (final state). The
Text field contains the complete reply.Field Name | Type | Description |
EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
TaskId | String | AI Task ID. |
RoomId | String | TRTC Room ID. |
RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
Payload.Text | String | Complete LLM reply (final state). |
Payload.RoundId | String | Round ID, matches ASR Recognition Result event for the same turn. |
{"EventGroupId": 15,"EventType": 1504,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": {"Text": "This button is disabled (greyed out). You need to check the \"Agree to Terms\" box above to activate it.","RoundId": "554772d4-5f23-4b5a-8361-764d0fc7bb0f-0"}}}
1505: AI State Transition
Each time the chatbot's conversation state changes, a webhook is triggered. Status codes align with those defined in the client SDK.
Field Name | Type | Description |
EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
TaskId | String | AI Task ID. |
RoomId | String | TRTC Room ID. |
RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
Payload.State.Code | Integer | Chatbot status code: 0: AI idle; 1: AI listening (ASR recognition); 2: AI thinking (LLM inference); 3: AI speaking (TTS playback); 4: AI interrupted (turn ended early); 5: AI finished speaking (turn ended normally). |
Payload.State.Desc | String | Status description. |
Payload.Timestamp | Integer | State transition timestamp (ms). |
{"EventGroupId": 15,"EventType": 1505,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": {"State": {"Code": 5,"Desc": "AI Speaking Finished"},"Timestamp": 1790820920603}}}
1506: Screenshot Upload Result
When visual understanding is enabled and cloud storage archiving is configured (
StorageType=1 + CloudStorage), screenshots are asynchronously uploaded to cloud storage. Upload results are pushed periodically.Field Name | Type | Description |
EventMsTs | Integer | Unix timestamp (ms) when the event occurred. |
TaskId | String | AI Task ID. |
RoomId | String | TRTC Room ID. |
RoomIdType | Integer | 0: Numeric room ID; 1: String room ID. |
Payload.PeriodStartMs | Integer | Start time (ms) for this batch of screenshots. |
Payload.PeriodEndMs | Integer | End time (ms) for this batch of screenshots. |
Payload.Count | Integer | Number of screenshots uploaded in this batch. |
Payload.Frames | Array of Object | List of screenshots. Each item is defined below. |
Each element of
Payload.Frames includes:Field Name | Type | Description |
FrameId | String | Screenshot frame ID. |
CaptureMs | Integer | Screenshot capture timestamp (ms). |
Reason | String | Trigger reason (e.g., scene_change for scene changes). |
ObjectKey | String | Cloud storage object path: vision/{SdkAppId}/{date}/{TaskId}/{captureTs}_{reason}_{frameId}.jpg |
SizeBytes | Integer | Image size (bytes). |
{"EventGroupId": 15,"EventType": 1506,"CallbackTs": 1751196050100,"EventInfo": {"EventMsTs": 1751196050080,"TaskId": "task-88a1b2c3","RoomId": "room-user123","RoomIdType": 1,"Payload": {"PeriodStartMs": 1751196060000,"PeriodEndMs": 1751196061000,"Count": 2,"Frames": [{"FrameId": "F-8a3f2c1e-0007","CaptureMs": 1751196060120,"Reason": "scene_change","ObjectKey": "vision/1400000000/20260812/task-88a1b2c3/1751196060120_scene-change_F-8a3f2c1e-0007.jpg","SizeBytes": 52310}]}}}
Signature Calculation
The signature is included in the request header
Sign. After your webhook receiver processes the callback message, calculate the signature in the same manner; if the result matches, the callback is confirmed as originating from Tencent Cloud RTC and not forged. For signature calculation and sample code in Java, Python, PHP, or Golang, see Signature Verification Example.Note:
When calculating the signature, use the original payload received in the callback request. Do not modify the body or remove escape characters (such as
\n, \t, etc.).Notes
1. Signature verification is required: Webhook endpoints that do not verify the
Sign header are vulnerable to forged requests.2. Stable state callbacks: ASR Recognition Result and LLM Reply Result are only sent once, containing the complete text (final state). Streaming fragments are not delivered. Use the client subtitle channel for streaming subtitles.
3. Idempotent handling: Webhook events may be delivered multiple times. Deduplicate using
TaskId, event type, and timestamp (EventMsTs/Timestamp).4. Timely response: After receiving a webhook, immediately return HTTP 200. For long-running processes (such as archiving or analysis), handle asynchronously to prevent blocking and repeated delivery.
5. SecretKey confidentiality: The SecretKey is for server-side signature verification only. Do not expose it to clients or include it in frontend code.
6. Screenshot callback prerequisite: Screenshot upload result events are triggered only when cloud storage archiving is enabled. If not configured, screenshots are retained in memory and not persisted.
