Always start a sender number with + on twillio

This commit is contained in:
Rafael Taranto 2019-07-15 20:45:36 +01:00 committed by Josh Harvey
parent f020ea1f47
commit 2f451c5893

View file

@ -14,11 +14,13 @@ function sendMessage (account, rec) {
const client = twilio(account.accountSid, account.authToken) const client = twilio(account.accountSid, account.authToken)
const body = rec.sms.body const body = rec.sms.body
const _toNumber = rec.sms.toNumber || account.toNumber const _toNumber = rec.sms.toNumber || account.toNumber
const from = _.startsWith('+')(account.fromNumber)
? account.fromNumber : `+${account.fromNumber}`
const opts = { const opts = {
body: body, body: body,
to: _toNumber, to: _toNumber,
from: account.fromNumber from
} }
return client.messages.create(opts) return client.messages.create(opts)