Abhinand
Abhinand

Reputation: 11

Twilio Send Message to Whatsapp

I tried to send Whatsapp message through Twilio

const accountSid = 'AC4fcb197075xxxxxxxcccccccvvvvvvvvv';
const authToken = 'fedd7f35082ccccccccccc49cxxxxxxxxxxx';
const client = require('twilio')(accountSid, authToken);
client.messages.create({
    body: 'This is the ship that made the Kessel Run in fourteenparsecs',
    from: '+15yyy61xxx',
    to: '+91mmm911kkk7'
}).then(message => console.log(message.sid));

Message SID is logged to console but in Twilio Debugger, following error codes are found

  1. 30004 - Message blocked
  2. 11200 HTTP retrieval failure

Upvotes: 1

Views: 3125

Answers (1)

Brett Meyer
Brett Meyer

Reputation: 156

I manage the WhatsApp team at Twilio -- happy to help!

Chenna's comments are correct. With WhatsApp, your to and from values would be prefixed with "whatsapp:".

To use WhatsApp with Twilio's Programmable Messaging API, you'll have to do one of two things first:

  1. Setup the Sandbox using your account on the Twilio Console. Details: https://www.twilio.com/docs/sms/whatsapp/api#twilio-sandbox-for-whatsapp. You then send messages using the US Sandbox number: from=whatsapp:+14155238886
  2. Request a Twilio phone number to be onboarded to Facebook/WhatsApp and Twilio WhatsApp. One approved and onboarded, you can use that number to send and receive messages through the API. Details: https://www.twilio.com/docs/sms/whatsapp/api#enabling-whatsapp-with-a-twilio-number, https://www.twilio.com/console/messaging/whatsapp/numbers, and https://www.twilio.com/whatsapp/request-access

If you need any more help, feel free to reach out to Twilio Support!

Upvotes: 8

Related Questions