Introduction to DialogFlow: Entities and Parameters
Let's continue improving our chatbot implemented on the Dialogflow platform. Previously, we created several rules, got familiar with training mode, and the chatbot learned to give more or less adequate responses to user phrases.
The next important functionality block in Dialogflow is entities. Essentially, entities are different forms of writing the same phrase or word - synonyms. In my chatbot example, I can describe synonyms for "excursion" in an entity. For example, "tour", "trip", "sightseeing" and so on.
How does the agent use entities?
Suppose there's a word or phrase in the user's request from the set defined in the entity. The agent marks such a substring as a parameter.
During rule formation, you probably noticed that some words are automatically marked in a different color. These are parameters. Dialogflow highlights cities and other locations, dates, numbers, and everything described in the entity as parameters.
These parameters can then be used in the "Action and parameters" section when creating rules. Let me explain.
For example, we ask the user: "In which city or hotel are you staying?"
The user responds: "I'm at the Hilton hotel".
The word "Hilton" is highlighted as a separate parameter, and we can access this parameter's value anywhere in the dialogue. In my example, after the user books an excursion, the chatbot can write something like: "The bus will pick you up from Hilton tomorrow at 07:00".
Contexts and Their Usage
Let's open any rule from the "Intents" section and focus on the first block called "Contexts".
Contexts are like sessions that store information from previous user and bot conversations. Let me explain. You have several rules (intents). Rules react to certain phrases. If the sequence of rule execution is important to you, then you need to use contexts.
Imagine your chatbot sells excursion tickets. You can't first offer the user to buy a ticket, and then tell them about the excursion and take their contact details. A sequence is needed. To maintain this sequence, you can use contexts.
Events
The next block in the rules is "Events". Using this block, you can make the rule execute only when we need a specific event.
For example, if you select "Telegram Welcome", the rule will execute during the user's first interaction with the bot when the user enters the /start command.
Advanced Responses
What if you want to send the user not just text, but an image or even buttons? In Dialogflow this is possible, although slightly more complex than in some other platforms.
Let's look closer at the Responses block, where you can configure the bot's reaction (responses) to user messages. Keep in mind, if you're setting up Dialogflow for integration with several messengers, these messengers' capabilities may differ from each other.
Fulfillment
This block is used to connect Dialogflow to other services and exchange data with them. For example, the agent can receive a request from the user, send a request to an external server (like a database), and get data from there.
Of course, programming is necessary. Don't worry, we'll return to "Fulfillment" in future lessons and explore it in more detail.