Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Twilio could not find a Channel with the specified From address

Tags:

node.js

twilio

Im using twilio for whatsapp API, but the problem right now is that i keep getting this error

Error: Twilio could not find a Channel with the specified From address

Here's the code

const express = require('express')
const accountSid = '-'
const authToken = '-'
const client = require('twilio')(accountSid, authToken)
const request = require('request')

const app = express()


app.get('/test', (req, res, next) => {
    client.messages
      .create({
        body: 'Hello there!',
        from: 'whatsapp:+14155238886',
        to: 'whatsapp:+myNumber'
      })
      .then(message => console.log(message.sid))
      .done()

      res.json('Done')
})

app.listen(3030, (err) => {
    if (err) {
        console.log(err)
    } else {
        console.log('Connected to the port 3030')
    }
})

Sandbox picture

enter image description here

What should I do?

like image 594
airsoftFreak Avatar asked Aug 21 '18 03:08

airsoftFreak


2 Answers

This error occurs due to 1 of 3 reasons.

  • The From address in your Messaging API request is incorrect. To send messages using WhatsApp, the From address should be whatsapp:<sandbox phone number>. This can be found on the sandbox page in Twilio.

  • You are trying to send a message from an account that does not have an activated sandbox.

  • You are using your test Account SID and TOKEN. For whatever reason, Twilio needs your Production Account SID and TOKEN when using the WhatsApp sandbox for testing.

like image 61
Murali Allada Avatar answered Sep 28 '22 01:09

Murali Allada


Not sure if it still relevant but I'm currently testing out the Twilio whatsapp API in their sandbox (with a trail account) and I haven't added/bought any phone numbers so far.

What i noticed is that when you send a test messages from their console page and you look closely to the curl request (what is send to the API) on the console page they are always using the production clientid token combination.

While i was implementing the Client i assumed that i should use the test clientid token combination (because of common sense :)) but after inspecting the curl request i switched to the production clientid and token and I was able to send test messages to my own sandbox. (Using the sandbox 'from' phonenumber provided on the same page and only to my own private phonenumber which has been added to the sandbox)

Hope it helps :)

like image 41
Eric-PR Avatar answered Sep 28 '22 01:09

Eric-PR