Recognise the users input when sending a Message Template with buttons

Hajar Updated by Hajar

Hello! πŸ‘‹

In this article, we are going to see how to capture from a WhatsApp bot the response that users give to a Message Template with buttons.

Now, let's imagine that you send a template through a Campaign with these buttons to remind your customers of the call they have scheduled.

So, how do we capture the user's response when they reply to our Message Template by clicking on one of the buttons?

Steps to follow

  1. You will need to create a specific WhatsApp bot for this, for example with flow like this:
  2. We first need to add the Collect intent block, with this block we will save the user's response inside the @user_input variable, which in this case should be either 'Rescheduled' or 'Perfect, see you there!', or if the user decides to ignore the buttons and just reply with random text, it will be stored inside this variable as well.
  1. Now, we will connect the Conditions block that will first check if the @user_input contains the word 'Scheduled', so If the user pressed the Reschedule button, the flow will continue through the green arrow of this Conditions block. Otherwise, the flow will continue through the red arrow.
  1. In the second Conditions block we will check if the user pressed the 'Perfect, see you there' button, and if they had, the green output will be connected to the message or action you want to trigger for this case, and if not, it will follow the red output.
  1. The red output that we connect to the second Conditions block will be the flow that we want to show to the user in case they didn't reply to our Message Template with one of the buttons and instead they wrote something else. On this example we have used the Jump to block that will send the user back to the main bot connected to our WhatsApp channel, but it's up to you to trigger the action you want!
Also, if you're not familiar with the use of the Collect intent block, please read the full article here. Same for Conditions block here and Jump to block here.

  1. Now you can go ahead and link this bot to your Campaign!

If you triggered the Campaign from the Campaign section on Landbot, just add the bot on the Campaigns > Automation section of your WhatsApp channel:

Sending the Message Template via API

Campaigns cannot be triggered via API, but you can send Message Templates via API, please check this article that explains how to do it.

In this case, the bot that will be triggered when the user replies to the Message Template that you sent via API, is the main bot that you have connected to your WhatsApp channel, so you will need to add the blocks explained below on your main bot.

If you launched the template via API, just right after it you will need to make an unassign request to prevent the chat from being assigned to an agent, which would block the execution of the bot. Please, check our API docs to know how to do it.

How did we do?

Audience block

Audiences

Contact