feat: add Telnyx sms support
This commit is contained in:
parent
7307466df4
commit
e8a3d2ed11
8 changed files with 409 additions and 39 deletions
27
lib/plugins/sms/telnyx/telnyx.js
Normal file
27
lib/plugins/sms/telnyx/telnyx.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
const Telnyx = require('telnyx')
|
||||
|
||||
const NAME = 'Telnyx'
|
||||
|
||||
function sendMessage (account, rec) {
|
||||
const telnyx = Telnyx(account.apiKey)
|
||||
|
||||
const from = account.fromNumber
|
||||
const text = rec.sms.body
|
||||
const to = rec.sms.toNumber || account.toNumber
|
||||
|
||||
return telnyx.messages.create({ from, to, text })
|
||||
.catch(err => {
|
||||
throw new Error(`Telnyx error: ${err.message}`)
|
||||
})
|
||||
}
|
||||
|
||||
function getLookup () {
|
||||
throw new Error('Telnyx error: lookup not supported')
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
sendMessage,
|
||||
getLookup
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue