Overview
Send various types of events to channels, including streaming text messages and custom events. Supports AG-UI protocol events for real-time streaming communication.Query Parameters
Force end existing streams in the channel before starting a new one
0- Do not force end1- Force end existing streams
Request Body
Required Parameters
Client message number - must be unique and not repeated. Used to identify and track the message/stream. For streaming messages, all events in the same stream should use the same client_msg_no. UUID format is recommended.
Target channel ID where the event will be sent. For person channels, this should be the target user ID. For group channels, this should be the group ID.
Channel type
1- Person channel2- Group channel
Event object
Optional Parameters
Sender user ID. If not provided or empty, defaults to the system UID. This identifies who is sending the event.
Response Fields
Operation status, returns
"ok" on successStatus Codes
| Status Code | Description |
|---|---|
| 200 | Event sent successfully |
| 400 | Bad request - invalid parameters or event data |
| 500 | Internal server error |
Streaming Message Flow
Streaming Message Process
- Start Stream: Send
___TextMessageStartevent to initiate a stream - Send Content: Send multiple
___TextMessageContentevents with message chunks - End Stream: Send
___TextMessageEndevent to close the stream
Important Notes
- The same
client_msg_nomust be used for all events in a streaming session - Only one stream can be active per channel unless
force=1is used - For person channels, the system automatically handles fake channel ID generation
- Events are automatically routed to the appropriate cluster node
Event Types
AG-UI Protocol Events
AG-UI protocol events enable real-time streaming communication for AI applications:| Event Type | Purpose | Data Format |
|---|---|---|
___TextMessageStart | Initiates a streaming text message session | Initial content or metadata |
___TextMessageContent | Sends content chunks during streaming | Text chunk content |
___TextMessageEnd | Terminates a streaming text message session | Completion marker |
___ToolCallStart | Begins a tool/function call event | Tool name or metadata |
___ToolCallArgs | Sends arguments for tool calls | JSON formatted arguments |
___ToolCallEnd | Ends a tool call event | Completion status |
___ToolCallResult | Returns results from tool execution | JSON formatted results |
Custom Events
Any event type not starting with___ is treated as a custom event, useful for:
- User status updates
- System notifications
- Business logic events
- Application-specific interactions
Use Cases
AI Chatbot
Real-time Collaboration
System Notifications
Best Practices
- Unique Identification: Use UUID format for
client_msg_noto ensure uniqueness - Stream Management: Close unused streams promptly to avoid resource waste
- Error Handling: Handle stream conflicts and send failures
- Permission Verification: Ensure sender has channel send permissions
- Data Format: Use JSON format strings for complex data
- Performance Optimization: Control streaming message send frequency reasonably
Error Handling
Common Errors
| Error | Cause | Solution |
|---|---|---|
| Event type cannot be empty | No event.type provided | Ensure valid event type is provided |
| Stream already running in channel | Trying to start new stream when one is active | Use force=1 or wait for existing stream to end |
| Stream does not exist | Trying to send content to non-existent stream | Check if stream was created correctly |
| Stream is already closed | Sending content to closed stream | Start a new stream |

