Introduction
Chatbots are transforming the way companies interact with their clients. Creating a chatbot has never been easier, especially for beginners, regardless of whether you're building an FAQ bot or a more complex virtual assistant. The goal of this blog is to show you how to create your first chatbot, test it with integrated tools, and integrate it into a website without any issues.
What is a Chatbot?
A chatbot is an artificial intelligence program that allows people to converse with digital devices as if they were talking to a human being. The chatbot can be as simple as a single-line response to a question or as complex as a digital assistant that can gather and analyze data to provide ever-higher levels of customization.
How Do Chatbots Work?
Chatbots process data to deliver responses to user requests using:
Artificial Intelligence (AI)
Natural Language Processing (NLP)
Machine Learning (ML)
What Is AI?
AI (Artificial Intelligence) is the simulation of human intelligence processes by machines, particularly computer systems.
Some specific applications of AI include:
Expert systems
Natural Language Processing (NLP)
Speech recognition
Machine vision
What is an AI Chatbot?
AI chatbots are computer programs designed to simulate human-like conversations, enabling text-based (or sometimes voice-based) interactions with people.
Unlike regular chatbots, AI chatbots learn and improve over time.
What makes AI chatbots unique?
They adapt and get smarter the more you use them.
They learn user preferences and improve conversation flow.
Over time, they provide more personalized and relevant responses.
How does an AI Chatbot work?
User sends a message
Chatbot analyzes the request to understand the user’s intent.
Chatbot determines the response using its training and data.
Chatbot sends a reply back to the user.
The more interactions the chatbot processes, the better and more accurate its responses become.
Chatbot Uses
AI chatbots are widely used across platforms such as social media messaging apps, standalone messaging systems, websites, and even phone calls (known as Integrated Voice Response, or IVR).
Popular Uses Cases:
Timely, always-on assistance for customer service or human resource issues.
Types of Chatbots
Task-Oriented Chatbots (Rule-Based):
Focus on specific tasks like answering FAQs or performing simple actions.
Structured and rule-based, ideal for support functions.
Example: A bot that shares business hours or tracks an order.
Data-Driven and Predictive Chatbots (Virtual Assistants):
Use AI and ML to anticipate needs, personalize responses, and improve with time.
Can handle complex conversations.
Examples: Amazon Alexa and Apple Siri.
Key Things to Know Before You Start
You need to understand a few key concepts before building a chatbot
Intent: The intent of a question like "What's the weather like today?" is to get weather information.
Response: The chatbot's reply is based on what the user asked.
Entity: The entity refers to the specific details in a message. For example, in "Book a flight to Paris," Paris is the entity, and the intent is "Book a flight."
Training: This is teaching your chatbot to understand different ways users might ask the same thing. It helps the chatbot improve over time.
Now that you have these ideas in mind, you may begin building your first chatbot.
Step 1: Create Your Agent in Dialogflow
An agent is a virtual assistant that handles conversation with users. Your job is to design and and build an agent to handle different type of conversations.
1.1 Log into Dialogflow Console:
Go to the Dialogflow Console.
Sign in with your Google account.
1.2 Create a New Agent:
Click on "Create Agent."
Name your agent (e.g., "Healthcare Assistant").
Set the default language and time zone.
Click "Create" to finalize.
Step 2: To Create an Intent in Dialogflow
Next, you need to create an intent (what your user wants to achieve).
2.1 How to Create an Intent:
Navigate to the "Intents" Section:
Click on "Intents" from the left-hand menu.
Click on "Create Intent."
Create the Intent - “BookAppointment”:
Name the intent "BookAppointment."
After saving your intent, you’ll see a "Successfully Intent Saved" popup in the bottom-right corner of your screen
3. Add Training Phrases:
Training phrases are examples of what users might say to trigger this intent. For a healthcare chatbot, you can add phrases like:
"I want to book an appointment with a doctor."
"Schedule a check-up for me."
"Can I see a specialist this week?"
"I need an appointment for my child."
Each time you add a phrase, press Enter to save it.
4. Define the Response
In the "Responses" section, specify how the bot should respond. For example:
“Sure! Could you please tell me the doctor’s specialty? "
5. Save Your Intent
Once you’ve added the training phrases and responses:
Click on the "Save" button to complete the setup.
Step 3: Add Follow-Up Intents
Follow-up intents help maintain the conversation flow by gathering further details. Here’s how you can add them for the “BookAppointment” intent:
3.1 Example Follow-Up Intents:
After clicking follow-up intent, select custom and Rename->BookAppointment - Specialty->Save.
After creating First Follow-up Intent, Flow looks like as below
1. Follow-Up Intent: “BookAppointment - Specialty”
Purpose: Ask for the doctor’s specialty.
Training Phrases:
"Cardiologist."
"Pediatrician."
"I need a dentist."
Response:
“Noted! When would you like to visit for your appointment?”
Entity Creation Note:
"If you don't have an entity to capture doctor specialties yet, please refer to Step 4 to learn how to create a custom entity for this purpose."
2. Follow-Up Intent: “BookAppointment - Date/Time”
Purpose: To ask for the preferred date and time.
Training Phrases:
"Tomorrow at 10 AM."
"Next Monday at 5 PM."
"Any day this week after 3 PM."
"December 20th at 2 PM".
Response:
“Thank you! Could you please provide your name and contact details for confirmation?”
3. Follow-Up Intent: “BookAppointment - NameContact”
Purpose: Collect the user’s name and contact information.
Training Phrases:
"My name is Sree, and my number is 901-555-6789."
"I’m Jaggat, you can call me at 901-123-4567."
Response:
"Thank you $person! Could you please confirm your details:
Doctor: $doctor-specialty
Date and Time: $date at $time
Name: $person
Contact: $phone-number?
Does everything look correct?”
Parameter Handling:
To retrieve all details accurately, ensure the following parameters are captured: $person, $phone-number, $doctor-specialty, $date, $time.
Steps to Link Parameters Between Intents:
Go to the BookAppointment-Speciality intent and define the $doctor-specialty parameter under the output context.
Include the same name in the input context of the BookAppointment-NameContact intent.
Ensure consistent naming across intents and responses for seamless data transfer.
To retrieve the respective details of the doctor, date, and time, we must use the following format to obtain values in another intent:
doctor-specialty: This is the parameter name assigned in the BookAppointment-Specialty Intent.
@doctor-specialty: This represents the entity name.
#specialty-doctor-specialty: In this format, "specialty" denotes the context name that is used to link the two intents, while "doctor-specialty" specifies the parameter name.
Repeat this process for capturing $date and $time parameters.
Pro Tip: Always check for consistent parameter names and spelling in your chatbot configuration. Misalignment will prevent the chatbot from processing the user's request.
4. Follow-Up Intent: “BookAppointment - Confirmation-Yes”
Navigation: BookAppointment - NameContact ->BookAppointment - Confirmation-Yes(follow-up intent)
Purpose: Confirm all the details of the appointment.
Training Phrases:
“Yes, that’s correct.”
“Looks good!”
“No, I want to make changes.”
Response:
“Great! Your appointment is confirmed. You’ll receive a confirmation shortly. Have a nice day!”
5. Follow-Up Intent 5: BookAppointment - Confirmation - No
Navigation: BookAppointment - NameContact ->BookAppointment - Confirmation-No(follow-up intent)
Purpose: Handle situations when the user wants to make changes.
Response:
"Okay, let’s make the changes. Please let me know what needs to be updated."
Step 4: Create Entities and Parameters
Custom Entity: doctor-specialty
How to Create the Entity:
Navigate to Entities:
In the left-hand menu, click Entities.
Create Custom Entity:
Name the entity doctor-specialty.
Add sample values for doctor types like:
Cardiologist
Pediatrician
Dentist
Adding Parameters
Under the BookAppointment-Specialty intent, add a parameter to capture the doctor’s specialty.
Map the parameter (doctor-specialty) to the user’s input, such as "Cardiologist."
This parameter will appear in the Action and Parameters section.
Step 5: Using Entities in Responses
Dynamic Responses:
In the BookAppointment - NameContact intent, reference collected parameters dynamically. Use the syntax $parameter-name to personalize responses, such as:
"Your appointment with a $doctor-specialty is scheduled for $date at $time."
Example: "Thank you, Sree! Your appointment with a Cardiologist is scheduled for December 20 at 2:00 PM. Have a great day!"
Step 6: Save and Test the Flow
Save each intent as you create them.
6.1 How to Test in Dialogflow:
On the right side of the Dialogflow console, you’ll see a "Try It Now" panel.
Type a test message, like "Book an appointment with a cardiologist tomorrow at 10 AM."
Make sure each follow-up intent properly triggers and collects the necessary data.
Step 7: Test Using Web Demo
One of the easiest ways to test your bot is by using the Web Demo feature in Dialogflow. This doesn't require any coding!
7.1 How to Enable Web Demo:
Go to the “Integrations” section in Dialogflow.
Find the Web Demo option and click on it.
Turn it on.
7.2 Get the Web Demo URL:
Once enabled, Dialogflow will give you a link to a simple web page where you can test your chatbot.
Click the link, and you’ll see a chat interface where you can talk to your bot.
7.3. Get an Image for Your Bot
Steps to Add an Image to Your Bot:
Navigate to Settings:
Go to the Settings tab in your chatbot platform.
Access General Settings:
Under the General section, find the Description field.
Name Your Bot:
Give your bot a meaningful and relatable name that resonates with its function or audience.
Set Up the Image:
Find an image online that represents your bot’s personality.
Copy the URL of the image.
Paste this URL into the Agent Avatar URL field.
Test Without Code:
You don’t need to add any custom scripts. The Web Demo feature is ready to go. Just open the link, and you can start chatting with your bot.
Scenario: Book an appointment with a cardiologist tomorrow at 10 AM."
Summary
Create an Agent in Dialogflow.
Create Intents to handle user requests like booking appointments.
Add Follow-Up Intents to collect additional details like doctor specialty, date, time, name, and contact info.
Use Entities to capture data like specialty, date, time, and contact.
Define Parameters to store these values.
Use parameters in responses to confirm the appointment details and ensure the user gets the correct information.
Conclusion
For novices in particular, building a chatbot is an enjoyable and fulfilling endeavor. You don't need to know any code to design intents, test your chatbot, or even incorporate it onto your website with tools like Dialogflow. Your users will find your chatbot even more helpful as you keep making improvements to it.
What're you waiting for, then? Take the first step into the future of conversational AI by beginning to construct your chatbot right now!