feat: Add openwa notification (#7555)

This commit is contained in:
Bishwajit Kumar Poddar
2026-08-02 20:25:07 +05:30
committed by GitHub
parent abd0f3270d
commit c155c97534
7 changed files with 165 additions and 0 deletions
+1
View File
@@ -24,3 +24,4 @@ extra/exe-builder/obj
.vs
.vscode
.devcontainer
+60
View File
@@ -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;
+2
View File
@@ -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(),
+1
View File
@@ -247,6 +247,7 @@ export default {
evolution: "WhatsApp (Evolution)",
waha: "WhatsApp (WAHA)",
Whatsapp360messenger: "WhatsApp (360messenger)",
openwa: "WhatsApp (OpenWA)",
};
// Push Services - Push notification services
+91
View File
@@ -0,0 +1,91 @@
<template>
<div class="mb-3">
<label for="openwa-api-url" class="form-label">{{ $t("API URL") }}</label>
<input
id="openwa-api-url"
v-model="$parent.notification.openwaApiUrl"
placeholder="http://localhost:2785/"
type="url"
class="form-control"
required
/>
<div class="form-text">{{ $t("wayToGetOpenwaApiUrl") }}</div>
</div>
<div class="mb-3">
<label for="openwa-api-key" class="form-label">{{ $t("API Key") }}</label>
<HiddenInput
id="openwa-api-key"
v-model="$parent.notification.openwaApiKey"
:required="true"
autocomplete="new-password"
></HiddenInput>
<div class="form-text">{{ $t("wayToGetOpenwaApiKey") }}</div>
</div>
<div class="mb-3">
<label for="openwa-session" class="form-label">{{ $t("openwaSession") }}</label>
<input
id="openwa-session"
v-model="$parent.notification.openwaSession"
type="text"
placeholder="default"
class="form-control"
required
/>
<div class="form-text">{{ $t("wayToGetOpenwaSession") }}</div>
</div>
<div class="mb-3">
<label for="openwa-chat-id" class="form-label">{{ $t("openwaChatId") }}</label>
<input
id="openwa-chat-id"
v-model="$parent.notification.openwaChatId"
type="text"
class="form-control"
required
/>
<div class="form-text">
{{ $t("wayToWriteOpenwaChatId", ["00117612345678@c.us", "123456789012345678@g.us", "1234567890@lid"]) }}
</div>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input v-model="$parent.notification.openwaUseCustomMessage" class="form-check-input" type="checkbox" />
<label class="form-check-label">{{ $t("openwaCustomMessageTitle") }}</label>
</div>
<div class="form-text">{{ $t("openwaCustomMessageDesc") }}</div>
</div>
<template v-if="$parent.notification.openwaUseCustomMessage">
<div class="mb-3">
<TemplatedTextarea
id="openwa-custom-message"
v-model="$parent.notification.openwaCustomMessage"
:required="true"
:placeholder="customMessagePlaceholder"
></TemplatedTextarea>
</div>
</template>
<i18n-t tag="div" keypath="More info on:" class="mb-3 form-text">
<a href="https://www.open-wa.org/" target="_blank">https://www.open-wa.org/</a>
</i18n-t>
</template>
<script>
import HiddenInput from "../HiddenInput.vue";
import TemplatedTextarea from "../TemplatedTextarea.vue";
export default {
components: {
HiddenInput,
TemplatedTextarea,
},
computed: {
customMessagePlaceholder() {
return this.$t("Example:", [`[{{ name }}] [{{ status }}]\n{{ msg }}`]);
},
},
};
</script>
+2
View File
@@ -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,
+8
View File
@@ -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",