How to send a whatsapp message through twilio via zapier webhook

Currently trying to create a Whatsapp message to be sent via This custom Javascript code on Zapier shown via Twilio API. It successfully reaches out to twilio but returns “Authentication Error – No credentials provided”.

var messagesUrl = "https://api.twilio.com/2010-04-01/Accounts/<accountSID>/Messages.json";
var payload = {
 "To": "whatsapp:<tonumber>",
 "Body" : "Hey This is a test",
  "From" : "whatsapp:<fromnumber>"
};
 var options = {
 "method" : "post",
 "payload" : payload
};

options.headers = {
 "Authorization" : "Basic <accountsid>:<accounttoken>"
};
fetch(messagesUrl, {options, body: JSON.stringify(payload)})
 .then(function(binaryResponse) {
  return binaryResponse.json();
})
.then(function(jsonResponse){
  callback(null, {result: jsonResponse});
}).catch(callback);

What is the best approach to take to simply send a confirmation text on whatsapp to prospects on zapier? Thanks in advance

Answer

Thank you for your help, i ended up solving this by using a much simpler Custom web hook POST method, i was over-complicating it. Details on how i did this for anybody else wanting to send whats-app messages through Twilio on Zapier Below:

Method

Post

URL

https://api.twilio.com/2010-04-01/Accounts/<accountSID>/Messages.json

Data

To=whatsapp:%2B<toNumber>&From=whatsapp:%2B<fromNumber>&Body=Put your message body here

Note: The + of your E.164 number will concatenate hence the %2B to replace it

Basic Auth

<AccountSID>|<AccountToken>

Headers

Content-Type | application/x-www-form-urlencoded

Leave a Reply

Your email address will not be published. Required fields are marked *