I am working on implementing a custom WhatsApp API integration to send verification codes to users on WhatsApp. I have already been approved for access to the WhatsApp Business API and obtained the necessary credentials.

Now, I want to send verification codes to users through WhatsApp using my custom integration. But I don't have any idea that how to do that?

I just wanna know How do I generate a random verification code in my application without getting any bugs?

And also I wanna know Which WhatsApp API endpoints should I use to send the verification code as a text message?

I was expecting a the most suitable way to do these things without getting any bugs

Tag:whatsapp, twilio, verification

3 comments.

  1. IObert

    The easiest way to do this is by using Twilio Verify. The advantage here is that you don't need to generate and manage your own codes and can even use the one of Twilio's numbers:

    Step 1: Create a verify service

    Step 2: Send a code to a number

    // Find your Account SID and Auth Token at twilio.com/console // and set the environment variables. See http://twil.io/secure const accountSid = process.env.TWILIO_ACCOUNT_SID; const authToken = process.env.TWILIO_AUTH_TOKEN; const client = require('twilio')(accountSid, authToken); client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .verifications .create({to: '+15017122661', channel: 'whatsapp'}) .then(verification => console.log(verification.accountSid));

    Step 3: Verify the code the user entered

    client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') .verificationChecks .create({to: '+15017122661', code: '123456'}) .then(check => console.log(check.valid));
    1. Code_Sphinx_TSK

      yeah wow it's very easy to manage

    2. IObert

      I'm glad you like it. Feel free to mark this answer as correct (checkmark button) if it helped you.

Add a new comment.