Add WhatsApp (WAHA) notification provider (#5647)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
This commit is contained in:
devlikeapro
2025-03-18 19:06:43 +07:00
committed by GitHub
parent 9857770cc7
commit 6f8f8f955f
6 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class WAHA extends NotificationProvider {
name = "waha";
/**
* @inheritdoc
*/
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
try {
const config = {
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"X-Api-Key": notification.wahaApiKey,
}
};
let data = {
"session": notification.wahaSession,
"chatId": notification.wahaChatId,
"text": msg,
};
let url = notification.wahaApiUrl.replace(/([^/])\/+$/, "$1") + "/api/sendText";
await axios.post(url, data, config);
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = WAHA;

View File

@@ -64,6 +64,7 @@ const ServerChan = require("./notification-providers/serverchan");
const ZohoCliq = require("./notification-providers/zoho-cliq");
const SevenIO = require("./notification-providers/sevenio");
const Whapi = require("./notification-providers/whapi");
const WAHA = require("./notification-providers/waha");
const GtxMessaging = require("./notification-providers/gtx-messaging");
const Cellsynt = require("./notification-providers/cellsynt");
const Onesender = require("./notification-providers/onesender");
@@ -152,6 +153,7 @@ class Notification {
new ZohoCliq(),
new SevenIO(),
new Whapi(),
new WAHA(),
new GtxMessaging(),
new Cellsynt(),
new Wpush(),