v12.0.0 - initial commit

This commit is contained in:
padreug 2025-12-31 19:04:13 +01:00
commit e2c49ea43c
1145 changed files with 97211 additions and 0 deletions

View file

@ -0,0 +1,41 @@
const axios = require('axios')
const NAME = 'Whatsapp'
function sendMessage(account, rec) {
const phoneId = account.phoneId
const token = account.apiKey
const to = rec.sms.toNumber || account.toNumber
const template = rec.sms.template
const url = `https://graph.facebook.com/v17.0/${phoneId}/messages`
const config = {
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
}
const data = {
messaging_product: 'whatsapp',
recipient_type: 'individual',
type: 'template',
to,
template: {
name: template,
language: { code: 'en_US' },
},
}
axios.post(url, data, config).catch(err => {
// console.log(err)
throw new Error(`Whatsapp error: ${err.message}`)
})
}
module.exports = {
NAME,
sendMessage,
}