@botmesh/core - v2.0.0-alpha.2
    Preparing search index...

    Interface AskStepOptions<T>

    Options of .ask(text, key, opts): every wait option plus a zod-compatible schema and a delay.

    interface AskStepOptions<T = string> {
        timeout?: string | number;
        validate?: (
            body: string,
            ctx: RuntimeMessage,
        ) => string | true | Promise<string | true>;
        maxAttempts?: number;
        retries?: number;
        otherwise?: string;
        filter?: (ctx: RuntimeMessage) => boolean;
        schema?: SchemaLike<T>;
        delay?: FlowDelay;
    }

    Type Parameters

    • T = string

    Hierarchy (View Summary)

    Index
    timeout?: string | number
    validate?: (
        body: string,
        ctx: RuntimeMessage,
    ) => string | true | Promise<string | true>
    maxAttempts?: number

    Total answers the wait accepts, the first one included, before the conversation ends with the "too many attempts" message (RetriesExceeded). Invalid answers and c.retry() calls count. Default 3; Infinity = unlimited.

    retries?: number

    Retries AFTER the first answer: retries: N is maxAttempts: N + 1. Pass one of the two.

    Breaking in 2.0: during the alphas retries: N meant N total attempts; use maxAttempts: N to keep that behaviour. A wait that sets retries without maxAttempts logs one warning per bot (logger.warn) to flag the change.

    otherwise?: string
    filter?: (ctx: RuntimeMessage) => boolean
    schema?: SchemaLike<T>

    Validate (and transform) the answer with any safeParse() schema (zod-compatible). The parsed value is stored in c.state[key]; a rejected answer re-prompts with otherwise, else the schema's first issue message. Runs after validate.

    delay?: FlowDelay