Last active
November 25, 2022 13:05
-
-
Save Anshul0305/84e8aa12a7fc6f395765678be247697a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unirest = require('unirest'); | |
const { base64encode } = require('nodejs-base64'); | |
function sendWhatsappMedia(MediaUrl){ | |
// ENTER THE DETAILS BELOW | |
const AccountSID = "YOUR TWILIO ACCOUNT SID"; | |
const AuthToken = "YOUR TWILIO AUTH TOKEN"; | |
// DO NOT CHANGE ANYTHING BELOW | |
const data = request.body.originalDetectIntentRequest.payload; | |
const To = data.From; | |
const From = data.To; | |
const Authorization = base64encode(`${AccountSID}:${AuthToken}`); | |
console.log("From", From); | |
console.log("To", To); | |
console.log("Auth", Authorization); | |
console.log("MediaUrl", MediaUrl); | |
const req = unirest('POST', `https://api.twilio.com/2010-04-01/Accounts/${AccountSID}/Messages.json`) | |
.headers({ | |
'Authorization': `Basic ${Authorization}` | |
}) | |
.field('To', To) | |
.field('From', From) | |
.field('MediaUrl', MediaUrl) | |
.end(function (res) { | |
if (res.error) throw new Error(res.error); | |
console.log(res.raw_body); | |
}); | |
} |
Hi, thanks for your post, i have a question, what kind of setting need, to paste my id and token of twilio, because i try with account keys of producction and test, can you help me? regards of México
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, first, thank you for all your notes and forgive me my poor english (i am from peru)
i have a problem with this code
I want to obtain the phone number to register into a googlespreadsheet (api2)
I really aprreciate your help
function grabar(agent){
const DF_Nombre = agent.parameters.Nombre;
const DF_Momento = (Date.now()/86400000)+25569 -5/24;
const data = request.body.originalDetectIntentRequest.payload;
}