Skip to content

Commit

Permalink
Updates SMS module for new Plivo structure (#41)
Browse files Browse the repository at this point in the history
Thanks @ribordy
  • Loading branch information
ribordy authored and samyun committed Oct 20, 2018
1 parent 0ca5275 commit a0e7f92
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions lib/bot/send-sms.js
Expand Up @@ -8,29 +8,18 @@ async function sendSms (to, message, from = PLIVO_NUMBER) {
if (!enabled || to == null) return false;

const plivo = getPlivo();
const params = {
src: from,
dst: to,
text: message
};

return new Promise(resolve => {
plivo.send_message(params, function (status, res) {
console.log('Status: ' + status);
console.log(res);
resolve({
status,
res
});
});
});
try {
response = await plivo.messages.create(from, to, message);
console.log(response);
return response;
} catch (error) {
console.error(error);
return false;
}
}

function getPlivo () {
return Plivo.RestAPI({
authId: PLIVO_ID,
authToken: PLIVO_TOKEN
});
return new Plivo.Client(PLIVO_ID, PLIVO_TOKEN);
}

module.exports = {
Expand Down

0 comments on commit a0e7f92

Please sign in to comment.