diff --git a/server/notification-providers/waha.js b/server/notification-providers/waha.js new file mode 100644 index 000000000..b075f33f0 --- /dev/null +++ b/server/notification-providers/waha.js @@ -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; diff --git a/server/notification.js b/server/notification.js index 7ed62ffec..a77094ac9 100644 --- a/server/notification.js +++ b/server/notification.js @@ -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(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 8a2c6269d..561637ec0 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -163,6 +163,7 @@ export default { "ZohoCliq": "ZohoCliq", "SevenIO": "SevenIO", "whapi": "WhatsApp (Whapi)", + "waha": "WhatsApp (WAHA)", "gtxmessaging": "GtxMessaging", "Cellsynt": "Cellsynt", "SendGrid": "SendGrid" diff --git a/src/components/notifications/WAHA.vue b/src/components/notifications/WAHA.vue new file mode 100644 index 000000000..476d8e698 --- /dev/null +++ b/src/components/notifications/WAHA.vue @@ -0,0 +1,38 @@ + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 3bf9affd3..c1162da92 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -63,6 +63,7 @@ import ZohoCliq from "./ZohoCliq.vue"; import Splunk from "./Splunk.vue"; import SevenIO from "./SevenIO.vue"; import Whapi from "./Whapi.vue"; +import WAHA from "./WAHA.vue"; import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import SIGNL4 from "./SIGNL4.vue"; @@ -139,6 +140,7 @@ const NotificationFormList = { "ZohoCliq": ZohoCliq, "SevenIO": SevenIO, "whapi": Whapi, + "waha": WAHA, "gtxmessaging": GtxMessaging, "Cellsynt": Cellsynt, "WPush": WPush, diff --git a/src/lang/en.json b/src/lang/en.json index 118dd7fc8..c0bf639c8 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1055,6 +1055,12 @@ "rabbitmqHelpText": "To use the monitor, you will need to enable the Management Plugin in your RabbitMQ setup. For more information, please consult the {rabitmq_documentation}.", "SendGrid API Key": "SendGrid API Key", "Separate multiple email addresses with commas": "Separate multiple email addresses with commas", + "wahaSession": "Session", + "wahaChatId": "Chat ID (Phone Number / Contact ID / Group ID)", + "wayToGetWahaApiUrl": "Your WAHA Instance URL.", + "wayToGetWahaApiKey": "API Key is WHATSAPP_API_KEY environment variable value you used to run WAHA.", + "wayToGetWahaSession": "From this session WAHA sends notifications to Chat ID. You can find it in WAHA Dashboard.", + "wayToWriteWahaChatId": "The phone number with the international prefix, but without the plus sign at the start ({0}), the Contact ID ({1}) or the Group ID ({2}). Notifications are sent to this Chat ID from WAHA Session.", "YZJ Webhook URL": "YZJ Webhook URL", "YZJ Robot Token": "YZJ Robot token", "Plain Text": "Plain Text",