Skip to main content
new Bot() validates the whole object and throws a ConfigValidationError that names the first wrong option.

BotConfig options

Essentials

Routing and conversations

A message in conversation.* wins over the localized built-in text; to translate the built-ins instead, see Built-in messages.

Sending

Identity and storage namespace

These ids namespace everything the bot writes (store rows, user data, schedules, durable journals, traces), so two bots can share one database. Changing any of them later makes the bot look in a new namespace: existing rows stay under the old one.

Production features (opt-in)

Each one is off until you set it, and then has its own guide. storeConfig is deprecated: pass store: new MemoryStore({ file, maxMessagesPerChat, autoSaveInterval }).

Durations

Every duration option takes a string or a number of milliseconds. That includes every option whose name ends in Ms (typing.minMs, coordination.turnWaitMs, scheduler.tickMs, durability.outbox.backoff.baseMs…):
An invalid value fails fast, naming the option:
parseDuration('2m') (from @botmesh/core) reads the same grammar and returns milliseconds.

Lifecycle and events

  • Sends, edits and ctx.delete() before start() or after stop() reject with BotNotRunningError. A 'ready' listener can already send.
  • start() and stop() calls run one at a time, in call order.
  • Presence hints (ctx.typing(), ctx.markRead()) never throw while the transport is disconnected: they are skipped and counted in metrics().presenceSkipped.
Listen with bot.on(event, fn) (bot.once, bot.off too):
Always listen to 'error'Errors never crash the process, so without a listener they are only logged. bot.on('error', ({ error, ctx }) => ...) is where you report them.

Logging

logger takes a LoggerLike: pino, console, or any object with debug, info, warn and error. Providers and stores take the same logger option. The packages always call it pino style, so a custom logger only has to handle two shapes:
An error always goes under the err key, and child(bindings) is optional. Without logger the bot uses its own pino logger at warn (debug: true lowers it to debug); bot.logger is the logger in use. Chat and sender ids are personal data (phone numbers, emails), so the bot’s own log lines hash them by default: Message bodies are never logged.

Errors

All are exported by @botmesh/core. Test with instanceof; most also carry a stable code or name.

Next steps