How To Build A WhatsApp Chatbot
So you want to build a WhatsApp Chatbot. You’ve made the right choice! With over 2 billion users, WhatsApp is where all your customers are hanging out, and building a bot can help you grab a piece of their attention. But you already probably know all of that, so let’s jump right in…
There are two parts to building a WhatsApp chatbot:
Part A: Getting WhatsApp Business API Access
Part B: Building A Conversational Flow
It is important to note that these two parts do not have to occur in a particular order. In fact, we recommend that you get both started at the same time.
With that, here is a breakdown of each part👇
Part A: Getting WhatsApp Business API Access
Before you can even start thinking about creating your WhatsApp chatbot you need to get access to the WhatsApp Business API.
To do this you need to go through a few verification steps so that WhatsApp knows exactly what your business does and what you plan to do with a WhatsApp Chatbot.
The entire process consists broadly of 2 steps and it takes around 2 weeks to complete, but you’ll find that when you actually get into the details it can get quite bureaucratic, so if you need help along the way feel free to contact us . One of our experienced customer success managers will help you through the entire process.
If you want to do it yourself though, here are the steps👇
Step 1: Verify your Business on Facebook
Since WhatsApp is owned by Facebook, they handle their business verification through Facebook’s business platform.
You can find instructions on how to verify your business through Facebook over HERE.
NOTE: If your company runs Facebook ads you probably have this step complete
Step 2: Apply for Business API Access through a Third-party Vendor
WhatsApp does not directly provide API access to businesses. Instead, they do it through approved third-party vendors.
Once you have your business verified through Facebook you can apply for WhatsApp Business API access through one of these vendors.
Here are some of the providers we have worked with and the webpages where you can request WhatsApp API Access on their platforms:
Twilio: https://www.twilio.com/whatsapp/request-access
360dialog: https://www.360dialog.com/en/whatsapp-business/
In this guide, we’re going to show you how you can hook your bot up through Twilio.
Part B: Build out your chatbot’s conversational flow
Just because the API verification process takes some time, does not mean that you can’t have some chatbot-related fun while you wait!
In fact, we highly recommend that, while the API verification process is happening, you start building out the conversational flow of your chatbot.
Here are the steps you can go through to create a basic Leadgen+FAQ WhatsApp Chatbot for TARS:
Step 1: Signup for the TARS builder
Go to https://hellotars.com and signup for free
Step 2: Create a new Chatbot
When you first signup for the TARS builder you will be dropped into our templates library:
You can use any of the 950+ templates that we have as a base for your chatbot, but in this guide, we are going to build one from scratch so click the My Chatbots button on the left side of the screen:
On the following screen, click on the Create a new chatbot button and give your chatbot a name:
This will open up a blank canvas where you can define the conversational flow of your chatbot:
Step 3: Create a gambit
To start creating your conversational flow, click the green Add a gambit button in the top left of the screen:
This will populate your canvas with a weird-looking object that looks like this:
This object is called a gambit, and it is the basic building block of any conversation. To understand how it works click on it to open up the gambit modal:
As you can see, each gambit is made up of two parts: Bot Messages and User Input. Using these two parts of the gambit modal you can define a single back-and-forth interaction between the bot and the user.
Since we’re still on the first gambit, go ahead and write the messages in such a way that they welcome the user to the chatbot:
Once the messages are complete, you can specify how users can respond to these messages by clicking the Select User Input Type dropdown.
Once the messages are complete, you can specify how users can respond to these messages by clicking the Select User Input Type dropdown.
We have over a dozen user input options available in our builder, but given the WhatsApp chatbot platform’s limitations, only the text, button, image/file, geo-location, no input, and auto page redirection input UIs are compatible with WhatsApp chatbots.
The most popular input UIs in the TARS builder are text and buttons, so we’ll focus on those in this guide.
For the first gambit of the FAQ/Leadgen bot we are creating in this guide, select the Buttons option, and drop all of the FAQs that you want the bot to answer in as buttons:
Since this is also going to be a leadgen chatbot, throw in an extra button for users to start the leadgen flow of the conversation. In the case of the TARS chatbot, I’m going to let people book a free landing page audit (one of the many services we offer):
It is important to note that WhatsApp’s API does not support actual buttons, so we map each button to an option in a numbered list like this:
Once the buttons are set up, rename the gambit something descriptive (in this case, intro):
And hit save:
You will now notice that the gambit now has four red sockets sticking out of the bottom:
These sockets correspond to the button options we defined in the gambit. As you will see in the next step, they will allow you to branch the conversation off in different directions based on the user’s input.
Step 4: Create a second gambit and connect it to the first
Now that we’ve gotten the first back-and-forth out of the way it’s time to flesh out the rest of the conversation. For starters, create a second gambit and connect it to the first gambit like this:
Fill out the messages in the second gambit so that it responds to the corresponding question that we specified in the first gambit. In the TARS bot that I am creating, the first question had to do with pricing so I am going to tell users about TARS’ pricing:
Be sure to add the options from the first gambit to the second gambit as well, in case the customer wants more information:
And don’t forget to rename the gambit something descriptive:
Step 5: Repeat Step 4 till you have gambits for every FAQ
This step is about as easy as it sounds. Create new gambits for each of the FAQs you defined in the first gambit, fill them out with messages that answers one of the questions, rename the gambit and connect it to the corresponding socket in the first gambit so that your flow looks something like this👇
Also, since we re-added all of the options from the first gambit to each of the FAQ Answer gambits, we need to connect all of the empty sockets in the new gambits we created to the appropriate answer:
Step 6: Build out the lead gen flow
You’ll notice that we have one socket still unconnected in the options.
This corresponds to the leadgen flow, which we want to build out.
Before creating your leadgen flow in the builder, decide on what details you want to capture as part of each lead. IN the case of the TARS chatbot, I am going to collect two details:
- Email id
- Landing Page URL
Once you’ve settled on the details, create one gambit per detail and connect them up in a chain like this:
After they are connected to each other, you will need to jump into each one and define the messages and user input just like we did in the FAQ gambits.
In the TARS chatbot example, the first leadgen gambit is going to accept the landing page URL detail so I’m going to jump in, define the messages such that they ask for this detail, and rename the gambit landing_page_url.
You’ll notice that I don’t need to change the input UI for this gambit because we need to use plain text input to accept a URL
Similarly, in the second leadgen gambit, I’m going to rename it email_id, and define the messages to ask for this detail:
To collect email ids I’m going to have to use text input to collect an email id as well but before closing out of this gambit, I am going to adjust the verification of the text input to email using the dropdown in the input UI section of the gambit:
This will ensure that the users only submit their email id. If they submit something else, the bot will prompt them with a message like this:
Once your leadgen flow has been setup like mine is above, you can connect the empty sockets of the other gambits to the leadgen flow like this:
Step 7: Complete the flow
At this point you should have just one empty socket in the flow left at the bottom of the last leadgen gambit:
To close this out, create another gambit, rename it end_gambit and attach it to the flow like this:
Write the messages in this gambit such that they thank the user for sharing their details in the leadgen flow:
And finally, select the Auto-page redirection option in the input UI drop-down:
Hit save on the gambit, and you’ll notice that the socket at the bottom of our end_gambit is now black:
This means that the conversation ends there.
In a WhatsApp chatbot, this just means that the next time the user talks to the bot, it will start the conversation from the beginning.
Step 8: Test your bot in webview
At this point your flow is complete and even if you haven’t got WhatsApp Business API approval yet, you can test it out in our webview, by hitting publish:
And then clicking the arrow button next to it:
This will open the bot up in a new tab where you can interact with it to see how the flow works:
NOTE: You can also use this web chatbot as a customer service tool by sharing it as a link or deploying it as a website widget.
Step 9: Hook up your bot to your WhatsApp Business API credentials
After you receive approval from WhatsApp Business API access from Twilio, you will need to jump into your Twilio account, go to the Twilio Dashboard (https://www.twilio.com/console) section and copy the Account SID & Auth Token.
Once this is done, go to the distribute section of the builder:
Select WhatsApp from the menu:
Select Twilio from the dropdown:
Input the copied keys into the appropriate fields and hit save:
Doing this will let your chatbot send messages through your Twilio-enabled WhatsApp Business Number.
You still, however, need to give Twilio a way to send messages received on the number form users to the TARS builder so that it knows how and when to respond.
To do this, copy the webhook URL that appears below the save button:
Click on the WhatsApp Senders option in your Twilio Dashboard and click on Configure option for the WA number you want to connect in your Twilio dashboard:
Finally, enter the copied Webhook URL in the “A Message Comes in” field (keep the dropdown value to be HTTP Post) and hit configure
Step 10: Test your bot in WhatsApp
Now it’s time for the fun part.
Hit publish in the TARS builder again and start a conversation with the chatbot in WhatsApp using the WhatsApp Business Number associated with your API credentials:
Your bot should respond to you using the flow that you created in the builder.
At this point, your bot is ready to be shared with users! You can check out our guide on how you can bring people to your WhatsApp chatbot to find out more about this.
Step 11: Check the conversation data
Once you’ve had a conversation with the bot (in webview or in WhatsApp), you can check the conversation data in the builder to see how your bot is performing
To do this, click on the check data section in the menu on the left:
You’ll notice that there are 4 options for how you can leverage conversation data. Here’s a breakdown of each one👇
View
The view option lets you do some basic data analysis right within the builder.
In this section you can see a running list of all the conversations that your bot has had:
Analyze
The analyze section lets you analyze how your bot is performing. Currently, the builder offers two options for doing this.
You can either look at a set of summary statistics about the bot’s performance:
Or you can examine how those statistics are performing over time:
NOTE: If you want to learn more about what these statistics are check out our guide on the topic HERE.
Integrate
Using the Integrate section you can hook up your bot to your favorite CRM using our Zapier integration.
Export
For the real data nerds out there we give you the option of exporting conversational data as a CSV for analysis in excel:
Concluding Thoughts…
With that, you have everything that you need to create your first WhatsApp Chatbot.
If you are interested in reading more about the technology, check out these articles that we’ve created on the topic:
What is a WhatsApp Chatbot?
WhatsApp Business API vs WhatsApp Business Number: Which option is best for you?
How to automate customer service using a WhatsApp Chatbot
How to generate more leads using a WhatsApp Chatbot
How to book more sales calls using a WhatsApp Chatbot
How to increase Facebook Ad ROI using a WhatsApp Chatbot
How to conduct User Engagement Quizzes through a WhatsApp Chatbot
4 Ways to bring users to your WhatsApp Chatbot
Download “The Ultimate Guide to WhatsApp Chatbots” Ebook👇🏻
Also, we’ve recently hosted a webinar explaining how to create a WhatsApp Chatbot for your business using Tars. Check it out👉🏻
If you want help creating a WhatsApp chatbot schedule a consultation with us today at bit.ly/tars-whatsapp-chatbot
Arnav is the Director of Content Marketing at Tars. He spends most days building bots, writing about conversational design and scrolling through Giphy’s trending section looking for the gifs that go into the Tars Newsletter.
- Part A: Getting WhatsApp Business API Access
- Step 1: Verify your Business on Facebook
- Step 2: Apply for Business API Access through a Third-party Vendor
- Part B: Build out your chatbot’s conversational flow
- Step 1: Signup for the TARS builder
- Step 2: Create a new Chatbot
- Step 3: Create a gambit
- Step 4: Create a second gambit and connect it to the first
- Step 5: Repeat Step 4 till you have gambits for every FAQ
- Step 6: Build out the lead gen flow
- Step 7: Complete the flow
- Step 8: Test your bot in webview
- Step 9: Hook up your bot to your WhatsApp Business API credentials
- Step 10: Test your bot in WhatsApp
- Step 11: Check the conversation data
- Concluding Thoughts…
Learn why businesses trust us to automate their pre-sales and post-sales customer journeys.
Recommended Reading: Check Out Our Favorite Blog Posts!
Recommended Reading: Check Out Our Favorite Blog Posts!
The Complete Explainer for Tars WhatsApp Engagement Suite
WhatsApp Business Number vs WhatsApp Business API: What’s the Best Option for You?
4 Ways To Bring Customers To Your WhatsApp Chatbot
Our achievements in numbers
7+
years in the Enterprise Conversational AI space
700+
global brands that we’ve worked with
50m+
customer conversations automated
10+
countries with deployed Chatbots