
Security News
Scaling Socket from Zero to 10,000+ Organizations
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.
@basisapi/whatsapp-bot
Advanced tools
The WhatsApp chat bot designed for writing own chat bots. Users can interact with bots by sending them command messages in private or group chats. The bot uses Green-API (basis-api.com) provider WhatsApp API protocol under hood to support WhatsApp. requires plugged and active phone. The protocol provides reach WhatsApp API including messages, media, phone state, location etc. Have look at whatsapp-api-client wrapper REST protocol library for more information
npm i @basisapi/whatsapp-bot
To use the WhatsApp Bot API, you first have to visit basis-api.com and get free developer account for API. BASIS Api will give you id instance and api token, something like
HOST: https://en-api.basis-api.com
ID_INSTANCE: "0000",
API_TOKEN_INSTANCE: "000000000000000000AAAAAAAAAAAAAA"
In case you want API-V1 protocol you also have to visit basis-api.com and choose Chat bot price option. BASIS API will give you a free trial period if you ask them. Access token looks like this:
token = 'gr.abcdefg...'
You can import library using modern ES6 syntax (you have to add "type":"module" to package.json):
import WhatsAppBot from '@basisapi/whatsapp-bot'
or using classic syntax:
const WhatsAppBot = require('@basisapi/whatsapp-bot')
For API-V0 protocol
const bot = new WhatsAppBot({
host: https://en-api.basis-api.com
idInstance: "0000",
apiTokenInstance: "000000000000000000AAAAAAAAAAAAAA"
})
### 3. Start coding
A WhatsApp bot was inpired by telegram bot framework - [Telegraf](https://telegraf.js.org). But the WhatsApp bot library inherited limited part of Telegraf API. At this moment whatsapp bot can send and receive text, interact with user by telegraf scenes and use sessions. The bot supports only long-polling mode. To understand basics have look at examples below.
### Examples
Hello world example responds with a plain text phrase to any users print:
```js
const WhatsAppBot = require('@basisapi/whatsapp-bot')
const bot = new WhatsAppBot({
host: https://en-api.basis-api.com
idInstance: process.env.ID_INSTANCE,
apiTokenInstance: process.env.API_TOKEN_INSTANCE
})
bot.on('message', (ctx) => ctx.reply('Hello world!'))
bot.launch()
Bot listens for users command beginning with the / symbol
const WhatsAppBot = require('@basisapi/whatsapp-bot')
const bot = new WhatsAppBot({
idInstance: process.env.ID_INSTANCE,
apiTokenInstance: process.env.API_TOKEN_INSTANCE
})
bot.command('oldschool', (ctx) => ctx.reply('Hello'))
bot.command('modern', ({ reply }) => reply('Yo'))
bot.command('hipster', WhatsAppBot.reply('λ'))
bot.on('message', (ctx) => ctx.reply('Send /oldschool, /modern or /hipster to launch bot'))
bot.launch()
Licensed on MIT terms. For additional info have look at LICENSE
FAQs
WhatsApp Bot for NodeJs
The npm package @basisapi/whatsapp-bot receives a total of 0 weekly downloads. As such, @basisapi/whatsapp-bot popularity was classified as not popular.
We found that @basisapi/whatsapp-bot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh shares lessons from scaling a developer security startup to 10,000+ organizations in this founder interview.

Research
Socket Threat Research maps a rare inside look at OtterCookie’s npm-Vercel-GitHub chain, adding 197 malicious packages and evidence of North Korean operators.

Research
Socket researchers identified a malicious Chrome extension that manipulates Raydium swaps to inject an undisclosed SOL transfer, quietly routing fees to an attacker wallet.