> ## Documentation Index
> Fetch the complete documentation index at: https://botmesh.afaya.com.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Examples

> Complete bots you can copy, run and adapt. Most examples are one bot.js file that shows a set of botmesh features, with a transcript captured from a real run and links to the guide of every feature it uses. A test runs every example's code and checks its transcript, so what you read is what you get.

## Run any example

1. Set up a project once, as in
   [Getting started](https://botmesh.afaya.com.co/guide/getting-started.md#requirements) (Node.js 22.12+,
   `"type": "module"`, `npm install @botmesh/core @botmesh/baileys`).

2. Save the example's code as `bot.js`.

3. Chat with it in the terminal, no phone needed:

   ```bash theme={null}
   npx botmesh dev bot.js
   ```

4. Connect it for real with `node bot.js` (a QR code for WhatsApp), or swap
   the provider for [Telegram](https://botmesh.afaya.com.co/guide/getting-started.md#or-connect-telegram).
   The bot code does not change between channels.

## Beginner

| Example | Level | Tags | Features | What you'll build |
| - | - | - | - | - |
| [Greeting bot](https://botmesh.afaya.com.co/examples/greeting-bot.md) | Beginner | Commands | `WELCOME`, text and regex triggers, `ctx.pass()`, slash commands, catch-all | A bot that welcomes each user once, says hello, echoes and lists its commands |
| [FAQ bot](https://botmesh.afaya.com.co/examples/faq-bot.md) | Beginner | Triggers | Normalized matching, keyword lists, `contains`, regex, precedence | Keyword answers to frequent questions, with a fallback |
| [Send messages](https://botmesh.afaya.com.co/examples/messages.md) | Beginner | Triggers | Trigger forms, `ctx.quote()`, `ctx.react()`, sender info | Every way to answer a text message |
| [Menu bot](https://botmesh.afaya.com.co/examples/menu-bot.md) | Beginner | Flows, Buttons | `flow().choose()`, `then` sub-flows, `bot.conversation()`, buttons per channel | A pizza-place menu that works on every channel |
| [Poll bot](https://botmesh.afaya.com.co/examples/poll-bot.md) | Beginner | Polls, Reactions | `ctx.poll()`, `bot.on('poll')`, `bot.send()`, `ctx.react()` | Native polls answered with the live tally |
| [Media replies](https://botmesh.afaya.com.co/examples/media.md) | Beginner | Media | Photo, file, video, voice, sticker, location, contact; `bot.onType()`, `loadMediaOf()` | A bot that sends every media kind and reacts to images |
| [Reminder bot](https://botmesh.afaya.com.co/examples/reminders.md) | Beginner | Scheduler | `bot.delay()`, `bot.schedule()` with time zone, `task.cancel()`, `bot.send()` | One-off reminders and a daily tip at 9:00 |
| [Registration flow](https://botmesh.afaya.com.co/examples/registration-flow.md) | Beginner | Flows, Forms | `.ask()` with `validate`, `.do()`, `c.state`, `.timeout()`, `/cancel` | A validated sign-up that saves the user |

## Intermediate

| Example | Level | Tags | Features | What you'll build |
| - | - | - | - | - |
| [Shopping flow](https://botmesh.afaya.com.co/examples/shopping-flow.md) | Intermediate | Flows | `.choose()`, `then` sub-flows, `goto`, computed state, timeouts | A small shop with quantity, confirmation and address |
| [Support with timeout](https://botmesh.afaya.com.co/examples/support-flow.md) | Intermediate | Conversations | `bot.conversation()`, `c.waitText()`, `c.choose()`, `ConversationTimeout`, `ConversationCancelled` | A support desk that opens tickets and handles abandoned sessions |
| [Plugin: rate limiter](https://botmesh.afaya.com.co/examples/rate-limiter.md) | Intermediate | Plugins, Hooks | `definePlugin()`, `before('message')`, `abort()`, `onDispose()` | A reusable plugin that limits messages per user |
| [Appointment booking](https://botmesh.afaya.com.co/examples/appointment-booking.md) | Intermediate | WhatsApp, Forms, SQLite | `.persistent()`, `.form()`, `validate` + `maxAttempts`, `SQLiteStore`, `ctx.user` | A booking flow that validates, confirms and resumes after a restart |
| [Order tracking](https://botmesh.afaya.com.co/examples/order-tracking.md) | Intermediate | WhatsApp, User data | `ctx.user` namespaces, `bot.conversation()`, `MemoryStore` file | Order lookups that remember what each user follows |
| [Human handoff](https://botmesh.afaya.com.co/examples/human-handoff.md) | Intermediate | WhatsApp, Support | `ctx.handoff()`, `bot.resume()`, handoff events, agent commands, `bot.delay()` | A support bot that passes chats to agents and takes them back |
| [Multi-language bot](https://botmesh.afaya.com.co/examples/multi-language.md) | Intermediate | WhatsApp, Telegram, i18n | `bot.locale()`, `ctx.t()`, `detect`, `ctx.setLang()`, plurals | A bot that answers each user in English or Spanish |
| [Group bot](https://botmesh.afaya.com.co/examples/group-bot.md) | Intermediate | WhatsApp, Telegram, Groups | per-participant conversations, `scope`, mentions, `groupMode`, admin-only commands | A group quiz with a scoreboard and admin commands |
| [WhatsApp and Telegram at once](https://botmesh.afaya.com.co/examples/whatsapp-and-telegram.md) | Intermediate | WhatsApp, Telegram, SQLite | `defineBot`, two providers, store namespaces, stable ids | One bot file serving two channels from one process |

## AI

They use [`@botmesh/ai`](https://botmesh.afaya.com.co/guide/ai) with Anthropic by default; every page shows how to switch to OpenAI, Gemini or a local Ollama model. The API key always comes from an environment variable.

| Example | Level | Tags | Features | What it does |
| - | - | - | - | - |
| [AI FAQ assistant](https://botmesh.afaya.com.co/examples/ai-faq.md) | Beginner | AI, Guardrails | autoresponder, persona, function triggers, `/reset` | Answers shop questions with an LLM, declines anything off-topic and keeps fixed answers out of the model. |
| [AI booking assistant](https://botmesh.afaya.com.co/examples/ai-tools-booking.md) | Intermediate | AI, Tools | tool calling, `confirm: true`, `confirmLines`, `dedupe`, `enum` | Books, lists and cancels appointments through your functions, with a confirmation before each change. |
| [AI answers from your FAQ](https://botmesh.afaya.com.co/examples/ai-rag.md) | Intermediate | AI, RAG | `rag` retriever, `appendSources`, `warmup()` | Answers from a Markdown FAQ, cites the section it used and admits what it does not know. |
| [Streaming AI replies](https://botmesh.afaya.com.co/examples/ai-streaming.md) | Intermediate | AI, Streaming, Telegram | `stream`, drafts / edits / chunks, cost and latency settings | Shows the answer while the model writes it, tuned for cost and latency. |
| [AI router](https://botmesh.afaya.com.co/examples/ai-router.md) | Advanced | AI, Flows | `generate()`, `replyInChat()`, flows, `bot.trigger()` | Classifies free text with the model, runs payments as deterministic flows and leaves chit-chat to the AI. |
| [AI with human escalation](https://botmesh.afaya.com.co/examples/ai-handoff.md) | Advanced | AI, Tools, Handoff | tool calling, `ctx.handoff()`, `bot.resume()`, escape commands | Hands the chat to a person with a summary for the agent, then gets it back with `/bot`. |

## Advanced

| Example | Level | Tags | Features | What you build |
| - | - | - | - | - |
| [WhatsApp Cloud API webhook server](https://botmesh.afaya.com.co/examples/cloud-api-webhook.md) | Advanced | WhatsApp, Cloud API, Webhooks, Security | `@botmesh/meta` webhooks, raw-body signatures, 24-hour window, templates | A `node:http` server for the official Cloud API, with template fallback |
| [Production-ready bot](https://botmesh.afaya.com.co/examples/production-bot.md) | Advanced | Production, Docker, SQLite, Durability | `SQLiteStore`, durability, persistent flows, health and metrics, graceful shutdown, logs | A support bot packaged as a small project with a Dockerfile |
| [Scheduled daily digest](https://botmesh.afaya.com.co/examples/daily-digest.md) | Advanced | Scheduler, Broadcast, Time zones | Durable scheduler, time zones, `bot.broadcast`, `ctx.user` opt-in/out | A digest at 08:00 in the bot's time zone, once per day across restarts |
| [Testing your bot](https://botmesh.afaya.com.co/examples/testing-your-bot.md) | Advanced | Testing, Vitest, Golden transcripts | `createTestBot`, `expectReply`, golden transcripts, replay | A complete Vitest file that records and replays a conversation |
| [Build a plugin: FAQ with tools](https://botmesh.afaya.com.co/examples/faq-plugin.md) | Advanced | Plugins, Dependency injection | `definePlugin`, `install`/`uninstall`, `ctx.onDispose`, `provide` | A reusable FAQ plugin that shares its counters as a tool |

## Feature coverage

Which examples show each main feature. Every example also runs in the
[terminal simulator](https://botmesh.afaya.com.co/guide/dev-simulator.md) and, except the Cloud API webhook
server, on WhatsApp (Baileys) and Telegram with the same bot code.

| Feature | Examples |
| - | - |
| Flows (`flow()` DSL) | [Registration flow](https://botmesh.afaya.com.co/examples/registration-flow.md), [Menu bot](https://botmesh.afaya.com.co/examples/menu-bot.md), [Shopping flow](https://botmesh.afaya.com.co/examples/shopping-flow.md), [Appointment booking](https://botmesh.afaya.com.co/examples/appointment-booking.md), [AI router](https://botmesh.afaya.com.co/examples/ai-router.md), [Testing your bot](https://botmesh.afaya.com.co/examples/testing-your-bot.md), [Cloud API webhook server](https://botmesh.afaya.com.co/examples/cloud-api-webhook.md) |
| Questions, menus and forms (`ask`, `choose`, `form`) | [Registration flow](https://botmesh.afaya.com.co/examples/registration-flow.md), [Menu bot](https://botmesh.afaya.com.co/examples/menu-bot.md), [Shopping flow](https://botmesh.afaya.com.co/examples/shopping-flow.md), [Support with timeout](https://botmesh.afaya.com.co/examples/support-flow.md), [Appointment booking](https://botmesh.afaya.com.co/examples/appointment-booking.md), [Order tracking](https://botmesh.afaya.com.co/examples/order-tracking.md) |
| Triggers and commands | [Greeting bot](https://botmesh.afaya.com.co/examples/greeting-bot.md), [FAQ bot](https://botmesh.afaya.com.co/examples/faq-bot.md), [Send messages](https://botmesh.afaya.com.co/examples/messages.md), [Group bot](https://botmesh.afaya.com.co/examples/group-bot.md), [FAQ plugin](https://botmesh.afaya.com.co/examples/faq-plugin.md) |
| Media (send and receive) | [Media replies](https://botmesh.afaya.com.co/examples/media.md) |
| Polls | [Poll bot](https://botmesh.afaya.com.co/examples/poll-bot.md) |
| Buttons | [Menu bot](https://botmesh.afaya.com.co/examples/menu-bot.md), [AI booking assistant](https://botmesh.afaya.com.co/examples/ai-tools-booking.md) |
| Hooks | [Rate limiter](https://botmesh.afaya.com.co/examples/rate-limiter.md), [Multi-language bot](https://botmesh.afaya.com.co/examples/multi-language.md) |
| Plugins | [Rate limiter](https://botmesh.afaya.com.co/examples/rate-limiter.md), [FAQ plugin](https://botmesh.afaya.com.co/examples/faq-plugin.md) |
| i18n | [Multi-language bot](https://botmesh.afaya.com.co/examples/multi-language.md) |
| User data (`ctx.user`) | [Order tracking](https://botmesh.afaya.com.co/examples/order-tracking.md), [Appointment booking](https://botmesh.afaya.com.co/examples/appointment-booking.md), [Daily digest](https://botmesh.afaya.com.co/examples/daily-digest.md), [WhatsApp and Telegram](https://botmesh.afaya.com.co/examples/whatsapp-and-telegram.md) |
| Human handoff | [Human handoff](https://botmesh.afaya.com.co/examples/human-handoff.md), [AI with human escalation](https://botmesh.afaya.com.co/examples/ai-handoff.md) |
| Groups | [Group bot](https://botmesh.afaya.com.co/examples/group-bot.md) |
| Scheduler | [Reminder bot](https://botmesh.afaya.com.co/examples/reminders.md), [Daily digest](https://botmesh.afaya.com.co/examples/daily-digest.md), [Human handoff](https://botmesh.afaya.com.co/examples/human-handoff.md) |
| Broadcast | [Daily digest](https://botmesh.afaya.com.co/examples/daily-digest.md) |
| Stores | [Appointment booking](https://botmesh.afaya.com.co/examples/appointment-booking.md), [Order tracking](https://botmesh.afaya.com.co/examples/order-tracking.md), [WhatsApp and Telegram](https://botmesh.afaya.com.co/examples/whatsapp-and-telegram.md), [Production-ready bot](https://botmesh.afaya.com.co/examples/production-bot.md), [Daily digest](https://botmesh.afaya.com.co/examples/daily-digest.md) |
| Durability | [Production-ready bot](https://botmesh.afaya.com.co/examples/production-bot.md) |
| Multi-channel (one bot, several providers) | [WhatsApp and Telegram](https://botmesh.afaya.com.co/examples/whatsapp-and-telegram.md) |
| Webhooks and WhatsApp Cloud API | [Cloud API webhook server](https://botmesh.afaya.com.co/examples/cloud-api-webhook.md) |
| Telegram | [WhatsApp and Telegram](https://botmesh.afaya.com.co/examples/whatsapp-and-telegram.md), [Streaming AI replies](https://botmesh.afaya.com.co/examples/ai-streaming.md), [Group bot](https://botmesh.afaya.com.co/examples/group-bot.md), [Multi-language bot](https://botmesh.afaya.com.co/examples/multi-language.md) |
| AI chat | [AI FAQ assistant](https://botmesh.afaya.com.co/examples/ai-faq.md), [AI answers from your FAQ](https://botmesh.afaya.com.co/examples/ai-rag.md), [AI router](https://botmesh.afaya.com.co/examples/ai-router.md) |
| AI tools with confirmation | [AI booking assistant](https://botmesh.afaya.com.co/examples/ai-tools-booking.md), [AI with human escalation](https://botmesh.afaya.com.co/examples/ai-handoff.md) |
| AI chat history and RAG | [AI answers from your FAQ](https://botmesh.afaya.com.co/examples/ai-rag.md), [AI FAQ assistant](https://botmesh.afaya.com.co/examples/ai-faq.md), [AI router](https://botmesh.afaya.com.co/examples/ai-router.md) |
| AI streaming | [Streaming AI replies](https://botmesh.afaya.com.co/examples/ai-streaming.md) |
| Testing | [Testing your bot](https://botmesh.afaya.com.co/examples/testing-your-bot.md), [Streaming AI replies](https://botmesh.afaya.com.co/examples/ai-streaming.md) |
| Terminal simulator (`npx botmesh dev`) | [Greeting bot](https://botmesh.afaya.com.co/examples/greeting-bot.md), [Poll bot](https://botmesh.afaya.com.co/examples/poll-bot.md), [Testing your bot](https://botmesh.afaya.com.co/examples/testing-your-bot.md) |

Apart from the Cloud API webhook server, the bot code of every example is
the same on WhatsApp (Baileys) and Telegram: only the provider changes. Where a channel renders something
differently (buttons, stickers), the example page says so, and the
[capability matrix](https://botmesh.afaya.com.co/guide/channels.md#capability-matrix) lists the details.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.