Can't configure Whatsapp
See original GitHub issueHi. 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:
- Created 3 years ago
- Comments:11
Top GitHub Comments
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 withexpress()
. 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-requestsMaybe this information could be added to the Bottender docs as well? Anyway, my problem is fixed. Thanks for your help. 😃
@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… ?