Installation
Install and configure the Bots package in your Igniter.js application.
Prerequisites
Before installing the Bots package, make sure you have:
- Node.js 18.0+ installed
- An existing Igniter.js application (see Installation guides)
- Basic understanding of TypeScript
- Access to messaging platform APIs (Telegram Bot API, WhatsApp Cloud API, etc.)
Installation
Install the Bots package using your preferred package manager:
npm install @igniter-js/botpnpm add @igniter-js/botyarn add @igniter-js/botbun add @igniter-js/botPeer requirements: TypeScript >= 5.x
Platform-Specific Setup
Depending on which messaging platforms you want to support, you'll need to set up their APIs. Each platform has its own requirements and setup process. Expand the accordion below for the platform you're using:
Project Structure
After installation, you'll typically organize your bot code like this. The example below shows a Next.js App Router structure, but the Bots package works with any backend framework that can handle HTTP requests and responses:
Framework Compatibility
The Bots package is framework-agnostic. While this example uses Next.js App Router, you can use it with Express, Fastify, Hono, or any other framework that accepts Request and returns Response objects. The webhook handler pattern adapts to your framework's routing system.
Key Organization Tips:
- Commands: Use
Bot.command()to create commands in separate files (src/bot/commands/) - Middleware: Use
Bot.middleware()to create middleware in separate files (src/bot/middleware/) - Storage: Keep shared state or database access in a dedicated module (
src/bot/storage/) - Handlers: Event handlers can be organized separately (
src/bot/handlers/)
This structure keeps your bot code organized and maintainable as it grows.