Channel Publishing
Primary Use Case
While this endpoint can be used generically by ChatBotKit customers for pub/sub messaging, its primary purpose is to support remote function calling in conversational AI workflows.
How Remote Function Calling Works
-
Setup: When calling the
/completeroutes with function definitions, you can specify achannelname in the result configuration. -
Function Invocation: If the AI model decides to call one of the defined functions, it returns a message item containing:
- The function name
- The function arguments
- The channel name that was specified in the
/completerequest
-
Result Publishing: The caller then executes the function locally and pushes the result back to the model by publishing to this endpoint using the channel name provided by the model.
Workflow Example
Important Notes
-
Channel ID Requirements: Channel IDs must be at least 16 characters long for security and collision avoidance.
-
Channel ID Namespace: Channel IDs cannot be reused between different ChatBotKit sessions.
-
Message Format: The
messagefield accepts a string. For structured data (like function results), serialize to JSON -
Real-time Delivery: Messages are delivered in real-time to active subscribers.If no subscriber is listening, the message is not queued or persisted.
-
Stateless: Channels do not maintain message history. Subscribers only receive messages published while they are actively connected.