Skip to content

Latest commit

 

History

History
148 lines (107 loc) · 5.76 KB

README.md

File metadata and controls

148 lines (107 loc) · 5.76 KB

Welcome to @totigm/whatsapp-bot 👋

NPM version GitHub repo Downloads CI GitHub repo stars Documentation License: MIT

📄 Introduction

This is a library to create WhatsApp bots. It is a WhatsApp implementation of the @totigm/bot-builder package, which handles all the commands stuff behind the scenes, so you can focus on your bot's logic.

The whatsapp-web.js library is used for this implementation.

🔗 Quick links

💻 Installation

npm i @totigm/whatsapp-bot

or

yarn add @totigm/whatsapp-bot

🚀 Getting started

You can use this WhatsApp bot template to generate your own. This template has everything set up for you, so you can start coding your bot right away.
The template has TypeScript, Docker, ESLint, and Prettier already configured, so you have a nice developer experience and a production-ready bot.

Start adding commands to your bot by checking the reference documentation.

The WhatsApp bot template and bot examples are also a good reference on how to use this library.

🤖 Example usage

import WhatsappBot from "@totigm/whatsapp-bot";

const bot = new WhatsappBot();

bot.addCommand(
    "hey",
    async (message, client) => {
        const chatId = message.from;
        const contact = await client.getContactById(chatId);

        return `Hey ${contact.pushname}! How are you doing?`;
    },
    {
        description: "Say hey",
        explanation: "The bot will say hey to the user using their WhatsApp's name",
        example: {
            output: "Hey Toti! How are you doing?",
        },
    },
);

The previous code will create a bot that works like this:

bot conversation

🤩 Bot examples

⚙️ Options

When you create a bot, you can pass an options object to customize it. Check its options documentation for more information.

const options = { ... };

const bot = new WhatsappBot(options);

🚀 Deploying

To deploy your WhatsApp bot, check out this template, which creates a Docker image with everything needed for the whatsapp-web.js library to work. This will help you to deploy your bot to the cloud provider of your choice.

This library automatically checks if the app is being run on a Docker container and set its configurations according to that, so you don't have to worry about it.

👤 Author

GitHub: totigm
Twitter: totigm8
LinkedIn: totigm
NPM: totigm

🤝 Contributing

Contributions are more than welcome!

We think that you might have great ideas to make this project even better. If you do, please create a pull request and/or issue following the contribution guidelines.

⭐️ Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 Toti Muñoz.
This project is MIT licensed.


This project was made with ❤ and TypeScript