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 " +
Buffer.from(notification.plivoAuthID + ":" + notification.plivoAuthToken).toString("base64"),
},
timeout: 10000,
};
config = this.getAxiosConfigWithProxy(config);
const data = {
src: notification.plivoFromNumber,
dst: notification.plivoToNumber,
text: msg,
};
const baseURL = `https://api.plivo.com/v1/Account/${notification.plivoAuthID}`;
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;
} catch (error) {