question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't configure Whatsapp

See original GitHub issue

Hi. I’ve been trying to configure Whatsapp with Twilio sandbox on an existing bot but it’s not working. I’m using v1.3.5.

Here’s what I did: added the Whatsapp config to channels, set enable to true, left the default path and added the keys and phone number using envs with the same names as the ones on the documentation.

So I started my node with npm dev run and ngrok on the same port. (I noticed the documentation said to use npx bottender dev but that also didn’t work and it actually gave me less information than the other way.). Then I configured the URLs on Twilio and tried sending a whatsapp message and all that happens is ngrok says POST /webhooks/whatsapp 400 Bad Request and Twilio gives me 11200 - HTTP retrieval failure for every message I send.

The thing is I can access /webhooks/whatsapp just fine, for example, if I open the address on the browser I get an Internal Server Error and an error message on the node console. This makes me think that there is something wrong with the way the Twilio keys and phone are configured. I configured the number in this way: WHATSAPP_PHONE_NUMBER="whatsapp:+xxxxxxxxxxx", like mentioned on the previous issue.

I’m using the same Twilio number I used to send the join xxx-xxx token, I hope that’s the correct number. I tested with another number Twilio gave me but that didn’t work either. I tried exchanging the Twilio live keys with the test keys but that also didn’t work.

Would really appreciate some guidance here. Or maybe some error messages telling us what’s wrong.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
pTutucommented, Apr 15, 2020

Yeah, I’m using the live credentials but that wasn’t the problem. I managed to configure twilio on an older project, without using Bottender and it worked correctly, so I know my credentials are correct. And looking at this older project I found a solution to the problem.

It seems that we have to add server.use(bodyParser.urlencoded({ extended: false })); after setting the server with express(). I don’t know why this middleware configuration fixes the issue but I have seem it being mentioned on the Twilio docs. For example: https://www.twilio.com/docs/usage/tutorials/how-to-secure-your-express-app-by-validating-incoming-twilio-requests

Maybe this information could be added to the Bottender docs as well? Anyway, my problem is fixed. Thanks for your help. 😃

0reactions
florianmaximcommented, Jun 19, 2020

@chentsulin Sorry, still having troubles to get whatsapp to work with twilio 😕

I am using bottender 1.4.6.

I am using LIVE credentials and and added server.use(bodyParser.json({ verify })); server.use(bodyParser.urlencoded({ extended: false, verify })); to my custom server.

If I run it locally in dev mode and tunnel it via ngrok to twilio it actually works fine. Even though I get an Internal Server Error if I open localhost:3000/webhooks/whatsapp (!)

If I run it on my server and pass the webhook to twilio I get the 11200 - HTTP retrieval failure again. All other webhooks working fine(!)

The error I get is:

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, o at Function.from (buffer.js:195:11) at WhatsappConnector.verifySignature (C:\Users\florianmaxim\hn-bot\node_modules\bottender\dist\whatsapp\WhatsappConnector.js:76:50) at WhatsappConnector.preprocess (C:\Users\florianmaxim\hn-bot\node_modules\bottender\dist\whatsapp\WhatsappConnector.js:84:18) ) at Generator.next (<anonymous>) at new Promise (<anonymous>) at __awaiter (C:\Users\florianmaxim\hn-bot\node_modules\bottender\dist\server\Server.js:4:12) at DevServer.run (C:\Users\florianmaxim\hn-bot\node_modules\bottender\dist\server\Server.js:101:16) at DevServer.handleRequest (C:\Users\florianmaxim\hn-bot\node_modules\bottender\dist\server\Server.js:40:21)

Any help… ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't change phone number | Ohje- ja tukikeskus: WhatsApp
If you're having issues using the change number feature, make sure that: The old phone number you entered is currently registered on your...
Read more >
Can't connect to WhatsApp | WhatsApp Help Center
Open your device's Settings > tap Network & internet > Internet. Next to your carrier, tap the Settings icon. Turn Mobile data on....
Read more >
Can't connect to WhatsApp | WhatsApp Help Center
Restart your device by turning it off and back on. · Update WhatsApp to the latest version available from the Apple App Store....
Read more >
Can't change phone number | WhatsApp Help Center
If you're having issues using the change number feature, make sure that: The old phone number you entered is currently registered on your...
Read more >
Can't change phone number | WhatsApp Trung tâm trợ giúp
If you're having issues using the change number feature, make sure that: The old phone number you entered is currently registered on your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found