In the previous post, we populated the mens-winners entity with a list of values. When you see the Entity in the Editor mode (as opposed to the raw mode you used for uploading CSV), you will see the following:
If you notice, I have added the column names Keys and Values to annotate this image. I think of this as a sort of “inverted dictionary” format. The first word you will type is the value of the dictionary (who won?), and the synonyms you will define will contain exactly one item, which is the key of the dictionary (which year). That is, winner = Pat Cash.
As we go further, you will see why we need to declare it in this inverted dictionary like format.
Declaring the Intent
I will start by declaring a single intent corresponding to the entity we have created. We want to know the winner of the Wimbledon’s mens title in a particular year.
So create a new Intent, and – this is very important – click on the apostrophe at the beginning of the User says textbox and toggle it to the @ sign.
When you click and toggle into the template mode, the apostrophe will turn into an @ sign. More importantly, you will be able to refer to the entities you have already created – by using the @ prefix you will see autocompletion options.
Now type out the following into the User says box (in three different User says boxes), while remembering to keep the text box in template mode (the default is example mode which has the apostrophe at the beginning)
Wimbledon men’s champion @mens-winners:mens-winners
Men’s Wimbledon winner @mens-winners:mens-winners
Who won the Wimbledon’s men’s championship in @mens-winners:mens-winners ?
If you remember from the previous FAQ bot, the goal is to create many variants of the same question. This helps API.AI understand the patterns which could be used when people are asking about the same thing.
In the section called Response, input the following:
The winner of the $mens-winners.original men’s Wimbledon championship was $mens-winners
Testing what we have till now
Now let us go to the test console and try the following query, you can see that the response is as expected.
Let us look at the format of the Response we just typed out. When we refer to $mens-winner, API.AI will use it as a placeholder for the “Value” of the entity. And if you remember the column names annotated from the picture above, when the user asks the question “who won men’s Wimbledon in 1982”, a few different things are going on under the hood.
In the next part, we will look “under the hood” and see what is happening.