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 inMs (typing.minMs,
coordination.turnWaitMs, scheduler.tickMs, durability.outbox.backoff.baseMs…):
parseDuration('2m') (from @botmesh/core) reads the same grammar and returns
milliseconds.
Lifecycle and events
- Sends, edits and
ctx.delete()beforestart()or afterstop()reject withBotNotRunningError. A'ready'listener can already send. start()andstop()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 inmetrics().presenceSkipped.
bot.on(event, fn) (bot.once, bot.off too):
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:
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
- Core concepts: the inbound pipeline and the building blocks
- Messages & media: everything
ctxcan send - Operations: metrics, health and conversation events