WhatsApp Bot Boilerplate

Role / Services

Chatbot & Server Development

Credits

Opensource Project

Location / Year

Indonesia, 2024

The WhatsApp Bot Boilerplate is a TypeScript-based framework designed to simplify the development of robust and scalable WhatsApp bots. Leveraging modern tools like Bun for runtime efficiency and integrations with AI agents, this project provides a modular foundation for creating feature-rich chatbots. It’s built with developer productivity in mind, offering a clean structure, hot-reloading, and seamless database connectivity.

Build With

TypeScript

Nodejs

Bun

Gemini

Gemini

Groq

Upstash Redis

Supabase

Key Features

WhatsApp Web Integration

Powered by @whiskeysockets/baileys for reliable WhatsApp Web API support.

AI-Driven Interactions

Supports advanced AI integrations with Google Gemini and Groq AI via Vercel AI SDK.

Modular Design

Organized codebase with command modules and utility functions for easy customization.

Database Connectivity

Integrates with Upstash Redis for state management and Supabase for persistent storage.

Optimized Performance

Uses Bun for a lightweight, high-speed runtime with hot-reloading for rapid development.

Extensible Commands

Simplifies adding new features with a flexible command module system.

Why This Project?

This boilerplate was developed to address the need for a scalable and maintainable WhatsApp bot framework. By combining TypeScript’s type safety with modern tools like Bun and Vercel AI SDK, it enables developers to create bots that are both powerful and easy to extend. The project’s modular architecture ensures that new features, such as custom commands or AI integrations, can be added without disrupting existing functionality.

Technical Highlights

TypeScript

Ensures type-safe code for better reliability and maintainability.

Bun Runtime

Delivers faster startup and execution compared to traditional Node.js environments.

Database Support

Combines Upstash Redis for real-time state management and Supabase for file and data storage.

Command System

Features a robust type system for command handling, including aliases, permissions, and cooldowns.

Important Note on Usage

This boilerplate utilizes the @whiskeysockets/baileys library, which is a third-party implementation and not an official WhatsApp or Meta library. As such, it is not endorsed or supported by WhatsApp or Meta. Users should exercise discretion when using this boilerplate, as there may be risks associated with using unofficial APIs, including potential account restrictions or other unforeseen side effects. The developer of this boilerplate does not guarantee the safety or reliability of the @whiskeysockets/baileys library and is not responsible for any consequences arising from its use. Please proceed with caution and review WhatsApp’s terms of service before deploying bots built with this framework.

Getting Started

To use the boilerplate, developers need only a WhatsApp account, Bun, and access to Upstash Redis and Supabase. After cloning the repository and configuring environment variables, the bot can be launched in development mode with a single command:

Start Application|bash
1bun run dev

New commands can be added by creating TypeScript files in the commands/ directory, making it easy to extend functionality.

Example Use Case

One of the standout features is the command module system. For instance, the included ping command measures bot responsiveness by calculating the latency between a user’s message and the bot’s reply. This diagnostic tool showcases the boilerplate’s ability to handle real-time interactions efficiently.

@/command/ping.ts|typescript
1import moment from "moment";
2import type { CommandModule } from "@/lib/types/wabot.types";
3
4export default {
5  aliases: ["ping", "pong"],
6  callback: async ({ message, msg }) => {
7    if (message.messageTimestamp) {
8      const value = JSON.stringify(
9        {
10          ping: `*_${moment
11            .duration(
12              Date.now() -
13                parseInt(message?.messageTimestamp?.toString()) * 1000
14            )
15            .asSeconds()} second(s)_*`,
16          raw: message?.messageTimestamp?.toString(),
17        },
18        null,
19        2
20      );
21      return msg.reply(value, true);
22    }
23  },
24} satisfies CommandModule;

Future Potential

This boilerplate is designed with growth in mind. Future enhancements could include:

Expanded AI agent integrations for more advanced conversational capabilities.

Enhanced logging and debugging tools for better monitoring.

Comprehensive guides for advanced customization and deployment.

Conclusion

The WhatsApp Bot Boilerplate is a versatile starting point for developers looking to build sophisticated WhatsApp bots. Its combination of modern tooling, modular design, and AI integrations makes it an ideal choice for projects requiring scalability and performance. This project demonstrates my ability to create well-structured, production-ready frameworks that balance simplicity with advanced functionality.

Explore the project on Github repository and start building your own WhatsApp bot today.

Socials

Version

Portfolio 2025

Local Time (Jakarta)

GMT+7