Skip to main content
The chat interface serves as the entry point for all user requests and agent responses. Intercept messages at key points in the lifecycle to transform user input before it reaches the agent, modify agent responses before display, or implement custom rendering behavior. The chat interface manages message routing between users and agents but does not control response generation. The agent configuration determines response generation, including prompts, instructions, and the selected large language model (LLM). LLMs are inherently non-deterministic. The system can generate slight variations in responses even when users provide similar or identical inputs. Expect differences in wording, structure, or level of detail as a normal characteristic of LLM-based systems. These variations do not affect the accuracy, reliability, or intent of the information provided. Embedded chat integrations provide additional flexibility for customization. Developers can modify how the chat experience handles messages by intercepting and adjusting requests or responses at defined integration points. As a result, variations in embedded chat can stem from integration-level processing rather than changes to the agent itself.
Intercept user input
Use the pre:send event to intercept messages before they reach the agent. Transform user input, add context, or implement custom validation. For detailed guidance, see Handling user input.
Intercept agent responses
Use the pre:receive event to intercept agent responses before the chat displays them. Modify, filter, or enhance responses.
Handle streaming responses
Use the pre:stream:delta event to filter or transform streaming content in real time.
Send messages programmatically
Use the send method to send messages to the agent programmatically. Trigger conversations or simulate user input.
Persist custom state
Use updateMessageStateUserDefined to persist custom data in message state across thread reloads.
Message lifecycle events
The chat interface emits events at key points in the message lifecycle. Observe and react to message flow:
  • pre:send
    Triggered before sending a message to the agent.
  • send
    Triggered after sending a message to the agent.
  • pre:stream:delta
    Triggered before each streaming chunk is processed.
  • pre:receive
    Triggered before receiving a complete response.
  • receive
    Triggered after receiving a complete response.