Table of Contents

WhatsApp - How to direct a user through a different bot flow on their second visit

Second Visit in WhatsApp/Messenger bots

Our bots for WhatsApp/Messenger always continue the conversation until it reaches the end of the flow.

Once the last block is reached, if the user sends any message, the bot will be triggered and start again from its first block.

So if you do not define a second flow for the users that return to your bot (or restart the bot), they will answer the same questions every time they interact with your bot.

If you want to prevent this behavior, you can define a second flow for returning visitors, following some simple steps 😉

There are 2 different ways you can collect the user's input and first interaction with the bot: Collect Intent block and Set Variable block.

Using the Collect Intent block

The Collect Intent block (former User Input block) is a very useful tool that you can use to capture and use your user's input and first interaction with the bot.

The user's first input or interaction will be saved under the variable called @user_input:

Using the Set Variable block

This step is very simple, you can read more about it in the How to capture and use the first user's interaction (input) in WhatsApp/Messenger article.

Create a "Set Variable" block and edit it so that it looks like it does below:

Set a Condition

The next thing we want to do, regardless of whether you're using the Set Variable block or the Collect Intent block to capture the user's first input, is to add a Conditions block where we will verify if this is the user's first time interacting with the bot.

We created the variable @qualification but feel free to use a variable you feel comfortable with and set it up as shown in the picture:

User's first visit

If this is the user's first time interacting with the bot, the variable will have no value yet, so we will connect the red output (false) to the qualifying questions flow.

At the end of the flow, add a "Set Variable block". We will use this block to give the @qualification variable a value.

In this case @qualification = yes

The same applies in case you are using the Set Variable block to collect the user's first input:

User's second or following visits

Since we gave the @qualification variable a value, the next time the user interacts with the bot it will recognize this and the flow will continue through the green exit every time.

Connect the green output (true) to the second visit flow.

The same applies if you are using a Set Variable block to collect the user's first input:

How did we do?

Types of Content and Media you can use in WhatsApp 🖼

WhatsApp - Get user out of error message loop

Contact