Skip to main content
POST

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
string
default:"0"
Force end existing streams in the channel before starting a new one
  • 0 - Do not force end
  • 1 - Force end existing streams

Request Body

Required Parameters

client_msg_no
string
required
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.
channel_id
string
required
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
integer
required
Channel type
  • 1 - Person channel
  • 2 - Group channel
event
object
required
Event object

Optional Parameters

from_uid
string
Sender user ID. If not provided or empty, defaults to the system UID. This identifies who is sending the event.

Response Fields

status
string
required
Operation status, returns "ok" on success

Status Codes

Streaming Message Flow

Streaming Message Process

  1. Start Stream: Send ___TextMessageStart event to initiate a stream
  2. Send Content: Send multiple ___TextMessageContent events with message chunks
  3. End Stream: Send ___TextMessageEnd event to close the stream

Important Notes

  • The same client_msg_no must be used for all events in a streaming session
  • Only one stream can be active per channel unless force=1 is 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:

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

  1. Unique Identification: Use UUID format for client_msg_no to ensure uniqueness
  2. Stream Management: Close unused streams promptly to avoid resource waste
  3. Error Handling: Handle stream conflicts and send failures
  4. Permission Verification: Ensure sender has channel send permissions
  5. Data Format: Use JSON format strings for complex data
  6. Performance Optimization: Control streaming message send frequency reasonably

Error Handling

Common Errors

Retry Mechanism

For temporary errors, implement exponential backoff retry mechanism: