back to manuals

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

  1. Setup: When calling the /complete routes with function definitions, you can specify a channel name in the result configuration.

  2. 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 /complete request
  3. 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 message field 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.