Conversations are how your agent receives and responds to user messages. Each conversation file defines a handler that runs when a message arrives on a matching channel.
Create a file in src/conversations/ that exports a Conversation:
import { Conversation } from "@botpress/runtime"export default new Conversation({ channel: "*", handler: async ({ execute }) => { await execute({ instructions: "You are a helpful assistant.", }) },})
This is the simplest possible conversation. It matches all channels and hands every message to the AI model with a system instruction.You can test your conversation using the Chat page in the dev console. This requires the webchat integration, so install it first with adk add webchat.
The channel field determines which integration channels this conversation handles:
export default new Conversation({ channel: "*", handler: async ({ execute }) => { await execute({ instructions: "You are a helpful assistant.", }); },});
When you use "*", the handler runs for any channel, but message and event are typed as unknown. Specifying a channel gives you strict types on message payloads, event payloads, and the conversation instance:
If multiple conversation files match the same channel, the most specific match wins. A conversation with channel: "webchat.channel" takes priority over one with channel: "*" for webchat messages.
Your handler receives different types of requests. Check the type field to determine what you’re handling:
export default new Conversation({ channel: "webchat.channel", handler: async (props) => { switch (props.type) { case "message": // A user sent a message await props.execute({ instructions: "You are a helpful assistant." }) break case "event": // An integration event fired (e.g., conversationStarted) break case "workflow_request": // A workflow is asking the user for input break case "workflow_callback": // A workflow finished and is reporting back break case "workflow_notify": // A workflow is sending a progress update break case "nudge": // Lifecycle nudge (user has been idle) break case "expire": // Lifecycle expiration (session ending) break } },})