Skip to main content
Defined in: core/Bot.ts:243 The bot engine. Register handlers, flows, conversations, hooks and plugins, then call start(). A bot drives exactly one transport (BotConfig.provider); everything it receives and sends goes through the neutral IProvider contract, so the same code runs on WhatsApp, Telegram or any other channel.

Example

Extends

  • EventEmitter

Constructors

Constructor

Defined in: core/Bot.ts:321

Parameters

Returns

Bot

Overrides

EventEmitter.constructor

Properties

logger

Defined in: core/Bot.ts:244

ready

Defined in: core/Bot.ts:269 Resolves when the bot reaches the 'ready' connection state.

blacklist

Defined in: core/Bot.ts:276 Senders/chats whose inbound messages are dropped before anything else (not persisted, no hooks, no routing, no 'message' event). Ids are matched exactly against ctx.sender and ctx.from. See AccessList.

whitelist

Defined in: core/Bot.ts:281 When enabled, only senders/chats on this list are processed (the blacklist still wins). Disabled by default. See Whitelist.

Methods

on()

Call Signature

Defined in: core/Bot.ts:358 Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
Returns a reference to the EventEmitter, so that calls can be chained. By default, event listeners are invoked in the order they are added. The emitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.
Type Parameters
Parameters
Returns
this
Since
v0.1.101
Overrides
EventEmitter.on

Call Signature

Defined in: core/Bot.ts:359
Parameters
Returns
this
Overrides
EventEmitter.on

once()

Call Signature

Defined in: core/Bot.ts:362 Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter, so that calls can be chained. By default, event listeners are invoked in the order they are added. The emitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.
Type Parameters
Parameters
Returns
this
Since
v0.3.0
Overrides
EventEmitter.once

Call Signature

Defined in: core/Bot.ts:363
Parameters
Returns
this
Overrides
EventEmitter.once

off()

Call Signature

Defined in: core/Bot.ts:366 Alias for emitter.removeListener().
Type Parameters
Parameters
Returns
this
Since
v10.0.0
Overrides
EventEmitter.off

Call Signature

Defined in: core/Bot.ts:367
Parameters
Returns
this
Overrides
EventEmitter.off

emit()

Call Signature

Defined in: core/Bot.ts:370 Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each. Returns true if the event had listeners, false otherwise.
Type Parameters
Parameters
Returns
boolean
Since
v0.1.26
Overrides
EventEmitter.emit

Call Signature

Defined in: core/Bot.ts:371
Parameters
Returns
boolean
Overrides
EventEmitter.emit

start()

Defined in: core/Bot.ts:378

Returns

Promise<void>

stop()

Defined in: core/Bot.ts:388 Stop the bot. By default aborts conversations and tears down immediately.

Parameters

Returns

Promise<void>

send()

Defined in: core/Bot.ts:397 Send normalized content to any chat (a plain string is sent as text, like broadcast and sendTo). Runs the before('send')/after('send') hook pipeline; a before('send') hook may mutate payload.content or abort() to skip.

Parameters

Returns

Promise<SentMessage<unknown>>

enqueue()

Defined in: core/Bot.ts:426 Durable fire-and-forget send (needs BotConfig.durability): runs the before('send') hooks, journals the send and returns its outbox key at once; the background sweeper delivers it (retries, backoff, dead-letter queue). Enqueueing an idempotencyKey that already exists is a no-op (status: 'exists') — use it for campaigns and scheduled jobs that may run twice. A text over the channel’s limit is split after the hooks (BotConfig.splitLongText) into one record per part: key, key#2, ….

Parameters

Returns

Promise<{ key: string; status: "exists" | "queued" | "skipped"; }>

Example


sendText()

Defined in: core/Bot.ts:435 Send plain text to a chat. Same as send(chatId, text).

Parameters

Returns

Promise<SentMessage<unknown>>

Deprecated

Use send: bot.send(chatId, text) (a string is sent as text).

broadcast()

Defined in: core/Bot.ts:463 Send content (a string is sent as text) to many chats: in batches of batchSize (default 10) with concurrency parallel sends (default 1), pausing delayBetween between batches. A RateLimitedError pauses the whole broadcast for its retryAfterMs and retries that chat (up to retries times after the first send, default 3); other errors are recorded and the broadcast goes on. Abort signal to stop early — never-attempted chats come back in pending. bot.stop() cancels it the same way (with drain, stop waits for its in-flight sends), and a broadcast started on a bot that is not started (never started, or stopped) sends nothing. Duplicate ids are sent once. Each send takes the normal outbound path (send hooks, ledger, the provider’s rate limiter) but not the dispatcher’s per-chat queues, so inbound handling is never blocked; still, launch it with void (not await) from inside a handler so that chat’s queue is not held.

Parameters

Returns

Promise<BroadcastResult>

Example


trigger()

Defined in: core/Bot.ts:491 Start a registered flow/conversation for a subject without waiting for them to write — reminders from bot.schedule(), webhooks, admin panels. data seeds c.state. The start goes through the same gates as a message (blacklist / whitelist, human handoff) and the chat’s FIFO queue; by default a subject that already has a live or dormant conversation is left alone (ifActive: 'replace' cancels it). Resolves once the conversation is entered — not when it ends (listen to 'conversation:ended' for that). Rejects when name is not registered. Safe to await from a handler or command of the same chat: the trigger then runs inline in that message’s queue slot instead of queuing behind it (which would deadlock the chat). Awaiting a trigger for a DIFFERENT chat whose handlers in turn await a trigger back into this one can still deadlock — launch those with void. Before-message hooks, matchers and the 'message' event do not run, and nothing is persisted for the synthetic inbound (ctx.raw is { synthetic: 'trigger', name }).

Parameters

Returns

Promise<TriggerResult>

Example


metrics()

Defined in: core/Bot.ts:501 Snapshot of the runtime counters: conversations (started/completed/cancelled/ timedOut/retriesExceeded/errored, active, mean duration) overall and per flow, messages in/out, inbound drops (duplicate/blocked/handoff), triggers, errors and uptime. In-process only. Render it for Prometheus with toPrometheus().

Returns

BotMetricsSnapshot

resetMetrics()

Defined in: core/Bot.ts:506 Zero every metrics counter (uptime is kept).

Returns

void

handoff()

Defined in: core/Bot.ts:539 Hand chatId over to a human agent. Until resume, the Dispatcher skips every routing stage for that chat (commands, conversations, dormant resume, matchers, catch-all) except BotConfig.handoff.allowCommands; inbound messages are still persisted, hooks still run and the 'message' event still fires. Active conversations in the chat are cancelled silently and its dormant checkpoints dropped. Emits 'handoff' and persists the state on StoredChat.handoff (survives restarts with a persistent store). The state flips synchronously, so not awaiting is safe. Resolves true if the chat was not already handed off; never rejects for store failures (they go to the 'error' event). Throws TypeError synchronously on an empty chat id.

Parameters

Returns

Promise<boolean>

resume()

Defined in: core/Bot.ts:547 Give a handed-off chat back to the bot: routing resumes immediately, 'resume' fires and the persisted state is cleared. Resolves true if the chat was handed off.

Parameters

Returns

Promise<boolean>

isHandedOff()

Defined in: core/Bot.ts:552 Is chatId currently handed off to a human?

Parameters

Returns

boolean

getHandoff()

Defined in: core/Bot.ts:557 Snapshot of the chat’s handoff state (since, reason, meta), or undefined.

Parameters

Returns

HandoffState | undefined

listHandoffs()

Defined in: core/Bot.ts:562 Snapshots of every chat currently handed off.

Returns

HandoffState[]

sendTo()

Defined in: core/Bot.ts:574 Send to a chat from outside the inbound pipeline — typically a human agent’s message during a handoff. Same path as send (before/after('send') hooks, outbound ledger); it is the same call as send, named for handoff code. Works whether or not the chat is handed off and never resumes the bot by itself.

Parameters

Returns

Promise<SentMessage<unknown>>

Deprecated

Use send: bot.send(chatId, content, options) (the very same call).

exportAccessLists()

Defined in: core/Bot.ts:579 JSON-serializable snapshot of blacklist + whitelist for host persistence.

Returns

AccessListsSnapshot

loadAccessLists()

Defined in: core/Bot.ts:584 Restore exportAccessLists output. Lists missing from snapshot are left untouched.

Parameters

Returns

this

when()

Defined in: core/Bot.ts:601 Route messages matching trigger (text, RegExp, function, type trigger such as IMAGE, WELCOME, or an array) to a handler or a flow. Returns an unsubscriber.

Parameters

Returns

() => void

conversation()

Defined in: core/Bot.ts:621 Register an async conversation, entered when opts.trigger (default: name) matches. ctx is the full MessageContext of the triggering message (ctx.tools, media helpers, react…); c offers ask/waitText/waitMedia/choose, retry(), idle()/idleClear(), end(farewell?) and goto(name).

Parameters

Returns

() => void

Example


enterConversation()

Call Signature

Defined in: core/Bot.ts:650 Enter an inline ConversationHandler for the chat (or group participant) of ctx. To start a REGISTERED conversation or flow, use trigger (the by-name form here is deprecated). Fire-and-forget by design: it returns immediately, so a handler can start a conversation and return, releasing the chat’s FIFO queue for the user’s next message (which the conversation then receives). Any conversation already active on that key is replaced. Failures (e.g. an unknown name) are reported through the 'error' event, never as an unhandled rejection. The returned promise settles (it never rejects) once the conversation has ended and released its key. Never await it inside a handler: that blocks the chat’s queue, so the user’s answer could never reach the conversation.
Parameters
Returns
Promise<void>
Example

Call Signature

Defined in: core/Bot.ts:656
Parameters
Returns
Promise<void>
Deprecated
Start a registered conversation with trigger: bot.trigger(name, { chatId: ctx.from, userId: ctx.sender, isGroup: ctx.isGroup, ifActive: 'replace' }) (safe to await from a handler of the same chat).

use()

Call Signature

Defined in: core/Bot.ts:667 Register flows (an array is accepted). Chainable; remove one later with unregisterFlow. Plugins go through plug.
Parameters
Returns
this

Call Signature

Defined in: core/Bot.ts:672
Parameters
Returns
this
Deprecated
Plug plugins with plug (bot.plug(plugin)), which also returns the unsubscriber; use() is for flows.

useFlow()

Defined in: core/Bot.ts:685 Same as use(flow), typed for a single flow.

Parameters

Returns

this

Deprecated

Use use (bot.use(flow)), or registerFlow to get the flow id back and refuse a duplicate id.

command()

Defined in: core/Bot.ts:688 Register a /name command (wins over an active conversation). Returns an unsubscriber.

Parameters

Returns

() => void

onMessage()

Defined in: core/Bot.ts:697 Catch-all handler: receives the messages no command, conversation or matcher took. Not to be confused with bot.on('message', …), the event that observes every inbound message. Returns an unsubscriber.

Parameters

Returns

() => void

onType()

Defined in: core/Bot.ts:705 Handle every message of one MessageType (same as when(IMAGE, handler) and the other type triggers). Returns an unsubscriber.

Parameters

Returns

() => void

onImage()

Defined in: core/Bot.ts:709

Parameters

Returns

() => void

Deprecated

Use bot.onType('image', handler) or bot.when(IMAGE, handler).

onAudio()

Defined in: core/Bot.ts:711

Parameters

Returns

() => void

Deprecated

Use bot.onType('audio', handler) or bot.when(AUDIO, handler).

onVideo()

Defined in: core/Bot.ts:713

Parameters

Returns

() => void

Deprecated

Use bot.onType('video', handler) or bot.when(VIDEO, handler).

onDocument()

Defined in: core/Bot.ts:715

Parameters

Returns

() => void

Deprecated

Use bot.onType('document', handler) or bot.when(DOCUMENT, handler).

onSticker()

Defined in: core/Bot.ts:717

Parameters

Returns

() => void

Deprecated

Use bot.onType('sticker', handler) or bot.when(STICKER, handler).

onLocation()

Defined in: core/Bot.ts:719

Parameters

Returns

() => void

Deprecated

Use bot.onType('location', handler) or bot.when(LOCATION, handler).

onContact()

Defined in: core/Bot.ts:721

Parameters

Returns

() => void

Deprecated

Use bot.onType('contact', handler) or bot.when(CONTACT, handler).

onPoll()

Defined in: core/Bot.ts:723

Parameters

Returns

() => void

Deprecated

Use bot.onType('poll', handler) or bot.when(POLL, handler).

registerFlow()

Defined in: core/Bot.ts:738 Register a flow at runtime (same as use(flow), but refuses a duplicate id). Returns the flow id. See replaceFlow to hot-swap an existing one.

Parameters

Returns

string

Example


unregisterFlow()

Defined in: core/Bot.ts:744 Remove a flow or conversation by id: its triggers stop matching. Conversations already running finish on the version they entered with. Returns false when unknown.

Parameters

Returns

boolean

replaceFlow()

Defined in: core/Bot.ts:751 Hot-swap the flow registered under id (registers it when absent). The new flow keeps id whatever its own id is; its trigger replaces the old one. Running conversations keep the old version; persisted checkpoints resume on the new steps (by step index).

Parameters

Returns

void

hasFlow()

Defined in: core/Bot.ts:754 Whether a flow or conversation is registered under id.

Parameters

Returns

boolean

listFlows()

Defined in: core/Bot.ts:757 Every live flow (kind: 'flow') and async conversation (kind: 'conversation').

Returns

RegisteredFlowInfo[]

triggerFlow()

Defined in: core/Bot.ts:771 Start flow id proactively in a chat, without an inbound message (the user’s replies then flow into it as usual). A thin wrapper over trigger with ifActive: 'replace' — same access-list and handoff gates, per-chat FIFO slot, language resolution, messaging seams and metrics — so it replaces a conversation already running (or dormant) on the same key. Resolves false when the flow is unknown, the subject is refused by the access lists (blacklist / whitelist) or the chat is handed off; rejects when the bot is not started.

Parameters

Returns

Promise<boolean>

Deprecated

Use trigger: bot.trigger(id, { chatId, userId, isGroup, data, body, ifActive: 'replace' }) (it resolves a TriggerResult; result.started is this method’s boolean).

listConversations()

Defined in: core/Bot.ts:776 Snapshots of every live conversation (key, state, waiting, queued).

Returns

ConversationSnapshot[]

abortConversation()

Defined in: core/Bot.ts:782 Cancel the live conversation of target (a ConversationTarget, e.g. a ctx, or a raw runtime key from listConversations). Returns false when none is live.

Parameters

Returns

boolean

resetWelcome()

Defined in: core/Bot.ts:807 Re-arm the WELCOME trigger so the subject’s next message is treated as a first contact again (persisted in the store, so it survives restarts).
  • resetWelcome(dmChatId) — the user of that DM.
  • resetWelcome(groupId, userId) — one participant of a group.
  • resetWelcome(groupId) — every participant of that group.
Called from a handler of the same chat it is ordered with that chat’s messages (the dispatcher’s FIFO); called from elsewhere it races like any last-writer-wins store write. Rejects if the store write fails (the in-process state is re-armed regardless). slashCommandsPlugin calls it on /reset.

Parameters

Returns

Promise<void>

Example


inspectConversation()

Defined in: core/Bot.ts:816 Read-only snapshot of the live conversation for a chat (and participant, in groups): captured c.state, whether it waits for a reply. undefined when none is active. Diagnostics only — e.g. botmesh dev’s :state command.

Parameters

Returns

| ConversationSnapshot | undefined

isBusy()

Defined in: core/Bot.ts:828 True while the bot is still reacting to what it received: a provider event is being stored or dispatched to its handlers (e.g. one awaiting an AI call), or a conversation is running a step instead of waiting for the user’s reply. Work a handler starts without awaiting it is not tracked. Diagnostics only — botmesh dev uses it to wait for slow replies when its input is piped.

Returns

boolean

before()

Defined in: core/Bot.ts:842 Register a before hook (higher priority runs first). Chainable. The context is typed by the event (HookContextMap: MessageContext for 'message', SendHookContext for 'send', …) plus abort(); a custom event’s context is unknown unless the handler annotates it (or TCtx is given).

Type Parameters

Parameters

Returns

this

after()

Defined in: core/Bot.ts:847 Register an after hook (higher priority runs first). Chainable. Context typed like before.

Type Parameters

Parameters

Returns

this

onError()

Defined in: core/Bot.ts:855 Register an error-phase hook: (ctx, error) with the failing context. priority orders it like before/after (default 0).

Type Parameters

Parameters

Returns

this

hook()

Call Signature

Defined in: core/Bot.ts:860 Register a hook for any phase: the generic form of before/after/onError.
Type Parameters
Parameters
Returns
this

Call Signature

Defined in: core/Bot.ts:861 Register a hook for any phase: the generic form of before/after/onError.
Type Parameters
Parameters
Returns
this

Call Signature

Defined in: core/Bot.ts:862 Register a hook for any phase: the generic form of before/after/onError.
Type Parameters
Parameters
Returns
this

Call Signature

Defined in: core/Bot.ts:863 Register a hook for any phase: the generic form of before/after/onError.
Parameters
Returns
this

plug()

Defined in: core/Bot.ts:902 Install a plugin (optionally with config). Unlike use, returns an unsubscriber (not the bot: do not chain) that first calls the plugin’s uninstall() and then removes, newest first, what it registered through ctx.bot: commands, matchers, conversations/flow triggers, hooks, nested plugins, runtime flows and onDispose callbacks. Calling it again is a no-op. It does NOT undo event listeners (on/once), provide()d tools, locale() messages, schedule/every/delay jobs, onIdle handlers or a flow replaceFlow() overwrote: undo those in ctx.onDispose() (e.g. ctx.bot.unprovide(name)). install() should be synchronous. If it throws, whatever it registered so far is rolled back and the error is rethrown; if it returns a promise that rejects, the rejection goes to the 'error' event instead of crashing the process. spec.requires lists plugin names that must already be plugged (a nested plugin may require its parent); a missing one throws before install() runs. Flows registered through ctx.bot.registerFlow() (or created by ctx.bot.replaceFlow()) are unregistered on unplug. One instance per plugin name: plugging a name that is already plugged throws (unplug the first instance before plugging it again), unless every instance sets spec.multiple: true. config is typed by the plugin (definePlugin<MyConfig>()), so an unknown option or a wrong type is a compile error.

Type Parameters

Parameters

Returns

() => void

Throws

when a plugin named in spec.requires is not plugged, or when a plugin with the same spec.name is already plugged and spec.multiple is not set.

locale()

Call Signature

Defined in: core/Bot.ts:933 Register (deep-merge) the messages of locale code, or — with an options object — configure i18n (defaultLocale, detect, providerLanguage, userKey, locales). Either form turns on per-message language resolution: ctx.user preference → provider-reported language → detect → default, limited to the locales allow-list when one is set. Keys nest (ctx.t('menu.title')), {param} placeholders are interpolated and { one, other, zero? } leaves pick a plural form from params.count. The built-in core messages live under core.* (es and en ship) and can be overridden here. Throws TypeError on an invalid code or message tree.
Parameters
Returns
this
Example

Call Signature

Defined in: core/Bot.ts:934 Register (deep-merge) the messages of locale code, or — with an options object — configure i18n (defaultLocale, detect, providerLanguage, userKey, locales). Either form turns on per-message language resolution: ctx.user preference → provider-reported language → detect → default, limited to the locales allow-list when one is set. Keys nest (ctx.t('menu.title')), {param} placeholders are interpolated and { one, other, zero? } leaves pick a plural form from params.count. The built-in core messages live under core.* (es and en ship) and can be overridden here. Throws TypeError on an invalid code or message tree.
Parameters
Returns
this
Example

t()

Defined in: core/Bot.ts:945 Translate outside a handler (scheduled jobs, broadcasts): lang defaults to the default locale. Pair it with langOf to use a user’s stored preference.

Parameters

Returns

string

langOf()

Defined in: core/Bot.ts:955 The stored language preference of userId (ctx.setLang) when a registered locale serves it, else the default locale — the same language ctx.lang would resolve from the stored value (always the default while i18n is off). A store read failure resolves the default (logged at debug level).

Parameters

Returns

Promise<string>

locales()

Defined in: core/Bot.ts:960 Registered locale codes, built-in es/en included.

Returns

string[]

provide()

Defined in: core/Bot.ts:970 Inject value as ctx.tools[name] in every handler (replacing a previous value under the same name). Returns the bot, so calls can be chained. Undo it with unprovide.

Type Parameters

Parameters

Returns

this

unprovide()

Defined in: core/Bot.ts:981 Remove the tool injected under name by provide (the inverse of provide, as unregisterFlow is of registerFlow). Returns true when a tool was removed, false when none was provided under that name. Unplugging a plugin does not undo its provide() calls: call this from ctx.onDispose().

Parameters

Returns

boolean

schedule()

Call Signature

Defined in: core/Bot.ts:996 Run fn on a cron expression (e.g. '0 9 * * *').
Parameters
Returns
ScheduledTask

Call Signature

Defined in: core/Bot.ts:1001 Durable cron task: its schedule is stored under opts.id (see BotConfig.scheduler), survives restarts with the opts.missed policy, and each occurrence runs on one replica.
Parameters
Returns
ScheduledTask

Call Signature

Defined in: core/Bot.ts:1006 Cron task read in a time zone: bot.schedule('0 9 * * 1-5', { timeZone: 'America/Bogota' }, fn) (see CronTaskOptions for the daylight-saving rules). Add an id to make it durable.
Parameters
Returns
ScheduledTask

every()

Call Signature

Defined in: core/Bot.ts:1015 Run fn every interval (a duration such as '10m', or ms).
Parameters
Returns
ScheduledTask

Call Signature

Defined in: core/Bot.ts:1017 Durable interval task (see the durable schedule overload); slots do not drift.
Parameters
Returns
ScheduledTask

delay()

Call Signature

Defined in: core/Bot.ts:1022 Run fn once after duration (a duration such as '30s', or ms).
Parameters
Returns
ScheduledTask

Call Signature

Defined in: core/Bot.ts:1028 Durable one-shot task: its run time is fixed when opts.id is first stored, so a restart does not push it back, provided the code registers the id again at boot (only the schedule is stored, not the handler). See the durable schedule overload.
Parameters
Returns
ScheduledTask

forgetTask()

Defined in: core/Bot.ts:1037 Delete the stored schedule of a durable task id (the bot’s store namespace is applied, as on registration): an orphan logged at start (stored, no longer registered in code), a one-shot tombstone, or a registered task, which is cancelled as well.

Parameters

Returns

Promise<void>

onIdle()

Defined in: core/Bot.ts:1062 Run handler once when a chat stays quiet for duration ('10m', '1h', '1d', ms…) after its last processed inbound message. Every new inbound message from that chat reschedules it, and re-arms it after it fired. ctx is that last message’s context, so ctx.reply('¿Sigues ahí?') answers in the right chat. Handler errors go to the bot 'error' event. Pending timers are cancelled by clearIdle, by the returned unsubscribe and by stop(). The handler never runs for a chat in human handoff: a 'handoff' event carrying { chatId } cancels that chat’s timers, and its messages do not re-arm them until a 'resume' event for that chat (the bot’s own isHandedOff() state is honoured too, when present). duration must be positive and at most 2^31 − 1 ms (about 24.8 days, the longest a Node timer can wait); otherwise it throws RangeError.

Parameters

Returns

() => void

Example


clearIdle()

Defined in: core/Bot.ts:1070 Cancel pending onIdle timers for chatId (every chat when omitted) — e.g. when a human agent takes the chat over. They re-arm on that chat’s next processed inbound message.

Parameters

Returns

void

getStore()

Defined in: core/Bot.ts:1078

Returns

IStore

getProvider()

Defined in: core/Bot.ts:1079

Returns

IProvider

getConnectionState()

Defined in: core/Bot.ts:1080

Returns

ConnectionState

getNamespace()

Defined in: core/Bot.ts:1081

Returns

Readonly<StoreNamespace>

getSessionName()

Defined in: core/Bot.ts:1082

Returns

string

user()

Defined in: core/Bot.ts:1094 Persistent profile of any subject — the same data a handler sees as ctx.user when that subject writes (scheduled jobs, webhooks, admin code). Requires a store implementing the user-data contract (every built-in one).

Parameters

Returns

UserData

Example


purgeExpiredUserData()

Defined in: core/Bot.ts:1102 Physically remove expired ctx.user entries store-wide and resolve with how many were removed (0 with native-TTL stores such as Redis). Writes already trigger this at most once a minute; schedule it for idle bots: bot.every('1h', () => bot.purgeExpiredUserData()).

Returns

Promise<number>

exportSubject()

Defined in: core/Bot.ts:1105 Export normalized data associated with one subject in this bot namespace.

Parameters

Returns

Promise<SubjectDataExport>

deleteSubject()

Defined in: core/Bot.ts:1113 Delete normalized subject data in this bot namespace, including the handoff of chat userId and the subject’s live or dormant conversations.

Parameters

Returns

Promise<SubjectDeletionResult>

flowInventory()

Defined in: core/Bot.ts:1125 Read-only snapshot of the registered flows, conversations and trigger routes, plus the bits of config the linter needs. Input of describeFlows()/lintFlows().

Returns

FlowInventory

describe()

Call Signature

Defined in: core/Bot.ts:1139 Describe every registered flow/conversation as a Mermaid flowchart (default) or, with { format: 'json' }, as a JSON graph. See describeFlows.
Parameters
Returns
FlowGraph
Example

Call Signature

Defined in: core/Bot.ts:1140 Describe every registered flow/conversation as a Mermaid flowchart (default) or, with { format: 'json' }, as a JSON graph. See describeFlows.
Parameters
Returns
string
Example

Call Signature

Defined in: core/Bot.ts:1141 Describe every registered flow/conversation as a Mermaid flowchart (default) or, with { format: 'json' }, as a JSON graph. See describeFlows.
Parameters
Returns
string | FlowGraph
Example

lint()

Defined in: core/Bot.ts:1153 Statically lint the registered flows: unreachable steps/flows, missing goto targets, empty/duplicate triggers, risky timeouts, ambiguous menus, … See lintFlows.

Parameters

Returns

LintDiagnostic[]

Example

Accessors

durability

Get Signature

Defined in: core/Bot.ts:411 Durable message processing controls — the inbox/outbox journals, operator replay/retry of dead-lettered records and counters. undefined unless BotConfig.durability is set.
Example
Returns
DurabilityControl | undefined

tracing

Get Signature

Defined in: core/Bot.ts:520 The bot’s tracing (BotConfig.telemetry): start your own spans under the bot’s, or check enabled. Plugins (@botmesh/ai) use it to add their spans to the same trace. Without telemetry it is a disabled no-op (BotTracing.enabled false).
Example
Returns
BotTracing

injectTools

Get Signature

Defined in: core/Bot.ts:987
Returns
DefaultTools & Record<string, unknown>