diff --git a/server/notification-providers/plivo.js b/server/notification-providers/plivo.js new file mode 100644 index 000000000..79be359b8 --- /dev/null +++ b/server/notification-providers/plivo.js @@ -0,0 +1,39 @@ +const NotificationProvider = require("./notification-provider"); +const axios = require("axios"); + +class Plivo extends NotificationProvider { + name = "plivo"; + + /** + * @inheritdoc + */ + async send(notification, msg, monitorJSON = null, heartbeatJSON = null) { + const okMsg = "Sent Successfully."; + + try { + let config = { + headers: { + "Content-Type": "application/json", + Authorization: + "Basic " + + Buffer.from(notification.plivoAuthID + ":" + notification.plivoAuthToken).toString("base64"), + }, + }; + config = this.getAxiosConfigWithProxy(config); + + const data = { + src: notification.plivoFromNumber, + dst: notification.plivoToNumber, + text: msg, + }; + + await axios.post(`https://api.plivo.com/v1/Account/${notification.plivoAuthID}/Message/`, data, config); + + return okMsg; + } catch (error) { + this.throwGeneralAxiosError(error); + } + } +} + +module.exports = Plivo; diff --git a/server/notification.js b/server/notification.js index fb8a1bebc..13e333e80 100644 --- a/server/notification.js +++ b/server/notification.js @@ -45,6 +45,7 @@ const Pumble = require("./notification-providers/pumble"); const FlashDuty = require("./notification-providers/flashduty"); const Flowtriq = require("./notification-providers/flowtriq"); const PagerTree = require("./notification-providers/pagertree"); +const Plivo = require("./notification-providers/plivo"); const PromoSMS = require("./notification-providers/promosms"); const Pushbullet = require("./notification-providers/pushbullet"); const PushDeer = require("./notification-providers/pushdeer"); @@ -158,6 +159,7 @@ class Notification { new FlashDuty(), new Flowtriq(), new PagerTree(), + new Plivo(), new PromoSMS(), new Pumble(), new Pushbullet(), diff --git a/src/components/NotificationDialog.vue b/src/components/NotificationDialog.vue index 57ae408f8..e602e9da1 100644 --- a/src/components/NotificationDialog.vue +++ b/src/components/NotificationDialog.vue @@ -272,6 +272,7 @@ export default { gtxmessaging: "GtxMessaging", octopush: "Octopush", Onesender: "Onesender", + plivo: "Plivo", SevenIO: "SevenIO", SMSEagle: "SMSEagle", SMSPartner: "SMS Partner", diff --git a/src/components/notifications/Plivo.vue b/src/components/notifications/Plivo.vue new file mode 100644 index 000000000..bd1b97e3d --- /dev/null +++ b/src/components/notifications/Plivo.vue @@ -0,0 +1,68 @@ + + + diff --git a/src/components/notifications/index.js b/src/components/notifications/index.js index 6f7f31a48..5de8b8461 100644 --- a/src/components/notifications/index.js +++ b/src/components/notifications/index.js @@ -44,6 +44,7 @@ import PagerDuty from "./PagerDuty.vue"; import FlashDuty from "./FlashDuty.vue"; import Flowtriq from "./Flowtriq.vue"; import PagerTree from "./PagerTree.vue"; +import Plivo from "./Plivo.vue"; import PromoSMS from "./PromoSMS.vue"; import Pumble from "./Pumble.vue"; import Pushbullet from "./Pushbullet.vue"; @@ -146,6 +147,7 @@ const NotificationFormList = { FlashDuty: FlashDuty, Flowtriq: Flowtriq, PagerTree: PagerTree, + plivo: Plivo, promosms: PromoSMS, pumble: Pumble, pushbullet: Pushbullet, diff --git a/src/lang/en.json b/src/lang/en.json index e45502382..6c05e9274 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1048,6 +1048,14 @@ "telnyxToNumberHelptext": "The destination phone number to receive SMS notifications (e.g. +15559876543)", "telnyxMessagingProfileId": "Messaging Profile ID (optional)", "telnyxMessagingProfileIdHelptext": "Optionally associate a Telnyx Messaging Profile to control sender settings and features", + "plivoAuthID": "Auth ID", + "plivoAuthIDHelptext": "Your Plivo Auth ID from the Plivo Console", + "plivoAuthToken": "Auth Token", + "plivoAuthTokenHelptext": "Your Plivo Auth Token from the Plivo Console", + "plivoFromNumber": "From Number", + "plivoFromNumberHelptext": "The Plivo phone number or sender ID to send from (e.g. +15551234567)", + "plivoToNumber": "To Number", + "plivoToNumberHelptext": "The destination phone number to receive SMS notifications (e.g. +15559876543)", "twilioAccountSID": "Account SID", "twilioApiKey": "Api Key (optional)", "twilioApiKeyHelptext": "The API key is optional but recommended. You can provide either Account SID and AuthToken from the may TwilioConsole page or Account SID and the pair of Api Key and Api Key secret",