官术网_书友最值得收藏!

Using entities

In the First-President intent, you noticed that the intent had a problem answering the question who is the second president of USA? because the response was static, only replying with the first president, George Washington, and not the second president, John Adams, regardless of which ordinal positions were given by the user. Let's address this issue by dynamically creating the response using an entity:

  1. Let's start by creating an entity called president-number. In the first column, add the presidents' names, and in the second column, add the ordinals that match the president. The following screenshot shows the president-number entity:
Creating a president-number entity
  1. Now, create a new intent called Find President. Enter who is the first president of USA? in the User says textbox and then highlight the words first president and you will see that a drop-down pops out, where you can search and select the entity that you created, called president-number. The following screenshot shows the process of mapping the entity to the highlighted word:
Mapping an entity to a word

By accessing the entity value within the response, you have the ability to create a dynamic response that can map the ordinal value to the president's name. $president-number.original refers to the user's ordinal input, first president, and $president-number refers to the ordinal value mapped to the name George Washington in the president-name entity. The response The $president-number.original of $geo-country is $president-number creates a proper answer to the user's question about who was the first or second President of the USA. When you test this in Google Assistant in Dialogflow, you will see that the proper response gets returned: The second president of USA is John Adams.

  1. Now, create a second question that does not have a geo-country, USA: Who is first president?, and create an equivalent response The $president-number.original is $president-number. The FaqChatBot agent will be smart enough to figure out that if the geo-country is omitted in the question, the agent will use the response that does not have $geo-country. The following screenshot shows the completed Find President intent:
Find President intent
主站蜘蛛池模板: 牡丹江市| 轮台县| 洛扎县| 安塞县| 石屏县| 临桂县| 祁阳县| 南京市| 宁武县| 犍为县| 北安市| 米易县| 行唐县| 咸宁市| 永济市| 九江县| 天峨县| 财经| 临安市| 衡阳市| 砚山县| 宣武区| 芜湖县| 全南县| 南部县| 东兴市| 清镇市| 浪卡子县| 怀柔区| 裕民县| 和政县| 岳普湖县| 萨迦县| 长阳| 青铜峡市| 六盘水市| 阳山县| 高州市| 二手房| 图木舒克市| 贵阳市|