Skip to main content
Defined in: flows/FlowBuilder.ts:290 Builder returned by flow. Chain steps (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

Defined in: flows/FlowBuilder.ts:297

Parameters

Returns

FlowBuilder<S>

Methods

say()

Defined in: flows/FlowBuilder.ts:304 Send a message. { delay } pauses before sending.

Parameters

Returns

FlowBuilder<S>

ask()

Defined in: flows/FlowBuilder.ts:315 Ask a question and store the answer in 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()

Defined in: flows/FlowBuilder.ts:328

Parameters

Returns

FlowBuilder<S>

media()

Call Signature

Defined in: flows/FlowBuilder.ts:341 Send media. kind is one of image | video | audio | voice | document | sticker | location:
The legacy two-argument form .media(source, caption?) sends an image.
Parameters
Returns
FlowBuilder<S>

Call Signature

Defined in: flows/FlowBuilder.ts:342 Send media. kind is one of image | video | audio | voice | document | sticker | location:
The legacy two-argument form .media(source, caption?) sends an image.
Parameters
Returns
FlowBuilder<S>

Call Signature

Defined in: flows/FlowBuilder.ts:343 Send media. kind is one of image | video | audio | voice | document | sticker | location:
The legacy two-argument form .media(source, caption?) sends an image.
Parameters
Returns
FlowBuilder<S>

choose()

Defined in: flows/FlowBuilder.ts:367 Present a numbered menu and capture the selection. The picked option KEY is stored in 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

Defined in: flows/FlowBuilder.ts:400 Run another flow inline, then come back and continue with the next step. The sub-flow shares 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

Defined in: flows/FlowBuilder.ts:401 Run another flow inline, then come back and continue with the next step. The sub-flow shares 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()

Defined in: flows/FlowBuilder.ts:418 Stop the flow unless check passes. On failure it sends onFail and ends the conversation, or — with { redirect } — jumps to another conversation:

Parameters

Returns

FlowBuilder<S>

form()

Defined in: flows/FlowBuilder.ts:447 Collect a typed form. On providers with 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()

Defined in: flows/FlowBuilder.ts:455 Pause the flow ('2s', 1500) before the next step.

Parameters

Returns

FlowBuilder<S>

goto()

Defined in: flows/FlowBuilder.ts:460

Parameters

Returns

FlowBuilder<S>

timeout()

Defined in: flows/FlowBuilder.ts:465

Parameters

Returns

FlowBuilder<S>

persistent()

Defined in: flows/FlowBuilder.ts:466

Returns

FlowBuilder<S>

scope()

Defined in: flows/FlowBuilder.ts:467

Parameters

Returns

FlowBuilder<S>

id()

Defined in: flows/FlowBuilder.ts:468

Parameters

Returns

FlowBuilder<S>

compile()

Defined in: flows/FlowBuilder.ts:470

Returns

CompiledFlow