Triggered before the chat sends a message to the agent. Use this event to inspect or modify the message content before it is dispatched to the backend.Documentation Index
Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt
Use this file to discover all available pages before exploring further.
For comprehensive guidance on handling user input, see Handling user input.
pre:send event, two properties control different aspects of the message:
-
message.message.content
Text sent to the agent for LLM processing. -
message.message.message_state.input.display_text
Text displayed in the chat UI.
message.content:
- The modified content is sent to the agent for processing.
- The UI continues to display the original user input unless you also update
display_text.
Event properties
Always
'pre:send'.The message payload to send to the agent. It contains the user’s input and metadata.
The message object containing the content.
Text content sent to the agent for LLM processing. When you modify this property in the
pre:send event handler, the agent receives the modified text, but the user continues to see their original input in the chat UI unless you also update message_state.input.display_text.State information for the message. Use this object to control what the user sees in the chat UI independently from what the agent receives.
Text displayed to the user in the chat UI. When present, this property takes priority over
message.message.content for display purposes. Set this property when you want the user to see different text than what is sent to the agent, for example, showing original input while sending translated text, or displaying a modified version of the message.Examples
The following example demonstrates how to modify message content and add metadata before sending to the agent:Considerations
Common patterns
Thepre:send event supports several common patterns for handling user input:
- Translation: Translate messages for the agent while preserving the original language in the UI.
- Input sanitization: Remove sensitive information before sending to the agent.
- Content transformation: Transform user input into standardized formats.
- Adding context: Enrich messages with metadata without cluttering the UI.
Do you need practical examples?
Learn how to apply the features available for embedded chat into your implementation with guidance and examples.

