Ask on WhatsApp
The Ask on WhatsApp and wait step sends a question with up to three reply buttons, parks the run, and goes on when the person taps one. It is the approval for people who answer on their phone: "Issue the receipt for 1,240?" with Issue and Not now.
You need a WhatsApp connection first: your own business number on Meta's Cloud API, set up under Connectors. See WhatsApp. Everything below assumes one named acme-whatsapp.
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
name: acme-whatsapp
namespace: tenant-acme
spec:
classRef: {name: whatsapp-cloud}
config: {}
The connection's access token, phone number id, business account id and app secret are credentials: you enter them in the console, never in YAML.
Ask and wait
- YAML
- Console
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: ask-on-whatsapp-receipts
namespace: tenant-acme
spec:
displayName: Receipts approved on WhatsApp
triggers:
- id: email
ref: {name: email-arrives}
connectorRef: {name: invoices-inbox}
config: {attachments: together}
next: [text]
nodes:
- id: text
stepRef: {name: read-text}
next: [details]
- id: details
stepRef: {name: chat-agent}
config:
instructions: Find these details in the invoice.
fields: [{name: supplier}, {name: total, hint: Amount due, type: money}]
files: {mode: ifNoText}
next: [ask]
- id: ask
title: Ask Dana to issue the receipt
stepRef: {name: whatsapp-ask}
config:
connectorRef: acme-whatsapp
to: "12025550143"
text: "Issue the receipt for {details.supplier}, {details.total}?"
buttons:
- {id: issue, title: Issue}
- {id: later, title: Not now}
template: receipt_approval
language: en
params: ["{details.total}"]
timeoutHours: 24
reasonOn: [later]
next: [decision]
- id: decision
branch:
- when: {field: ask.answer, op: eq, value: issue}
next: [tell]
- id: tell
stepRef: {name: send-email}
config:
to: accounting@acme.example
subject: "Issue a receipt for {details.supplier}"
body: "Dana approved it on WhatsApp at {ask.answeredAt}."
- Open the flow, hover the line where the step should go, click +, choose Action, and search for
whatsapp. - Choose Ask on WhatsApp and wait.
- Under Send from, pick the WhatsApp number. Under To, enter the person's number with its country code, or click the contact button beside it to pick a member of the workspace who joined this number.
- Under Question, write the question. Under Buttons, give each answer an id (what the flow reads back) and a title (what the person taps, at most 20 characters). Add one to three.
- Under Template outside 24 hours, pick an approved template, set its Template language and Template values. Set Wait up to (hours) and click Done.
Settings
| Setting | What it does |
|---|---|
Send from (connectorRef) | The WhatsApp connection. Empty is the number the run's message came in on, else the workspace's only WhatsApp connection. With none or several, the step fails and asks you to pick one. |
To (to) | The person's phone, in any format with a country code, or a placeholder. Empty answers whoever sent the message that started the run. |
To a member (toMember) | A workspace member's sign-in email, used when To is empty. The member must have joined the number with their phone, so no phone numbers sit in the flow. |
Question (text) | Required, up to 1,024 characters, placeholders allowed. |
Buttons (buttons) | One to three. Each has an id (up to 256 characters) and a title (up to 20). |
Template outside 24 hours (template, language, params) | The approved template sent when the person has not written in 24 hours. See below. |
Wait up to (hours) (timeoutHours) | 1 to 720, default 72. |
Ask why after these answers (reasonOn) | Answer ids after which the person is asked why. See Ask why. |
The 24-hour window
WhatsApp lets a business answer freely only for 24 hours after the person last wrote to its number. This is the window. It belongs to the number and the person, so it is the same for every workspace that shares a number.
| The person last wrote | What the step sends |
|---|---|
| Within 24 hours | The question as reply buttons. |
Longer ago, and you named a template | That template, whose quick reply buttons carry the answers. Its buttons must be in the same order as the step's buttons. |
Longer ago, and no template | Lumen sends its generic lumen_question template with the question cut to one line, and holds the real question. When the person next writes, or taps the template's quick reply, the held question is sent with its buttons and the run's wait is answered by that tap. |
| Longer ago, and nothing can be held (an agent's tool, a test) | The step fails with a reason that tells you to name a template. |
Templates are approved by Meta, which usually takes minutes. Manage them on the WhatsApp connection under Message templates: Sync templates from Meta, New template with Quick replies, and Add Lumen's generic templates for lumen_update and lumen_question. Only an approved template can be sent, and the editor tells you when the one you picked is not.
Quiet hours on the connection hold a question until they end. The question then goes out inside or outside the window as it stands at that time.
What comes back
A tap resumes the same run, and the step adds these fields as <nodeId>.<name>:
| Output | Type | What it holds |
|---|---|---|
answer | string | The id of the button tapped, such as issue. Branch on this. |
answerTitle | string | The button's title. |
answeredBy | string | The person's phone. |
answeredAt | date | When they tapped. |
reason | string | What they typed after an answer that asks why. Empty otherwise. |
reasonQuoted | string | The same text wrapped for an AI agent's prompt, as data. Give an agent this one. |
Each button carries a signed, single-use payload. Lumen checks that the tap is for this wait, from the phone that was asked, on this number, before the deadline. An altered payload, a second tap or a late tap resumes nothing and gets a short answer ("This question was already answered." or "This question has expired."). The person can tap once.
If nobody taps by the deadline, the step fails and the run fails at it, like an approval. The buttons then answer nothing.
Ask why
A rejection is more useful with its reason. Name the answers that should ask for one in reasonOn. After a tap on such an answer, Lumen replies with reasonPrompt (default "Why? One line is enough.") and the run keeps waiting. The next text from that person on that number is the reason, and they get "Thanks, noted." If no text comes within reasonMinutes (1 to 120, default 30, never past the step's own wait), the run goes on with an empty reason.
The reason is untrusted text, cleaned to one line of at most 500 characters. A command that starts with / and a button tap are never taken as a reason.
Buttons that start a flow
Ask with buttons on WhatsApp (whatsapp-send-buttons) sends the same kind of question but does not wait. A tap starts a new run of the flows that listen on the connection, with the button's id as buttonId, and a later step branches on it. Use it when you want a menu that anyone can use at any time. Use Ask on WhatsApp and wait when the answer belongs to this run.
It works only inside the 24-hour window.
