Please enable JavaScript.
Coggle requires JavaScript to display documents.
Creating Your Chatbot - Coggle Diagram
Creating Your Chatbot
Integrate Chatbot to Telegram
Introduction
In this section, we will create a bot in Telegram, and link in to our agent here in Dialogflow. Get your Telegram app ready!
Step 1: Search "botfather" in Telegram
Botfather is a bot that can help us to create chatbots on Telegram. Search for botfather in Telegram.
Step 2: Press the "START" button
Hit the "START" button to begin creating our chatbot, and we will be guided through step by step.
Step 3: Create Your Chatbot
Type /newbot into the message bar.
Step 4: Give Your Chatbot a Name
Public users can search for your chatbot using this name, so it should be a unique name for you or your business.
Step 5: Chatbot Username (or Handle)
Earlier, we gave our chatbot a name, and here, we will give it a username. The username must end with _bot. Note that your chatbot cannot have the username abccarworkshop1234_bot, simply because I have taken up this username!
Step 6: Chatbot Token
You will see a token that is generated - this is a very long string of text and numbers. Keep this token private and secure, as anyone with the token can control your chatbot!
Step 7: In Dialogflow, Click "Integrations" and Select "Telegram"
In Dialogflow, we will now need to integrate our Dialogflow agent to our Telegram chatbot. Click on "Integrations" on the left panel, and scroll down to select "Telegram".
Step 8: Key Token Key into dialogflow
Enter the token generated by BotFather and press "START", then "CLOSE". Your bot is now live on Telegram!
Step 9: Try Your Live Chatbot
Search Telegram for your chatbot name (or search for the username). Give it a go and see how it works!
Summary
There are many platforms which we can link up our Dialogflow agent to. Here, we linked our agent to Telegram. If you are interested to link it up to another platform, you will similarly need to generate the Token from that portal.
Follow-up Intents
Introduction to Follow-up Intents
The user will respond with his vehicle type, but we have not programmed what our chatbot will do if the user replies "car" or "truck". To do so, we need to add a follow-up intent.
Step 1: Add Follow-up Intent for "Servicing"
Mouseover the "Servicing" intent, and click on "Add follow-up intent" > custom
Step 2: Configure the Follow-up Intent
You will see a new "Servicing - custom" intent. Click on it and configure the following:
Intent Name: Servicing - Car
Training Phrase: car
Response: For cars, it is a flat $300 for servicing. All checks and necessary parts replacement are included in this price.
Click "SAVE"
Now, try to type "i wanna do servicing" in the Test Console, and when prompted for the vehicle type, type "car" into the Test Console.
Step 3: Create Another Follow-up Intent under "Servicing" Intent
Create another follow-up intent under "Servicing" using the instructions below, and when done, your list of intents should look like the above.
Mouseover the "Servicing" intent again, and click on "Add follow-up intent" > custom. For this follow-up intent, configure as follows:
Intent Name: Servicing - Truck
Training Phrase: truck
Response: For truck, it is a flat $600 for servicing. All checks and necessary parts replacement are included in this price.
Train your Chatbot & Miscellaneous
Small Talk
On the left panel, click on "Small Talk" and enable small talk. By doing so, we can teach our agent how to reply to phrases like "thank you" and "you look great today" - just in case anyone decides to praise our bot.
You can even customise small talks, but we will leave you to explore that on your own.
Validation
Enable "Agent Validation" under Agent Setting
Dialogflow provides a validation feature to help us create high-quality agents. Agent validation results are available automatically whenever agent training is complete. These enable us to know if there are any issues with our agents.
To enable agent validation, click on the "Setting" icon, go to "ML Settings", then "Enable" Agent Validation and "TRAIN" your agent. Remember to click "SAVE".
Use the "Validation" Tool to Evaluate Chatbot
On the left panel, click on "Validation". Here, you can see any Info, Warning and Error that exists in your agent. Expand on the issues to read more on how you can improve your agent.
Training
Accessing Chat Conversations
On the left panel, click on "Training". Here, you can see all the conversations made with your chatbot, and manually train your chatbot better. (Note: All conversations can also be accessed from the History button.)
Training Based on Chat Conversations
For each end-user expression, if the agent correctly matches the intent, you can click on the tick icon. This allows the agent to definitively know it matches the intent correctly when it encounters the same phrase again in future.
Summary
In this section, we covered Small Talks, Agent Validation and Agent Training. It is important that we regularly review our chatbots and train it better, so that it can continually provide the responses desired by our customers.
Setup Intents in Dialogflow
Intents
We will begin this section by examining the "Default Welcome Intent" and "Default Fallback Intent", before going on to create the intents for ABC Automotive Workshop.
Default Intents and Create New Intents
By default, your agent is able to do two things:
1) Respond to welcome your user through the Default Welcome Intent
2) Respond to inform the user that it cannot comprehend through the Default Fallback Intent
Step 1: Click on "Default Welcome Intent"
The "Default Welcome Intent" and "Default Fallback Intent" are already there. Let's click on "Default Welcome Intent" and see what it says!
Step 2: Training Phrases (under Default Welcome Intent)
You now enter the "Default Welcome Intent". All changes made on this page will affect this intent.
Scroll down and you will see a list of Training Phrases. These are what the user might type to the chatbot. For example, the user could say "heya" or "greetings" etc.
Remember, training phrases are what the customer might type to the chatbot.
Step 3: Entities and Responses
Further down the "Default Welcome Intent" page, you will find there is a section for you to define parameters (and entities). We will discuss this later.
Scroll on down and you will see the "Responses" section. Based on what the end-user says, the agent will match to see if it is similar to the Training Phrases above, and if so, it's a match and the agent will reply any one of the text response.
You can also add a response variant -- give it a try. Type "Hello, I am Carrey. How can I help you?" into the text response variant.
Click "SAVE" at the top of the page. Your agent will begin to train itself, and the setting icon at the top left will be spinning. This will take about 10 minutes, so grab a coffee!
Step 4: Try the "Default Welcome Intent"
You can try out the Test Console on the right side of the screen. Type "hi hi" [hi space hi] into the console and see how your chatbot would respond.
Notice how "hi hi" is not an exact match with any of the Training Phrases, but the system still correct identifies the intent as the "Default Welcome Intent". Also, the response is any one from the list.
Try to type a few different ways that you would say hi to a chatbot, and see the response. At this time, you can also add more Training Phrases or/and Responses to this "Default Welcome Intent" if needed.
Step 5: Click "Save" and go back to "Intents"
Each time you add training phrases or responses, remember to click "SAVE" to apply all changes you made to the "Default Welcome Intent".
Now, click on "Intents" on the left panel to go back to the list of intent. Review "Default Fallback Intent", which is what happens when your chatbot cannot understand your user. Add in more Response Variants if needed.
Step 6: Create New Intents
We will build our chatbot such that the agent can handle different intentions of customers. To do so, click on "Intents" on the left panel, then click on "CREATE INTENT".
Step 7: Create Intent - "Types of Service"
Name the intent "Types of Service".
For this intent, we also need to think of different ways which customer will ask ABC Automotive Workshop about the types of services it provides. Add the following to training phrases, and think of even more ways customers might say this.
What service do you provide?
What Solutions do you offer?
Types of products and services offered
What do you specialize in?
What is the response ABC Automotive Workshop should given when someone asks the questions above? Under response, add a suitable response, such as the one below. You can have more variety, if you wish for different ways to reply the same thing:
Thanks for enquiring! We provide SERVICING and RENTAL for both CARS and TRUCKS. Let us know what you require so we can advise further.
Looking to service your car or truck? Look for us! Want to rent a car or truck? That's us!
Once you have keyed in the Training Phrases and Response(s), click the "SAVE" button at the top of the page. Give your agent some time as it begins to train itself.
Step 8: Add These Intents Too!
Create more intents as outlined in this document(opens in a new tab). Be sure to input the respective training phrases and responses for each intent.
Define Entities in Dialogflow
Creating Entities
Entities
Entities (parameters) are defined data which we wish to pick up from end-user expressions.
Follow through the steps to see how entities affect our chatbot.
Step 1: Create Entity
Click on "Entities", then click on "CREATE ENTITY".
Step 2: Creating Entity - "VehType"
Name this entity "VehType".
In this entity, we will only type in two possible values - "car" and "truck", since we assume ABC Automotive Workshop only handles these two types of vehicles.
Then click on the "SAVE" button.
Step 3: Go to "Rental" Intent to Add Parameter
In the "Rental" intent go to Actions and Parameters. We will add in the entity we created.
Key all information below (similar to image above):
Required: Yes
If user does not let us know the vehicle type, our chatbot will prompt.
Parameter Name: VehType
This is the Parameter name.
Entity:
VehType
This is the entity which we created earlier.
Value: $VehType
The $ symbol allows us to use this in our chatbot replies later.
IsList: No
We are expecting a singular item from the user (i.e. car/truck), not a list.
Prompts: What do you want to rent - car or truck?
If user doesn't mention, we will prompt for VehType using this.
Step 4: Modify Training Phrase to Recognize Entity
For all the training phrases under this intent, highlight the words "car" and "truck" and click
VehType:VehType
so that the agent will know they are defined entities.
Step 5: Test Your "Rental" Intent
On the Test Console, type this phrase:
"I would like to rent a vehicle."
Because we set the entity
VehType
as "Required", when the user does not mention whether he wishes to rent a "car" or "truck", your chatbot will prompt for
VehType.
Go on to type "car", and the following response will be sent to the user:
"We've got it! Visit our car workshop to rent a vehicle."
Step 6: Using Placeholders in Response
Notice now the response is "We've got it! Visit our car workshop to rent a vehicle."
With the use of an entity placeholder, you can use the entity value specified by the user. Under the intent "Rental", scroll down and modify the Response to "We've got it! Visit our car workshop to rent a $VehType."
Click "SAVE", and try to rent a vehicle again in the Test Console and see what happens!
Step 7: System Entities
Unlike
VehType
which is an entity we defined, there are system entities in Dialogflow, such as date, time, colour and numbers.
Add another parameter as shown in the image above, and modify the response by adding in "on $date". Remember to click "SAVE".
In your Test Console, type "i would like to rent a truck", and when prompted for when you would like to rent, try words like "Saturday", "Next Saturday", "tomorrow", etc...
Summary
Entities (parameters) are defined data which we wish to pick up from end-user expressions. Our bots can be trained to look out for such entities in the conversation to make conversations more meaningful.