Intent definition

As we said previously, the user's intent is their purpose, the ultimate goal. Examples are ordering something, wanting to activate something on the user window, looking for shows, or simply saying goodbye. A chatbot should be able to perform some actions based on the intent it detects from the user's message.

To create an intent, click on the plus icon next to Intents; the following window is opened:

In this window, we will have to set some parameters:

  • Intent name: The name of the intent.
  • Contexts: This is used to manage the flow of the conversation.
  • Events: This is a feature that allows you to invoke intents by an event name instead of a user query. Events can be used by external services to trigger Dialogflow intents, for example, Google Assistant's built-in intents.
  • Training phrases: The phrases that identify the intent must be reported in natural language. You can use both examples (example mode identified with the " icon) and templates (template mode identified with the @ icon). Other examples of sentences are provided, the more the agent will be intelligent or he will be able to better recognize the user requests and to resolve ambiguities.
  • Action and parameters: This specifies the possible action to be executed and its parameters that can be extracted from the dialogue.
  • Response: The answers to be returned to the user when the intent has been recognized must be reported. To make it more human-like, you can enter different variations for the same answer. The answers can also be parameterized, and depending on the integration used, they can consist of rich messages.
  • Fulfillment: Call a web service to connect your backend. Send the intent, parameters, and context to your Cloud function or a web service. Execute the necessary logic and respond with a written, spoken, or visual response.

When an example sentence is inserted, it is automatically noted, recognizing the parts that are collected as entity. An agent always contains a default fallback intent that collects all the cases in which no other intent has been recognized.

The first intent we want to insert has the purpose to specify the position related to our weather forecast. We said that an intent represents the user's purpose, so we need to think what questions the user may ask to receive weather forecasts. We need different intentions because there are many ways to ask the same thing. The process of identifying the intent is to map all the possible ways that the user can use to express an intent. The requests that we may expect from a user should be specified in the training phrases section. To start, let's insert the following phrases:

  • What's the weather like in Rome
  • How's the weather in Rome
  • Weather in Rome
  • Rome weather forecast

To insert a single phrase, simply add the user expression in the Training phrases text field and then press Enter to add another phrase. We will notice that the sentence will be added to our declaration of intent. In particular, we can see that the word Rome is highlighted. This means that it was noted as a parameter assigned to existing city entities, as shown in the following screenshot:

We continue to insert the sentences. After defining the location, it is necessary to define the time. It is clear that the user will need to know the predictions on a specific day, today or tomorrow for example. Then we also include these phrases:

  • What is the weather today
  • Weather for tomorrow
  • Weather forecast in Rome today

As before, the time parameter is also highlighted, this time with a different color. The last sentence is interesting as it contains both a date parameter and a geo-city parameter, as shown in the following screenshot:

To start, we leave the other fields as is and focus only on the answer that the chatbot will have to provide to the user. So far, we have not considered any external reference from which to retrieve the information requested by the user. This means that at least for now, we will have to insert vague answers like these:

  • I'm sorry, I do not have this information right now
  • Forecasts for $date are not available
  • The weather forecast for $date in $geo-city is not available

In the last two phrases, we have inserted the following reference entities: $date and $geo-city. So, when the agent responds, it takes into account the parameter values gathered and will use a reply that includes those values that it picked up.

Once we're done, we click on the Save button. The following messages appear at the bottom right of the window:

  • Intent saved
  • Agent training started
  • Agent training completed

The meaning is clear. Now that your agent can understand basic requests from the user, try out what you have made so far. To try the newly created agent, we can use the appropriate box available in the console at the top right. To do this, we simply need to type in a request. Let's try our agent by typing a slightly different request from the examples given in the Training phrases section. For example, we ask: Hows the weather in Rome today. After this, we press Enter and the following window is returned:

We can understand the frustration of the user who has not recovered the searched information, but we can already be satisfied as the agent has correctly interpreted the question and provided a plausible answer. Remember that, at least for now, the forecast data is not available and this is what the agent said. Also, as anticipated, the agent has identified the two reference entities and reused them to construct the response.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.161.193