I have a Twilio bought number (it does not support messages) that I want to connect to Whatsapp as a Whatsapp business number. When I enter this number on Whatsapp, select to call on this number, it asks for a verification code. How can I get the verification code when I can't listen to the call?
I have tried adding a function and attaching this function to the number. Here is my function:
exports.handler = function(context, event, callback) {
let otpCode = event.SpeechResult || event.Digits; // Captured OTP from speech or DTMF
console.log("Captured OTP:", otpCode);
let response = new Twilio.twiml.VoiceResponse();
response.say("Thank you. Your verification code has been logged.");
callback(null, response);
};
But when I see the logs, otpCode is null [1]: https://i.sstatic.net/CfNaTmrk.png
Can anyone please let me know what I am doing wrong or is there another way of getting the verification code from a voicecall?
You can use Twilio's ready-made Twimlet to parse the code and send it to your email:
Change the Webhook URL and use the Voicemail Twimlet following this convention:
http://twimlets.com/voicemail?Email=[your email address]
. For example, your twimlet can look like this:http://twimlets.com/voicemail?Email=support@example.com
.
For the full stey-by-step guide, refer to the "Twilio Voice only" section on this documentation page