Bot scenarios
Run a scripted conversation from your app: questions with buttons, a text box, cards, then an answer or a handoff to your team.
AAgent44Updated 4 min read
On this page
In one minute#
A bot scenario is a scripted conversation you build in Settings › Inbox › Bots: a welcome, a question with buttons ("Which plan are you on?"), a text box ("Your order number?"), cards with links, and an end that either finishes or hands the conversation to your team. Each bot has an id you choose (for example onboarding), and your app runs it with that id:
POST /v1/bot-scenarios/onboarding/runThe user sees the bot's first messages in the chat, up to its first question. Their answer moves the bot on, through the same message endpoint as any reply. While a bot runs, the AI agent stays quiet; when someone on your team replies, the bot stops and they take it from there.
Build a bot#
Open Settings › Inbox › Bots and choose New bot. Only workspace admins can create and change bots.
Give it a name (for your team), an id (what your app passes: 1 to 64 of
a-z,0-9,-and_, starting and ending with a letter or digit, unique in the workspace) and, optionally, a sender name (who users see the messages from; your workspace's name otherwise).Add steps, up to 30. Each is one of:
Message: plain text.
Question with buttons: a question, an answer id (for example
plan) and up to 10 buttons. Each button can lead to a different step.Question with a text box: a question, an answer id and a placeholder.
Cards: up to 10 cards, each with a title, a description, an image and up to 3 links (https only).
End the bot: optional last words; the conversation goes back to how it was (the AI agent answers again if it was answering).
Hand off to the team: optional last words; the conversation goes to your team, assigned to someone you pick or unassigned, and the AI agent stays out of it.
Steps run in order unless a step (or a button) says which step comes next. A question waits for the user's answer. Running past the last step ends the bot.
Turn it on and save. A bot that's off answers "Bot not found".
Editing, turning off or deleting a bot doesn't change conversations it's already running: they finish the steps they started with.
Run it from your app#
With the Flutter SDK, which opens the chat on it:
await Agent44.runBotScenario('onboarding');Or call the API yourself, with the user's identity headers (see the API overview):
curl -X POST https://api.agent44.ai/v1/bot-scenarios/onboarding/run \
-H "Authorization: Bearer a44_pub_YOUR_KEY" \
-H "X-A44-User-Id: usr_7f3a9c2e41" \
-H "X-A44-User-Hash: SIGNATURE_FROM_YOUR_SERVER" \
-H "Content-Type: application/json" \
-d '{}'Where it runs: pass
{"conversation_id": "…"}to run it in one of the user's conversations. Without it, the bot runs in the user's newest open conversation, or opens a new one (which counts against the user's 10 new conversations a day).200with the thread, asGET /v1/conversations/{id}returns it:{ "conversation": …, "messages": [ … ], "has_more": false }, with the bot's first messages (usually withcontent).404 {"error": "Bot not found"}for an unknown id or a bot that's off;404too for aconversation_idthat isn't this user's.409when that conversation is already running a bot.401 {"error": "This user couldn't be verified"}when the key's workspace enforces identity verification andX-A44-User-Hashis missing or wrong; nothing runs.429when a new conversation would pass the user's daily limit, or the request rate limit.
The user is created if they're new, like POST /v1/conversations.
Show and answer the bot's messages#
Bot messages come back like any other message, with author: "agent", the bot's sender name in author_name, and content describing what to draw: text, a question with buttons (picker), a text box (field) or cards (carousel). The Conversations API lists every content type and field. body always holds a plain-text version, so an app that doesn't draw content still shows the question.
When the user taps a button or submits the text box, send their answer as their message:
{ "body": "Pro", "reply_to": "<the bot message's id>", "choice": { "id": "plan", "value": "pro" } }to POST /v1/conversations/{id}/messages. agent44 marks the question answered (the choice gets "selected": true, or the field's value is set), so it can't be answered twice, and the bot sends its next messages. They aren't in the response: your next poll (GET /v1/conversations/{id}?since=…) brings them. An answer that doesn't fit the question (another question's id, a value that isn't one of the buttons, an answered question) is a 422, and nothing is sent.
If the user types a message instead of answering, the bot stops there and the conversation goes on as usual (the AI agent answers if it's on).
On websites, the web messenger draws bot messages (buttons, a text box, cards) and sends answers this way. It has no command to start a bot yet: start one from your app, or call the run endpoint yourself.
Unread, push and email#
The bot answers the user's own action, so its messages don't count as unread replies: they don't set unread on the conversation, aren't sent as push notifications, and are never in the "you have a reply" email.
In the inbox#
Your team sees the bot's messages with its name, the buttons with the one the user chose ticked, the cards, and under the user's reply "Answered plan: pro". While a bot runs, the conversation says so; a teammate's reply stops it. A handoff puts the conversation in the team's views, assigned or unassigned as you chose.