From c155c975346c86ec719c29796e66c44f23841a51 Mon Sep 17 00:00:00 2001 From: Bishwajit Kumar Poddar <78581592+ron007d@users.noreply.github.com> Date: Sun, 2 Aug 2026 20:25:07 +0530 Subject: [PATCH] feat: Add openwa notification (#7555) --- .gitignore | 1 + server/notification-providers/openwa.js | 60 ++++++++++++++++ server/notification.js | 2 + src/components/NotificationDialog.vue | 1 + src/components/notifications/OpenWa.vue | 91 +++++++++++++++++++++++++ src/components/notifications/index.js | 2 + src/lang/en.json | 8 +++ 7 files changed, 165 insertions(+) create mode 100644 server/notification-providers/openwa.js create mode 100644 src/components/notifications/OpenWa.vue diff --git a/.gitignore b/.gitignore index b11a79354..1dcaa2d64 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ extra/exe-builder/obj .vs .vscode +.devcontainer diff --git a/server/notification-providers/openwa.js b/server/notification-providers/openwa.js new file mode 100644 index 000000000..3856efe2f --- /dev/null +++ b/server/notification-providers/openwa.js @@ -0,0 +1,60 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class OpenWa extends NotificationProvider { + name = "openwa"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let text = msg; + const customMessage = notification.openwaCustomMessage; + if (notification.openwaUseCustomMessage && typeof customMessage === "string" && customMessage.trim()) { + text = await this.renderTemplate(customMessage, msg, monitorJSON, heartbeatJSON); + } + + let config = { + headers: { + Accept: "application/json", + "Content-Type": "application/json", + "X-Api-Key": notification.openwaApiKey, + }, + }; + config = this.getAxiosConfigWithProxy(config); + + const chatIds = (notification.openwaChatId || "") + .split(",") + .map((id) => id.trim()) + .filter((id) => id.length > 0); + + if (chatIds.length === 0) { + throw new Error("No valid OpenWA chat ID found."); + } + + const baseUrl = notification.openwaApiUrl.replace(/([^/])\/+$/, "$1"); + const sessionId = encodeURIComponent(notification.openwaSession); + const url = `${baseUrl}/api/sessions/${sessionId}/messages/send-text`; + + for (const chatId of chatIds) { + await axios.post( + url, + { + chatId, + text, + }, + config + ); + } + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = OpenWa; diff --git a/server/notification.js b/server/notification.js index be47cd3c5..80c8a0ffa 100644 --- a/server/notification.js +++ b/server/notification.js @@ -81,6 +81,7 @@ const SevenIO = require("./notification-providers/sevenio"); const Whapi = require("./notification-providers/whapi"); const WAHA = require("./notification-providers/waha"); const Evolution = require("./notification-providers/evolution"); +const OpenWa = require("./notification-providers/openwa"); const GtxMessaging = require("./notification-providers/gtx-messaging"); const Cellsynt = require("./notification-providers/cellsynt"); const Onesender = require("./notification-providers/onesender"); @@ -197,6 +198,7 @@ class Notification { new Whapi(), new WAHA(), new Evolution(), + new OpenWa(), new GtxMessaging(), new Cellsynt(), new Wpush(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 67b106bbe..7b6caa1b6 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -247,6 +247,7 @@ export default { evolution: "WhatsApp (Evolution)", waha: "WhatsApp (WAHA)", Whatsapp360messenger: "WhatsApp (360messenger)", + openwa: "WhatsApp (OpenWA)", }; // Push Services - Push notification services diff --git a/src/components/notifications/OpenWa.vue b/src/components/notifications/OpenWa.vue new file mode 100644 index 000000000..19813535f --- /dev/null +++ b/src/components/notifications/OpenWa.vue @@ -0,0 +1,91 @@ + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 9de95b8bf..7ef39764b 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -82,6 +82,7 @@ import Whapi from "./Whapi.vue"; import WAHA from "./WAHA.vue"; import Whatsapp360messenger from "./360messenger.vue"; import Evolution from "./Evolution.vue"; +import OpenWa from "./OpenWa.vue"; import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import WxPusher from "./WxPusher.vue"; @@ -185,6 +186,7 @@ const NotificationFormList = { SevenIO: SevenIO, whapi: Whapi, evolution: Evolution, + openwa: OpenWa, notifery: Notifery, waha: WAHA, Whatsapp360messenger: Whatsapp360messenger, diff --git a/src/lang/en.json b/src/lang/en.json index 6782382cf..ccafea037 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1377,6 +1377,14 @@ "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.", + "openwaSession": "Session", + "openwaChatId": "Chat ID (Phone Number / Contact ID / Group ID)", + "wayToGetOpenwaApiUrl": "Your OpenWA Instance URL.", + "wayToGetOpenwaApiKey": "API key used for your OpenWA instance.", + "wayToGetOpenwaSession": "Session ID used by OpenWA to send notifications.", + "wayToWriteOpenwaChatId": "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}). You can send to multiple Chat IDs by separating them with commas.", + "openwaCustomMessageTitle": "Custom Message (optional)", + "openwaCustomMessageDesc": "Leave empty to use the default message.", "360messengerAuthToken": "360messenger API Key", "360messengerRecipient": "Recipient phone number(s)", "360messengerGroupId": "360messenger Group ID",