bot.delay() ·
bot.schedule() with cron and time zone ·
cancelling a task ·
bot.send() outside a handler ·
regex triggers
Prerequisites
Node.js 22.12 or newer and a folder with"type": "module" (see
Getting started). Then install:
The complete bot
Sample transcript
Captured withnpx botmesh dev bot.js; the first reminder arrives two
seconds later:
How it works
bot.delay(duration, fn)runsfnonce afterduration('10s','5m','2h','1d'or milliseconds) and returns a task withcancel(). The handler keeps each task to list or cancel it later.bot.send(chatId, text)sends outside a handler: by the time the reminder fires, the message that created it is long gone, so the chat id (ctx.from) is saved first.bot.schedule(cron, { timeZone }, fn)runs on a 5-field cron expression read in an IANA time zone.bot.every('30m', fn)repeats at a fixed interval instead.- In memory. These tasks live in the process: a restart forgets them.
To survive restarts (and run once across several replicas), give a task an
idand a schedule store: see Durable tasks.
Run it on WhatsApp or Telegram
node bot.js prints a QR: scan it in WhatsApp → Linked devices. On
Telegram, install @botmesh/telegram and swap the provider as shown in
Or connect Telegram; the
factory does not change.
Next steps
- Scheduler:
every, cron syntax, daylight-saving rules - Persistent user data: remember subscribers across restarts
- Greeting bot: add
/helpand a welcome message