AI conversation callback

Tencent Real-Time Communication (TRTC) AI conversation offers a rich set of status callback features. These status callbacks are sent through TRTC's custom messages, enabling easy implementation of various switches between states such as "listening", "thinking", and "speaking" on the client.

Characteristics

1. Real-time: Status changes can be transmitted to all participants in real time.
2. Flexible: Custom message formats are used, making it easy to integrate and extend.
3. Multi-state support: Multiple states such as listening, thinking, speaking, and interrupted are included.

Message Format

Status callback messages are in the format of JSON. The specific fields are as follows:
Field
Type
Description
type
Number
Message type. 10001 indicates bot status.
sender
String
The userID of the sender, which is the bot's ID.
receiver
Array
The list of receiver userIDs. This message is actually broadcast within a room.
payload
Object
Message payload, containing detailed status information.
The payload object contains the following fields:
Field
Type
Description
roundid
String
Unique ID for a round of conversation.
timestamp
Number
Timestamp, indicating the specific time of status change.
state
Number
Current status code of the robot.
Status code description:
Status Code
Description
1
Listening
2
Thinking
3
Speaking
4
Interrupted

Sample Message

{ "type": 10001, "sender": "ai_assistant_001", "receiver": [], "payload": { "roundid": "conversation_789012", "timestamp": 1629384755, "state": 2 } }

Application Scenario

1. UI feedback: Corresponding interface elements are displayed based on different states, such as the animation for "listening".
2. Interaction control: When the AI is thinking or speaking, certain user inputs can be disabled to avoid interruptions.
3. Debugging and analysis: State information is used for conversation analysis to optimize user experiences.