Skip to content

How to import the library and initiate your bot#

Installation#

npm i @green-api/whatsapp-bot

You can create an instance in your personal account using link. Click create and select a tariff. To start receiving incoming notifications, you need to configure your instance. Open your personal account page via link. Select an instance from the list and click on it. Click Change. In Notifications category includes all webhooks that need to be received.

How to initialize an object#

To initiate a bot, you need to use the WhatsAppBot constructor from the library and specify the instance number and token from your personal account.

const WhatsAppBot = require('@green-api/whatsapp-bot')

const bot = new WhatsAppBot({
     idInstance: "{{INSTANCE_ID}}",
     apiTokenInstance: "{{TOKEN}}",
})

List of examples#

Description Link to example
How to initialize a handler hello-bot.js
Scene "Echo" echo-bot.js
How to filter by notification type media-bot.js
How to filter by message text filter-bot.js
How to work with bot state state-bot.js
Example of a ready-made chat bot demo-bot