As messaging apps continue to take center stage in our daily lives, chatbots have emerged as game-changers. These chatbots are smart AI systems designed to facilitate customer interactions through messaging, text, or speech.
And it’s no wonder why WhatsApp chatbots are now a must-have for enterprises — these AI-powered assistants help to automate interactions, provide instant responses, and offer personalized experiences. In fact, research shows that by 2024, chatbots are expected to save businesses up to 2.5 billion hours of work.
If you’d like to reap these benefits (and then some!) for your business, stick around. In this comprehensive guide, we’ll show you how to build your very own WhatsApp chatbot.
Let’s dive in!
Understanding WhatsApp Chatbots
In this section, we’ll explain what WhatsApp chatbots are, how to be eligible to deploy a chatbot, and the benefits of having one for your business!
What are WhatsApp Chatbots?
These are automated software programs that communicate with users on the WhatsApp platform. These chatbots are embedded with data specifically created for businesses looking to engage in conversational commerce within WhatsApp.
Not only can a WhatsApp chatbot mimic human conversational patterns convincingly, but it also maintains a consistent tone and brand identity throughout the conversation.
These chatbots on WhatsApp can be rule-based, following a structured decision-tree-type interaction, or NLP-based, employing natural language processing for a more human-like conversational style.
Some common use cases for WhatsApp chatbots include:
- 24/7 customer support
- Appointment scheduling
- Order placement & tracking
- FAQ automation
- Lead qualification
- Personalized recommendations
- Product discovery
- Booking support
- Lead generation
- Feedback and surveys
- Subscription services
However, before you can deploy a chatbot on WhatsApp, you have to apply and be approved for WhatsApp Business API (Application Programming Interface) integration.
The WhatsApp API allows you to efficiently connect with your customers on a large scale, using thousands of agents and automated bots.
Follow the steps below to apply for WhatsApp Business API.
Step 1: Choose your desired application route
You can apply for WhatsApp Business API:
- By yourself: You can sign up for a WhatsApp Business API directly. You’ll need to have the following:
- A verified business
- WhatsApp Business account
- Facebook Business Manager account
- Credit line for WhatsApp Business
- A command-line center to perform cURL (Client URL) requests
Note that this method can be challenging and time-consuming, especially for medium-sized companies, as it requires technical expertise. You will also need to hire a developer.
- Through a Business Solution Provider: Working with a WhatsApp Business Solution Provider (BSP) can make the approval process faster and easier. BSPs are experts in the WhatsApp Business Platform and can help you manage communication with your customers. They primarily support approved use cases like customer support and sending time-sensitive personalized notifications. Examples include Twilio, 360dialog, AiSensy, etc.
We highly recommend working with a Business Solution Provider as this increases the likelihood of your request being approved more quickly.
Step 2: Complete your application
When applying through a solution provider, you’ll need to provide essential information about your company and your intentions with WhatsApp services.
- Company name
- URL
- Industry
- Intended use cases
- Regions where you plan to provide WhatsApp services
- Country of company headquarters
- Volume predictions (number of messages per day)
- When you plan to launch the service
After your brand is approved, you’ll need to provide additional information to activate your phone number. You can use either a new or existing number, but if it’s new, you need to register it with WhatsApp Business App. You’ll need to provide:
- Customer Facebook Business Manager ID
- The phone number of your WhatsApp Business account
- The name associated with your number
- The region for your app (e.g. U.S)
Note: Each BSP is unique, so requirements for the application may differ.
Once your application is approved and your phone number is activated, you’ll get your WhatsApp API key.
Bonus: How to Create a Chatbot for Free : A Step-by-Step Guide [No Coding]
9 Benefits of Using WhatsApp Chatbots
As a business, it’s crucial to connect with your target audience where they are most active. Considering that WhatsApp has approximately 2.78 billion unique active users worldwide, it’s worth establishing a strong business presence on it.
Here are 9 benefits of making a WhatsApp business chatbot:
1. 24/7 availability
WhatsApp chatbots can operate around the clock, ensuring that customers can reach out for assistance or information at any time.
This 24/7 availability improves customer satisfaction by addressing their needs promptly, even outside of regular business hours.
2. Cost efficiency
Chatbots can handle a significant volume of customer inquiries simultaneously, reducing the need for hiring additional customer support staff.
This cost-effective approach saves businesses money in terms of staffing and training while helping you maintain service quality.
3. Quick response times
Another benefit is that these chatbots provide immediate responses to customer queries, reducing wait times and enhancing the customer experience.
This quick turnaround time can be crucial in resolving issues or answering questions promptly.
4. Consistent and accurate information
WhatsApp chatbots are programmed to provide consistent and accurate information based on predefined responses and data sources.
This ensures that customers receive consistent answers, reducing the risk of misinformation or errors, which can be common in human interactions.
5. Automated task handling
Beyond answering FAQs, WhatsApp chatbots can automate various tasks, such as appointment scheduling, order tracking, and payment processing.
This automation streamlines processes, enhances efficiency, and frees up human agents to focus on more complex tasks.
6. Personalized customer interactions
Research shows that 80% of consumers are more likely to do business with a company that offers a personalized customer experience.
This is another benefit that WhatsApp Business chatbots provide for your business. These bots can collect and analyze user data to provide personalized recommendations and responses and ultimately improve engagement.
7. Multilingual support
You can also leverage a WhatsApp chatbot to communicate with customers in multiple languages & reach a broader audience.
8. Rich media sharing
WhatsApp chatbots are not limited to text-only interactions. They can share a variety of media to enrich communication. For instance, if a customer inquires about your product, the chatbot can share images or videos to convey information more effectively.
9. Important analytics and insights
As we’ve already established. WhatsApp chatbots can generate detailed analytics and insights into customer behavior and interactions.
With this data, you can make more informed business decisions, refine your marketing strategies, and even enhance your chatbot’s performance over time.
Bonus: 12 Best Chatbot Examples For Businesses
How to Make a Chatbot in WhatsApp (Through Python Coding)
In this section, we’ll walk you through the process of creating a WhatsApp chatbot using Python. Keep in mind that this may be a little complicated, especially if you don’t have coding experience.
But, don’t worry, we’ve thoroughly simplified the process for you.
You need to have the following in place before you start:
- Python 3.9 or newer: Ensure you have Python installed on your system. If not, you can download it from the official Python downloads website.
- Flask: You’ll be using Flask to create a web application that responds to incoming WhatsApp messages.
- Smartphone with WhatsApp: You’ll need a smartphone with an active phone number and WhatsApp installed for testing.
- Twilio Account: Sign up for a Twilio account if you don’t already have one.
- ngrok: This utility allows you to connect your Flask application to a public URL that Twilio can access. It’s necessary for development, especially if your computer is behind a router or firewall as a service. If you don’t have ngrok installed, you can download it on the official website.
- Ngrok Account: To avoid certain limitations, we recommend that you create a free Ngrok account and install the authtoken on your computer.
Now, let’s get started.
Step 1: Configure the Twilio WhatsApp Sandbox
On Twilio, you can access a WhatsApp sandbox where you can easily develop and test your application.
Next you’ll need to connect your smartphone to this sandbox:
- In your Twilio Console, navigate to “Send a WhatsApp Message“
- Click “Connect to sandbox.“
- Next, copy the sandbox number and the code.
- Better still you can scan the QR code provided on your mobile phone.
- Send a WhatsApp message containing the code to the assigned number.
After you send the message, you’ll receive a reply from Twilio stating that your mobile number is connected to the sandbox. This means you can start sending and receiving messages.
Step 2: Create a Python Virtual Environment
To follow best practices, set up a separate directory for your chatbot project and create a virtual environment. Then, install the necessary Python packages. Here are the commands for Windows users:$ mkdir WhatsApp-bot $ cd whatsapp-bot $ python3 -m venv whatsapp-bot-venv $ whatsapp-bot-venv\Scripts\activate (whatsapp-bot-venv) $ pip install twilio flask requests
For Unix/Mac users:$ mkdir whatsapp-bot $ cd whatsapp-bot $ python3 -m venv whatsapp-bot-venv $ source whatsapp-bot-venv/bin/activate (whatsapp-bot-venv) $ pip install twilio flask requests
The final command uses pip, a tool for managing Python packages, to download and install three essential packages for your chatbot project:
- Flask framework to build the web application
- Twilio Python Helper library to use Twilio’s APIs
- Requests package to connect with external APIs from third-party sources
Step 3: Create a Flask Chatbot Service
Now, let’s build the chatbot. We’ll start by defining a webhook using Flask. The webhook serves as a communication point for Twilio to send incoming WhatsApp messages. Below is a basic Flask application with a webhook definition:
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
app = Flask(__name__) @app.route(‘/bot’, methods=[‘POST’]) def bot(): # Add webhook logic here and return a response if __name__ == ‘__main__’: app.run(port=4000)
This code defines a /bot
endpoint that listens to POST requests. Whenever Twilio receives an incoming message from a user, it will invoke this endpoint. The bot()
function will analyze the user’s message and provide the appropriate response.
To work with incoming messages, you’ll need to access the message content from the payload of the POST request. The message content is stored under the key 'Body'
. from flask import request incoming_msg = request.values.get(‘Body’, ”).lower()
For responses, Twilio expects a TwiML (Twilio Markup Language) response, which is XML-based. Fortunately, the Twilio Helper library for Python provides classes to create responses without manually creating XML. Here’s how you can create a response with text and media components:from twilio.twiml.messaging_response import MessagingResponse resp = MessagingResponse() msg = resp.message() msg.body(‘This is the response text’) msg.media(‘https://example.com/path/image.jpg’)
(To include an image, provide a URL to the image instead of the actual image data.)
Step 4: Implement the Chatbot Logic
Now, let’s implement the chatbot logic. We’ll create a simple chatbot that reacts to two keywords: “quote” and “dog“.
When a user’s message contains “quote,” the chatbot will respond with a random quote.
If the message contains “dog,” it will return a random dog picture. If both keywords are present, the bot will respond with both a celebrity and a dog picture.
Here’s the basic structure of the chatbot logic:responded = False if ‘quote’ in incoming_msg: # Add a quote to the response here responded = True if ‘dog’ in incoming_msg: # Add a dog picture to the response here responded = Trueif not responded: # Return a generic response here
This structure allows you to detect keywords and configure the Twilio response object accordingly. The responded
variable helps track cases where the message doesn’t contain any keywords.
Step 5: Use Third-Party APIs
To provide names of celebrities and dog pictures, you can use these two publicly available APIs:
- For famous quotes, try the Quotable API by Luke Peavey. A GET request to
https://api.quotable.io/random
returns a random quote in JSON format. - For dog pictures, we’ll use the Dog API by Dog CEO. The URL
https://dog.ceo/api/breeds/image/random
returns a different dog image each time it’s accessed.
Step 6: Put It All Together
Now that you’ve seen all the components, it’s time to integrate them into a complete chatbot service. You can copy the following code into a bot.py
from flask import Flask, request import requests from twilio.twiml.messaging_response import MessagingResponse app = Flask(__name__) @app.route(‘/bot’, methods=[‘POST’]) def bot(): incoming_msg = request.values.get(‘Body’, ”).lower() resp = MessagingResponse() msg = resp.message() responded = False if ‘quote’ in incoming_msg: # Return a quote r = requests.get(‘https://api.quotable.io/random’) if r.status_code == 200: data = r.json() quote = f'{data[“content”]} ({data[“author”]})’ else: quote = ‘I could not retrieve a quote at this time, sorry.’ msg.body(quote) responded = True if ‘dog’ in incoming_msg: # Return a dog pic msg.media(‘https://dog.ceo/api/breeds/image/random’) responded = True if not responded: msg.body(‘I only know about famous quotes and dogs, sorry!’) return str(resp) if __name__ == ‘__main__’: app.run(port=4000)
Step 7: Test the WhatsApp Chatbot
To test your chatbot, run the bot.py
file while your Python virtual environment is activated. The service will run on port 4000 on your computer.
Open a second terminal window and use Ngrok to make your local service accessible via the internet. The Ngrok command is typically ngrok http 4000
.
Once Ngrok is set up, go to the Twilio Console, configure the WhatsApp Sandbox Settings to use the Ngrok URL with the /bot
endpoint, and set the request method to HTTP Post. Save the changes.
Now, you can send messages to your chatbot from your connected smartphone. When you use the words “quote” or “dog” in your messages, the chatbot will invoke third-party APIs to provide fresh content.
Bonus: The Ultimate Guide to AI Chatbots for Marketing: Everything You Need to Know
Build AI Chatbots with Simplified (A No-Code Solution)
In this section, we’d like to introduce you to Simplified. This all-in-one platform provides tons of features to supercharge your efforts – from content writing & graphic design to video editing & social media management.
It also offers an AI Chatbot Builder that you can use to easily create custom AI chatbots tailored to your business needs!
And, although Simplified doesn’t directly deploy WhatsApp chatbots, you can still use this amazing tool to create chatbots for your website! Best of all, you don’t need any coding knowledge to build & deploy AI chatbots with Simplified.
Want to find out how to create your custom AI chatbot with Simplified? Wonderful! Just follow these easy steps:
1: Log in to your Simplified account or sign up for an account.
2: On your dashboard, click on “AI Chatbot.“
3: Now, select “Add New Bot.“
4: Enter a name for your project.
5: Done? Congratulations! Your chatbot has been successfully created. Now, it’s time to fill in relevant information about your chatbot by writing a custom welcome message & ice breaker questions.
6: Scroll down to customize your chatbot’s appearance by adding a chat heading, chatbot avatar, and trigger time. Once you’re through, select “Next.”
7: Now, it’s time to train & refine your chatbot! In this step, you can use your knowledge data to improve your chatbot’s capabilities. Upload relevant files or provide your website URL to customize its responses and behavior. Once you’re done, click “Next.”
8: Now that you’ve built and trained your bot, it’s time to deploy it and start interacting with your customers! Select your desired deployment method – you can choose to add the bot as a “chat bubble” for direct interaction or embed it anywhere on your website using the iframe code. Plus, you can share your chatbot on social media, messaging apps, or via email.
Once you’re done, you’ll be redirected to another page where you can further set up your chatbot.
Under the “Appearance” section, scroll down to access advanced settings. Here, you can select your desired language & tone and remove Simplified’s watermark.
Under the “Training” section, you can define your chatbot’s default personality.
The “Users Data” section allows you to choose whether or not you’d like to collect user details, as well as access the data of users that’s been collected.
Finally, under the “Conversation” section, you can see the list of your chatbot’s conversations.
Before you go, check out all the sweet benefits you can enjoy with Simplified’s AI Chatbot Builder:
- Access up to 4000, 7000, or 12000 message credits per month so you can engage with your audience without limitations
- Train your chatbots with multiple data sources such as unlimited PDF, DOCX, CSV & text files to increase your chatbot’s knowledge base
- Easily customize your chatbot by embedding unlimited widgets to further improve user interactions
- Get access to unlimited URL-based training so that your chatbot can learn from tons of online resources
- Get valuable user data to easily gain insights into user preferences & behaviors
- Choose from 20+ languages to reach wider audiences
- Personalize the tone of your chatbot for increased brand alignment
Isn’t that amazing? If you need a little extra convincing, check this out: you can build your custom AI chatbot with Simplified at absolutely no cost today!
That’s right. You don’t need to break the bank to build a chatbot & elevate your customer support. However, if you’re willing to access more helpful features, you can choose to upgrade to Simplified’s affordable monthly plan.
Wrapping Up
In conclusion, WhatsApp chatbots have become indispensable tools for businesses of all types. These chatbots offer efficiency, enhance customer interactions, and help streamline your work processes.
While we’ve outlined a Python-based approach to building WhatsApp chatbots, we also introduced Simplified, a no-code solution that simplifies the chatbot creation process for websites.
With this user-friendly AI chatbot builder, you can deliver delightful customer experiences, capture leads, and ultimately increase sales success — for free!