Skip to main content
The Message class is designed to send, stream, update or remove messages.

Parameters

str
The content of the message.
str
The author of the message, defaults to the chatbot name defined in your config file.
Element[]
Elements to attach to the message.
Action[]
Actions to attach to the message.
str
Language of the code if the content is code. See https://react-code-blocks-rajinwonderland.vercel.app/?path=/story/codeblock—supported-languages for a list of supported languages.
Dict
Custom metadata dictionary to attach to the message. Persisted with the message in the data layer.
List[str]
Tags to attach to the message for filtering and categorization.
str
The command selected by the user for this message. Set automatically by the UI when the user picks a command. Access this value in the on_message handler via msg.command.
Since version 2.1.0.
Dict[str, str]
The modes selected by the user for this message, as a dict of {mode_id: option_id}. Set automatically by the UI when the user configures mode pickers. Access this value in the on_message handler via msg.modes.
Since version 2.9.4.
str
Unique identifier for the message. Auto-generated as a UUID if not provided.
str
ID of the parent step or message. Automatically resolved from the current step context if not provided.
str
default:"assistant_message"
The message type (assistant_message or user_message). Automatically set based on the message direction.
str
ISO 8601 timestamp for the message creation. Automatically set to the current UTC time when .send() is called.

Send a message

Send a new message to the UI.

Stream a message

Send a message token by token to the UI.

Update a message

Update a message that already has been sent.

Remove a message

Remove a message from the UI.