BotBuilderCommunity/botbuilder-community-js

Twilio WhatsApp Adapter: request doesn't contain a valid Twilio Signature

Closed this issue · 1 comments

Hi,

I am struggling getting the adapter to work properly. The validation of the request keeps failing resulting in the errormessage above

const { TwilioWhatsAppAdapter } = require('@botbuildercommunity/adapter-twilio-whatsapp');
const whatsAppAdapter = new TwilioWhatsAppAdapter({
    accountSid: '<Sid from Twilio console >', 
    authToken: '<>Auth token from Twilio console', 
    phoneNumber: '<phone number from Whatsapp Sandbox settings in Twilio>',
    endpointUrl: 'url from Sandbox setting in Twilio' 
});

For the endpointUrl parameter I use is the one from my chatbot: https://mybot.azurewebsites.net/api/whatsapp/messages

for the phoneNumber parameter I tried multiple formats without succes:
whatsapp:+1XXXXXXXXXX
whatsapp:1XXXXXXXXXX
+1XXXXXXXXXX
1XXXXXXXXXX

I checked the source of this adapter and there are two possible causes:

  1. No x-twilio-signature header. I checked the request headers and there seems to be a valid x-twilio-signature header in there.
  2. The result of the twilio.validateRequest returns false. This method is taking authToken, signature, requestUrl and message. I checked them all and they seem fine.

I would appreciate some guidance. Otherwise I will need to figure our a way to debug this module
tnx

The sample works fine. Should have tried that first
An analysis of my own botcode showed that the problem was a line of code:
server.use(require('body-parser').json()
Since I am using restify I am not sure why it is there in the first place.