feat: add voice call option to Plivo notification provider (#7597)

Signed-off-by: sarveshpatil-plivo <sarvesh.patil@plivo.com>
This commit is contained in:
Sarvesh Patil
2026-07-15 15:44:37 +05:30
committed by GitHub
parent 590f90e3f9
commit 937bfa38af
3 changed files with 60 additions and 9 deletions
+20 -6
View File
@@ -18,16 +18,30 @@ class Plivo extends NotificationProvider {
"Basic " + "Basic " +
Buffer.from(notification.plivoAuthID + ":" + notification.plivoAuthToken).toString("base64"), Buffer.from(notification.plivoAuthID + ":" + notification.plivoAuthToken).toString("base64"),
}, },
timeout: 10000,
}; };
config = this.getAxiosConfigWithProxy(config); config = this.getAxiosConfigWithProxy(config);
const data = { const baseURL = `https://api.plivo.com/v1/Account/${notification.plivoAuthID}`;
src: notification.plivoFromNumber,
dst: notification.plivoToNumber,
text: msg,
};
await axios.post(`https://api.plivo.com/v1/Account/${notification.plivoAuthID}/Message/`, data, config); if (notification.plivoMessageType === "call") {
const answerUrl = new URL(notification.plivoAnswerUrl);
answerUrl.searchParams.set("message", msg);
const data = {
from: notification.plivoFromNumber,
to: notification.plivoToNumber,
answer_url: answerUrl.toString(),
answer_method: "GET",
};
await axios.post(`${baseURL}/Call/`, data, config);
} else {
const data = {
src: notification.plivoFromNumber,
dst: notification.plivoToNumber,
text: msg,
};
await axios.post(`${baseURL}/Message/`, data, config);
}
return okMsg; return okMsg;
} catch (error) { } catch (error) {
+34 -1
View File
@@ -48,9 +48,37 @@
<div class="form-text">{{ $t("plivoToNumberHelptext") }}</div> <div class="form-text">{{ $t("plivoToNumberHelptext") }}</div>
</div> </div>
<div class="mb-3">
<label for="plivo-message-type" class="form-label">{{ $t("plivoMessageType") }}</label>
<select id="plivo-message-type" v-model="$parent.notification.plivoMessageType" class="form-select">
<option value="sms">SMS</option>
<option value="call">{{ $t("plivoVoiceCall") }}</option>
</select>
</div>
<div v-if="$parent.notification.plivoMessageType === 'call'" class="mb-3">
<label for="plivo-answer-url" class="form-label">{{ $t("plivoAnswerUrl") }}</label>
<input
id="plivo-answer-url"
v-model="$parent.notification.plivoAnswerUrl"
type="url"
class="form-control"
placeholder="https://example.com/answer.xml"
:required="true"
/>
<div class="form-text">{{ $t("plivoAnswerUrlHelptext") }}</div>
</div>
<div class="mb-3"> <div class="mb-3">
<i18n-t tag="p" keypath="More info on:" style="margin-top: 8px"> <i18n-t tag="p" keypath="More info on:" style="margin-top: 8px">
<a href="https://www.plivo.com/docs/messaging/api/message" target="_blank"> <a
v-if="$parent.notification.plivoMessageType === 'call'"
href="https://www.plivo.com/docs/voice/api/call"
target="_blank"
>
https://www.plivo.com/docs/voice/api/call
</a>
<a v-else href="https://www.plivo.com/docs/messaging/api/message" target="_blank">
https://www.plivo.com/docs/messaging/api/message https://www.plivo.com/docs/messaging/api/message
</a> </a>
</i18n-t> </i18n-t>
@@ -64,5 +92,10 @@ export default {
components: { components: {
HiddenInput, HiddenInput,
}, },
mounted() {
if (typeof this.$parent.notification.plivoMessageType === "undefined") {
this.$parent.notification.plivoMessageType = "sms";
}
},
}; };
</script> </script>
+6 -2
View File
@@ -1053,9 +1053,13 @@
"plivoAuthToken": "Auth Token", "plivoAuthToken": "Auth Token",
"plivoAuthTokenHelptext": "Your Plivo Auth Token from the Plivo Console", "plivoAuthTokenHelptext": "Your Plivo Auth Token from the Plivo Console",
"plivoFromNumber": "From Number", "plivoFromNumber": "From Number",
"plivoFromNumberHelptext": "The Plivo phone number or sender ID to send from (e.g. +15551234567)", "plivoFromNumberHelptext": "The Plivo phone number to send from (e.g. +15551234567). SMS may also use an approved alphanumeric sender ID; voice calls require a Plivo phone number.",
"plivoToNumber": "To Number", "plivoToNumber": "To Number",
"plivoToNumberHelptext": "The destination phone number to receive SMS notifications (e.g. +15559876543)", "plivoToNumberHelptext": "The destination phone number that receives the SMS or voice call (e.g. +15559876543)",
"plivoMessageType": "Message Type",
"plivoVoiceCall": "Voice Call",
"plivoAnswerUrl": "Answer URL",
"plivoAnswerUrlHelptext": "URL that returns Plivo XML for the call. The alert text is appended as a ?message= query parameter, so your endpoint can return e.g. <Response><Speak>{message}</Speak></Response>.",
"twilioAccountSID": "Account SID", "twilioAccountSID": "Account SID",
"twilioApiKey": "Api Key (optional)", "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", "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",