say, ask, choose, do,
media, form, use, goto…) and register the flow with bot.use(). Every method returns
the builder, and the type of c.state grows with each ask, choose and use.
Type Parameters
Constructors
Constructor
Parameters
Returns
FlowBuilder<S>
Methods
say()
{ delay } pauses before sending.
Parameters
Returns
FlowBuilder<S>
ask()
c.state[stateKey]. With { schema } the parsed
value is stored and typed: .ask('¿Edad?', 'edad', { schema: z.coerce.number() }) →
c.state.edad: number.
Type Parameters
Parameters
Returns
FlowBuilder<FlowStateWith<S, K, T>>
do()
Parameters
Returns
FlowBuilder<S>
media()
Call Signature
kind is one of image | video | audio | voice | document | sticker | location:
.media(source, caption?) sends an image.
Parameters
Returns
FlowBuilder<S>
Call Signature
kind is one of image | video | audio | voice | document | sticker | location:
.media(source, caption?) sends an image.
Parameters
Returns
FlowBuilder<S>
Call Signature
kind is one of image | video | audio | voice | document | sticker | location:
.media(source, caption?) sends an image.
Parameters
Returns
FlowBuilder<S>
choose()
c.state[stateKey] (defaults to c.state.choice), so a later .say/.do can read it.
An option’s then sub-flow runs inline and returns here (sharing c.state); its goto
leaves the flow for another conversation.
Type Parameters
Parameters
Returns
FlowBuilder<FlowStateWith<S, K, Extract<keyof O, string>>>
use()
Call Signature
c.state, so whatever it captures is visible here (and typed: the builder’s
state merges the sub-flow’s). The sub-flow is snapshotted at this call.
Type Parameters
Parameters
Returns
FlowBuilder<FlowStateMerge<S, T>>
Call Signature
c.state, so whatever it captures is visible here (and typed: the builder’s
state merges the sub-flow’s). The sub-flow is snapshotted at this call.
Parameters
Returns
FlowBuilder<S>
guard()
check passes. On failure it sends onFail and ends the conversation,
or — with { redirect } — jumps to another conversation:
Parameters
Returns
FlowBuilder<S>
form()
capabilities.forms === 'native'
(WhatsApp Cloud API → WhatsApp Flows) it sends one native form and waits for
its submission; elsewhere it asks field by field. Either way the validated
answers are stored in c.state[opts.stateKey ?? definition.id].
The definition is checked here: a malformed one throws a TypeError.
Parameters
Returns
FlowBuilder<S>
Example
delay()
'2s', 1500) before the next step.
Parameters
Returns
FlowBuilder<S>
goto()
Parameters
Returns
FlowBuilder<S>
timeout()
Parameters
Returns
FlowBuilder<S>
persistent()
Returns
FlowBuilder<S>
scope()
Parameters
Returns
FlowBuilder<S>
id()
Parameters
Returns
FlowBuilder<S>
compile()
Returns
CompiledFlow