Skip to main content

Input

ask.* collects a single typed answer from the user; confirm shows a yes/no dialog. For the gentle overview see Core Concepts → Collecting input.

ask.*

Every ask.* variant takes a prompt! (RichText) and an optional timeout (Duration). It pauses the flow and returns the user's answer.

VariantReturns
ask.text(prompt!, timeout)String
ask.number(prompt!, timeout)Number
ask.location(prompt!, timeout)a location object
ask.contact(prompt!, timeout)a contact object
ask.document(prompt!, timeout)a document
ask.photo(prompt!, timeout)a photo

Binding the answer

Assign the result to a local, then use it:

name = ask.text("What's your name?")
send.text(`Hi, ${name}!`)

Handling timeout and cancel

Wrap the call in a branch to route the failure paths. The answer is available as answer in the default arm:

branch ask.number("How old are you?", timeout: "120s") {
"timeout" { send.text("No answer — try again with /start.") stop }
"error" { send.text("Something went wrong.") stop }
default {
when answer < 18 {
send.text("Sorry, adults only.")
} else {
send.text("Welcome!")
}
}
}
warning

Any blocking ask.* should handle "timeout". See Error handling.

Photo and document answers

ask.photo and ask.document return file objects. Photos commonly arrive as an array of sizes — use the last (largest):

pic = ask.photo("Send me a photo 📷")
send.text("Thanks for the photo!")

confirm

A quick yes/no confirmation dialog:

confirm(title: "Delete everything?")
ParamTypeNotes
title!RichTextThe confirmation question

For a customizable confirm flow with labelled buttons and routing, use the flow.confirm recipe.

See also