Send Verification Codes to Your Customers

Different channels can be used to send notifications with verification codes.

In this tutorial, find out how to use WhatsApp as a channel via API to send those codes. This however, can be done using our Infobip web interface.

Send verification codes - 2FA authentication -phone number verification - high -level overview

Process Workflow

Send verification codes - 2FA authentication -phone number verification - diagram

IMPLEMENTATION STEPS

In this case, since the customer is the one who is initiating the conversation, you can reply with a free-form message. But, just for showcase, we will use a templated message instead. Before you can send any kind of templates, such as a phone_number_verification  template, the template needs to be approved by WhatsApp. Once you create your message template, you can reuse it, personalize it for different customers, as well as attaching the appropriate invoice for each customer.

Use additional placeholders to personalize your message text.

The phone_number_verification notification is already approved by WhatsApp, as shown in the table below. Bear in mind that this specific template can be reused for different customers by editing the values in the placeholders.

TEMPLATE REGISTRATION

For template registration, you need to provide the template name, notification content, and language info, after which Infobip sends the template to WhatsApp for approval.

After the template has been registered, you will need to create a link that will allow your customers to to start a chat with you. After they click on the link on your web page, they will be automatically redirected to WhatsApp, with a personalized message linking to your WhatsApp account.

If you want to create your link with a pre-filled message that will automatically appear in the text field, use https://wa.me/whatsappphonenumber?text=urlencodedtext (opens in a new tab)  where the whatsappphonenumber is your phone number in full international format and urlencodedtext is the URL-encoded pre-filled message.

In this case, the link will look like this:

https://wa.me/15551234567?text=r5453-23421 (opens in a new tab), where r5453-23421 is the verification code that the user will receive.

When the customers click on the link, they will be redirected to a page that says:

Phone number verification over WhatsApp

After the customer click Send, they will be forwarded to your WhatsApp account, and the prefilled message r5453-23421 will appear.

If the verification code is correct, they will receive a templated message which confirms it.

Find out more about the WhatsApp click to chat (opens in a new tab) feature.

Steps over API

To send this notification to a specific passenger using the WhatsApp API, follow the steps described below.

  1. Log in to Infobip API Resource hub (opens in a new tab) and copy your BASE URL. Your personal base URL is: https://{{BASE_URL}}.api.infobip.com/
NOTE

The personal BASE URL is a simple way to identify who sent out the API request. This means we can identify the request through DNS and then find the optimal route for API requests.

  1. To send an approved message Template, use Postman or similar API development tools, then choose the POST method.
  2. Replace the endpoint with https://{{BASE_URL}}.api.infobip.com/omni/1/advanced.
  3. Add the Authorization header. For example, Basic: Base64 encoded username and password. Learn more about Authentication (opens in a new tab) on our Infobip API Resource hub.
  4. Copy the scenarioKey you previously created. Learn more about Creating a scenario.

Request example:

json
 
    {
       "scenarioKey":"CC9F01A5DC7BEE2C2B829D203482A654",
       "destinations":[
          {
             "to":{
                "phoneNumber":"41793026727"
             }
          }
       ],
       "whatsApp":{
          "templateName":"phone_number_verification",
          "templateData":[
             "Jenny“
          ],
          "language":"en"
       }
    }
 
  1. templateNametemplateData, and language are mandatory for you to successfully send the notification. templateData should contain the same number of elements as placeholders in the registered template. In case the template does not contain any placeholders, templateData field should be an empty array “[ ]”.

Need assistance

Explore Infobip tutorials

Encountering issues

Contact our support

What's new? Check out

Release notes

Unsure about a term? See

Glossary

Research panel

Help shape the future of our products
Service Terms & ConditionsPrivacy policyTerms of use