A Message is a piece of information that is sent from the user to an assistant and vice versa. Coupled with life cycle hooks, they are the building blocks of a chat.

A message has a content, a timestamp and cannot be nested.

Example: Reply to a user message

Lets create a simple assistant that replies to a user message with a greeting.

import chainlit as cl

async def on_message(message: cl.Message):
    response = f"Hello, you just sent: {message.content}!"
    await cl.Message(response).send()

Message API

Learn more about the Message API.