diff --git a/server/notification-providers/evolution.js b/server/notification-providers/evolution.js new file mode 100644 index 000000000..72ccf57c0 --- /dev/null +++ b/server/notification-providers/evolution.js @@ -0,0 +1,39 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Evolution extends NotificationProvider { + name = "evolution"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + const config = { + headers: { + "Accept": "application/json", + "Content-Type": "application/json", + "apikey": notification.evolutionAuthToken, + } + }; + + let data = { + "number": notification.evolutionRecipient, + "text": msg, + }; + + let url = (notification.evolutionApiUrl || "https://evolapicloud.com/").replace(/([^/])\/+$/, "$1") + "/message/sendText/" + encodeURIComponent(notification.evolutionInstanceName); + + await axios.post(url, data, config); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } + +} + +module.exports = Evolution; diff --git a/server/notification.js b/server/notification.js index fd8c23d67..36bfdfc29 100644 --- a/server/notification.js +++ b/server/notification.js @@ -69,6 +69,7 @@ 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 Evolution = require("./notification-providers/evolution"); const GtxMessaging = require("./notification-providers/gtx-messaging"); const Cellsynt = require("./notification-providers/cellsynt"); const Onesender = require("./notification-providers/onesender"); @@ -163,6 +164,7 @@ class Notification { new SevenIO(), new Whapi(), new WAHA(), + new Evolution(), new GtxMessaging(), new Cellsynt(), new Wpush(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index acfcde6a2..b9b2b65d2 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -165,6 +165,7 @@ export default { "ZohoCliq": "ZohoCliq", "SevenIO": "SevenIO", "whapi": "WhatsApp (Whapi)", + "evolution": "WhatsApp (Evolution)", "waha": "WhatsApp (WAHA)", "gtxmessaging": "GtxMessaging", "Cellsynt": "Cellsynt", diff --git a/src/components/notifications/Evolution.vue b/src/components/notifications/Evolution.vue new file mode 100644 index 000000000..3d340b8b1 --- /dev/null +++ b/src/components/notifications/Evolution.vue @@ -0,0 +1,39 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 933139a4a..300bbc755 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -69,6 +69,7 @@ import SpugPush from "./SpugPush.vue"; import SevenIO from "./SevenIO.vue"; import Whapi from "./Whapi.vue"; import WAHA from "./WAHA.vue"; +import Evolution from "./Evolution.vue"; import Cellsynt from "./Cellsynt.vue"; import WPush from "./WPush.vue"; import SIGNL4 from "./SIGNL4.vue"; @@ -150,6 +151,7 @@ const NotificationFormList = { "ZohoCliq": ZohoCliq, "SevenIO": SevenIO, "whapi": Whapi, + "evolution": Evolution, "notifery": Notifery, "waha": WAHA, "gtxmessaging": GtxMessaging, diff --git a/src/lang/en.json b/src/lang/en.json index e75e062c4..2f5249fe8 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -973,6 +973,10 @@ "wayToGetWhapiUrlAndToken": "You can get the API URL and the token by going into your desired channel from {0}", "whapiRecipient": "Phone Number / Contact ID / Group ID", "API URL": "API URL", + "wayToWriteEvolutionRecipient": "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}).", + "wayToGetEvolutionUrlAndToken": "You can get the API URL and the token by going into your desired channel from {0}", + "evolutionRecipient": "Phone Number / Contact ID / Group ID", + "evolutionInstanceName": "Instance Name", "What is a Remote Browser?": "What is a Remote Browser?", "wayToGetHeiiOnCallDetails": "How to get the Trigger ID and API Keys is explained in the {documentation}", "documentationOf": "{0} Documentation",