Bots for Business
A Guide to Building Bots for WhatsApp
If you’re wondering how to build a WhatsApp bot, this guide has the details. Start using the WhatsApp Business API to build a bot that serves your customers.
May 28, 2019

For businesses eager to interact with customers on WhatsApp, 2018 was a banner year. That was when WhatsApp, the world’s most popular messaging application, opened its platform to chatbot developers. Today, WhatsApp offers bot-building tools that help businesses of all sizes provide customer service, send updates to users, and connect with new audiences.
So, what’s involved in building a WhatsApp bot? How is it different from building a bot for another platform, such as Facebook or Slack? And how are companies using the platform to maintain relationships with users? To learn more about building bots for WhatsApp, let’s take a closer look at the platform’s developer tools, features and integrations, and use cases.
Why build a WhatsApp bot?
WhatsApp is the world’s most popular messaging app. Except for in a handful of countries (the United States being the most notable), WhatsApp dominates the global messaging landscape in terms of the number of active users. Given the app’s large international footprint, it’s no wonder Facebook was eager to acquire it in 2014 for $19 billion.
In Europe, South America, Africa, South Asia, and the Middle East, WhatsApp usage is particularly widespread. If your brand is already active in any of these regions, you should consider building a bot for WhatsApp. After all, it’s where your audience already spends time.
Besides the huge number of potential users, another reason to build a WhatsApp bot is trust. WhatsApp is a relatively late arrival to the world of chatbots-via-messaging apps, and it seems to be entering the fray with a healthy dose of discretion. For example, instead of making its main API, the WhatsApp Business API, freely available, WhatsApp requires you to go through an application process. In other words, WhatsApp vets you.
That’s a good thing because it shows that WhatsApp cares about users. Theoretically, by filtering out individuals and organizations that might not be a good fit for the platform, WhatsApp provides a markedly user-centered chatbot experience. The platform also prohibits promotional messages, so your audience can rest assured that you’re there to help them with something—not to make a sale.
Because of the thorough WhatsApp process, users know they can trust its bots.
How to build a WhatsApp bot
The first step is to apply for access to the WhatsApp Business API. Although WhatsApp says its API is only available to “medium and large businesses,” the company’s literature isn’t clear on what sort of businesses it considers medium or large. At present, organizations as large as Singapore Airlines and as small as redBus (an Indian transportation booking service that employs 600–700 people) have deployed WhatsApp chatbots. Even if you’re not sure whether you’ll be approved, it’s worth it just to apply.
Business steps
Following your approval, create a Business Profile. That way, WhatsApp users can get quick access to essential information, such as your locations, hours, and website URL. Publishing the profile also gives you the ability to send and receive messages from customers and to create automated notifications.
Other business steps include adding an eligible phone number and a verified name to your account. These are the non-technical hurdles you have to clear before you get to work on your bot.
Development steps
First, set up an on-premises environment or opt to run everything through Amazon Web Services (AWS). After completing a few initial steps, such as registering your API client, testing the installation, tweaking your settings, and creating backups, set up your webhooks.
Webhooks are the cogs and gears that churn inside your chatbot. They’re callbacks that are activated by certain kinds of user activity. Whenever a user sends a particular type of message—that is, an event—it triggers one or more webhooks. Your bot then sends the right response, and the user sees the message. WhatsApp developer documentation contains a detailed overview of how webhooks work in the WhatsApp Business API.
If you want your bot to send images or other types of media to users, review the WhatsApp guide to sending media-rich messages. You can also work with WhatsApp Message Templates to standardize certain types of correspondence with customers.
Potential stumbling blocks
Right away, you might wonder why WhatsApp requires you to host its API client with a database. Why not just have an open API to call? This is a frequently asked question that’s covered in the developer documentation.
According to WhatsApp, the company’s encryption requirements specify that all messages are encrypted with sender and receiver keys. Users store these keys in their devices. Businesses store them in—you guessed it!—a database. WhatsApp notes, “Having an API to send messages on will break end-to-end encryption which is against the WhatsApp philosophy.”
For some, the database requirement might present a challenge. That’s especially true if you’re planning to set up the database, maintain it, and scale it in-house. Just be aware of the IT effort that may be involved in this undertaking. Depending on the resources at your disposal, it may not be an issue.
Cross-platform visibility
Keep in mind that WhatsApp is just one platform where customers can interact with your brand. To ensure that your bot transcends the limitations of any one platform, consider redirecting or deploying an identical (or similar) bot —not just on another messaging app but on your own domain name.
Messaging applications come and go. They also change over time, and their user bases grow and shrink. WhatsApp might be the perfect place for your chatbot to live today, but that might not always be the case. That’s why it’s a good idea to deploy your chatbot on a domain that you always control and where the bot will be available to your audience.
A .BOT domain name, in particular, is the perfect place to host your bot. Customers will always know it’s where your bot lives (.BOT is easy to remember, after all), and they’ll know they can always connect with you there.
How to integrate your bot with WhatsApp
Many bot-building frameworks integrate seamlessly with messaging applications. For example, Google Dialogflow framework integrates with Slack and Facebook Messenger, and the framework documentation breaks down the process of getting your Dialogflow-built bot onto those platforms. Others, such as Amazon Lex and Microsoft Bot Framework, offer similarly straightforward integration options.
WhatsApp, on the other hand, follows a more controlled approach to chatbots than platforms like Facebook Messenger, Kik, and Viber. None of the major frameworks integrate with it directly. To deploy your bot on WhatsApp, choose between these options:
- Build your bot from scratch by following the WhatsApp Business API documentation.
- Build your bot on a framework and integrate it with WhatsApp using a third-party API.
The first option is pretty self-explanatory. You build and deploy a WhatsApp-specific bot by following WhatsApp-specific documentation. The second option offers more versatility, but it involves a little more effort.
To get a sense of how it might work, consider this WhatsApp bot tutorial from Twilio, which shows you how to build a WhatsApp bot with Dialogflow and then integrate it using the Twilio API for WhatsApp. The process breaks down like this:
- Gather all of your tools. For the purpose of the tutorial, Twilio uses a PHP developer environment, as well as Composer, a PHP-dependency-management tool. In the real world, you can create an environment that suits your preferences. Twilio also uses ngrok.
- Set up your environment and the Twilio API WhatsApp Sandbox. In the sandbox, you can prototype a bot for WhatsApp—even while you’re waiting for approval to access the WhatsApp Business API. Keep in mind that you can only message other users who join your sandbox.
- Integrate Twilio with Dialogflow. In your Dialogflow account, create a new agent and give it a name. In the tutorial, Twilio shows you how to build a weather bot, so the agent is named weather. Next, in Integrations, type your Twilio credentials. Finally, add your Dialogflow credentials to Twilio in that app’s console.
- Create your webhook, and add it to Dialogflow. The tutorial provides an example of a webhook in PHP. You can do the same thing using another language in your own developer environment. After that, return to Dialogflow and add the unique URL for your webhook (the tutorial uses ngrok to generate this).
- Add an intent in Dialogflow. The intent is an indicator of the user’s motivation behind a particular request. One of the advantages of using a true bot-building framework is that your bot can learn user intents, process natural language, and get “smarter” over time. Since the tutorial example is a weather bot, Twilio suggests simple phrases like, “weather in [name of city].”
- Save and test the webhook. And that’s it! You can ask your bot questions in the Twilio API WhatsApp Sandbox and gauge how well it responds.
This is just how it works in one tool, but the process should give you an idea of what to expect when trying to integrate a bot built on a separate framework.
The Gupshup Smart Messaging API for WhatsApp Business is another option for prototyping bots in a sandbox environment while you wait for WhatsApp approval. Gupshup is also a bot framework, so you can build your bot there, make the most of the framework’s natural language processing (NLP) features, and use the API to build, test, and deploy your bot to WhatsApp.
WhatsApp chatbot examples
One thing that some of the best WhatsApp chatbots have in common is their focus on customer service. Through its vetting process for companies and its exclusion of promotional bots, WhatsApp ensures that your users never feel that they’re being sold to or spammed, and most organizations leveraging the platform are doing so to improve existing customers’ experience with their brand.
KLM Royal Dutch Airlines

If you fly KLM, you can engage the KLM WhatsApp message bot to get flight and booking information. This can be useful if, for example, you already have WhatsApp open on your phone and you need to check which terminal your flight leaves from. The bot can also notify you of flight delays or connect you with a human agent if you’ve got a question it can’t answer.
Lost your boarding pass after leaving the security checkpoint? Ask the bot to send it straight to your phone. You’ll receive a link to the QR code, just like you would via email.
Bank BRI

As one of Indonesia’s largest banks, Bank BRI undoubtedly receives many inquiries about ATM and branch locations. It also logs a lot of customer feedback, as most banks do.
Thanks to its WhatsApp bot, Sabrina, customers can get bank branch information, find nearby ATMs, and leave feedback that human service representatives can follow up on. Sabrina uses contextual awareness to respond to inquiries quickly (think, “branches near me”). As a result, Bank BRI has lowered customer service costs and reduced employee operational time.
redBus
With WhatsApp, after booking a bus through redBus, one of India’s most popular bus-booking services, you have a lot of options at your disposal.
For starters, you can request your booking details or even amend your booking through the bot. You can also cancel a reservation or check the status of a refund. According to the company, these options have improved the redBus customer experience immensely.
Getting started with WhatsApp bots
The first step to getting started with WhatsApp bots is to apply for access to the WhatsApp Business API. After that, take a look at the WhatsApp Getting Started guide, which runs through all the business and technical steps involved in creating your bot.
Since Twilio and Gupshup offer options for prototyping before you actually get approved, you can go ahead and start building your WhatsApp message bot. In the event that you aren’t granted access to the API, the work you did doesn’t have to be in vain. You can always take your bot to a different channel, so there’s little risk in working with these tools. You can also use the free trial period to try out a bot-building framework and get some testing out of the way before gaining full access.
After building and deploying your bot on WhatsApp, you have a new and effective way to interact with customers and to bolster their perception of your brand.