Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
whatsapp-chapi
Advanced tools
Use this library to develop a bot for the WhatsApp platform. The library is available on GitHub as well as a package on npm.
This library is released under the terms of the Apache 2.0 license. See License for more information.
This library is released on npm.
Install with npm install whatsapp-chapi --save
If you are already using express or equivalent, you can do the following:
app.use("/whatsapp/webhook", bot.middleware());
Please revisit app.use() documentation. For more information see bot.middleware().
Creating a basic WhatsApp bot is simple:
whatsapp-chapi
library to your projectsetWebhook(url)
with your web server urlFirstly, let's import and configure our bot:
'use strict';
var express = require('express');
const Chapi = require('whatsapp-chapi');
const app = express();
const bot = new Chapi(YOUR_INSTANCE_ID_HERE, YOUR_AUTH_TOKEN_HERE);
bot.signIn('YOUR_WHATSAPP_ACCOUNT_PHONE');
app.post('/YOUR_WEBHOOK_HERE', function (req, res) {
bot.sendMessage(req.body.messages[0].author, 'ECHO TEXT');
res.sendStatus(200);
});
// Wasn't that easy? Let's create HTTPS server and set the webhook:
const http = require('http');
const port = process.env.PORT || 8080;
// Chapi will push messages sent to this URL. Web server should be internet-facing.
const webhookUrl = process.env.WEBHOOK_URL;
http.createServer(app).listen(port, () => bot.setWebhook(webhookUrl));
Param | Type | Description |
---|---|---|
url | string | Full url to your endpoint for message notification |
Returns a promise.JSON
.
bot.setWebhook("https://my.bot/incoming").then(() => yourBot.doSomething()).catch(err => console.log(err));
Param | Type | Description |
---|---|---|
phone | string | Your whatsApp account phone |
Returns a promise.JSON
.
bot.signIn("12345678911").then(() => yourBot.doSomething()).catch(err => console.log(err));
Note: Phone number should be in following format 12345678912
, without +
or any other symbols
Param | Type | Description |
---|---|---|
phone | string | WhatsAppPhoneNumber string |
message | string | text message to send |
Note: Phone number should be in following format 12345678912
, without +
or any other symbols
Returns a promise.JSON
.
// Single message
const Chapi = require('whatsapp-chapi');
const bot = new Chapi(YOUR_INSTANCE_ID_HERE, YOUR_AUTH_TOKEN_HERE);
bot.sendMessage('12345678912', 'Hello');
Param | Type | Description |
---|---|---|
phone | string | WhatsAppPhoneNumber string |
url | string | download url for file |
Returns a promise.JSON
.
// File message
const Chapi = require('whatsapp-chapi');
const bot = new Chapi(YOUR_INSTANCE_ID_HERE, YOUR_AUTH_TOKEN_HERE);
bot.sendFile('12345678912', 'https://assets.fireside.fm/file/fireside-images/podcasts/images/b/bc7f1faf-8aad-4135-bb12-83a8af679756/cover_medium.jpg');
TODO.
FAQs
WhatsApp chat api
The npm package whatsapp-chapi receives a total of 12 weekly downloads. As such, whatsapp-chapi popularity was classified as not popular.
We found that whatsapp-chapi 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.