Two-Step Email Verification

Abby Updated by Abby

In this article we'll show you how to create a two-step email verification with a Javascript block and a SendGrid Email block.

In the welcome message we've used multi-question to ask the user for their email and saved it in the variable @email

The next step in the flow is the code block:

We'll add the following snippet:

  var landbotScope = this;

const randomNumber = Math.floor((Math.random() * 9999) + 1);

This snippet creates a random four digit number and saves it in the variable @randomnumber every time the user passes over the block

It's crucial to have a user input after the code block, otherwise our variable won't get set.

So here we can ask the user to verify their email:

If they wish to change their email address we'll just loop them back to the welcome message, otherwise we'll continue to the 'Send an email' block

We'll send it to our email lead using the variable @email

In the email message we'll add the variable @randomnumber, it must be in this format as it's not available in the system variables

We've initialized a counter to avoid that the user gets stuck in an eternal loop, next we've added a 'Question: Number' block and saved the variable as @code

After the user enters the code we'll add a number to the counter and then use a condition to see if @code is equal to @randomnumber, if so that's it!


We link the fail output of the condition to the next condition 'If @counter is greater than 2' (you can add as many attempts as you want)

If it's greater than two we let them decide to try again or end the flow, if they end the flow we'll add a 'Set Variable' called 'checkmanually' and set it to true, that way your team can verify it.

If it's less than two then they'll be redirected to the welcome message to enter their email address again.

Here's the message they'll get in their inbox:

How did we do?

Conditional Welcome: Direct the Flow of Your Bot Based on External Parameters

Detect if bot was opened