Ask for the user to take an action before continuing. If the user does not answer in time (see timeout), a TimeoutError will be raised or None will be returned depending on raise_on_timeout parameter. If a project ID is configured, the messages will be uploaded to the cloud storage.

Attributes

content
str

The content of the message.

actions
List[Action]

The list of Action to prompt the user.

author
str

The author of the message, defaults to the chatbot name defined in your config.

disable_human_feedback
bool
default: "False"

The number of seconds to wait for an answer before raising a TimeoutError.

timeout
int
default: 90

The number of seconds to wait for an answer before raising a TimeoutError.

raise_on_timeout
bool
default: "False"

Whether to raise a socketio TimeoutError if the user does not answer in time.

Returns

response
AskActionResponse | None
required

The response of the user.

Example

import chainlit as cl


@cl.on_chat_start
async def main():
    res = await cl.AskActionMessage(
        content="Pick an action!",
        actions=[
            cl.Action(name="continue", value="continue", label="✅ Continue"),
            cl.Action(name="cancel", value="cancel", label="❌ Cancel"),
        ],
    ).send()

    if res and res.get("value") == "continue":
        await cl.Message(
            content="Continue!",
        ).send()