- Voice User Interface Projects
- Henry Lee
- 553字
- 2021-07-23 17:17:20
Creating your first intent
Let's create our first FAQ question in this section: who is the first president of USA?. Click on Intents (+) and name it First-President. Enter Who is the first president of USA? into the User says box, and enter The first president of USA is George Washington into the text response box.
The following screenshot shows the First-President intent that was created in Dialogflow:

First, notice that when you enter Who is the first president of USA? into the User says input box, the words first and USA are highlighted in yellow and orange, respectively. Dialogflow automatically identifies the word first as the type ordinal (@sys.ordinal) and the word USA as the type geo-country (@sys.geo-country) and basically creates a templatized question. The FaqChatBot agent will use those parameters to match against the user's question. You can think of the parameters as the keywords that you will be using to search with Google's search engine and the search engine returning a result relevant to the search terms. In the case of FaqChatBot, the agent will match the intent First-President to the user's inquiry and respond to the user with the text you entered in the Text response box.
The following screenshot shows debugging in the virtual Google Assistant in Dialogflow:

When you type who is the first president of USA?, it shows the matching intent name First-President, and two parameters, geo-country as United States of America and ordinal 1, which are used to match the intent. It also shows the answer to the intent that you previously entered in the Default Response and you can play the voice output by clicking on the PLAY button. All this metadata about the found intent is converted into JSON, which the backend server can use. You will learn more about this in Chapter 3, Building a Fortune Cookie Application. When you click on the SHOW JSON
button, you will see the request data in the JSON format.
Important properties that are useful to observe in the given JSON are queryResult.parameters.geo-country and queryResult.parameters.ordinal, which contain extracted values that map to the entities automatically defined by Dialogflow. Also, queryResult.intent.displayName contains the matching intent name. With this information, the backend server will be able to properly process the user requests. We will cover this in Chapter 3, Building a Fortune Cookie Application.
The following code shows the request data in JSON:
{
"responseId": "0c50fd61-dd7e-4c91-a11a-eaebdaa1a412",
"queryResult": {
"queryText": "who is the first president of USA?",
"parameters": {
"geo-country": "United States of America",
"ordinal": 1
},
"allRequiredParamsPresent": true,
"fulfillmentText": "The first president of USA is George Washington.",
"fulfillmentMessages": [
{
"text": {
"text": [
"The first president of USA is George Washington."
]
}
}
],
"intent": {
"name": "projects/faqchatbot-9417a/agent/intents/40991159-4a3e-4cfe-95ac-9be610220f51",
"displayName": "First President"
},
"intentDetectionConfidence": 0.75,
"diagnosticInfo": {},
"languageCode": "en"
}
}
Lastly, if you enter who is the second president of USA?, you will notice that you get the exact same response, except the ordinal will be 2 and the response you get is George Washington as the second president, which is not the correct answer. In the next section, you will learn how to utilize entities to address this problem.
- Mastering JavaScript Functional Programming
- Kali Linux Web Penetration Testing Cookbook
- 軟件架構設計:大型網站技術架構與業務架構融合之道
- Spring Cloud、Nginx高并發核心編程
- Mastering Unity Shaders and Effects
- ElasticSearch Cookbook(Second Edition)
- C語言程序設計習題與實驗指導
- 從程序員角度學習數據庫技術(藍橋杯軟件大賽培訓教材-Java方向)
- 從Excel到Python數據分析:Pandas、xlwings、openpyxl、Matplotlib的交互與應用
- Struts 2.x權威指南
- Backbone.js Testing
- Clojure Polymorphism
- Offer來了:Java面試核心知識點精講(框架篇)
- 人件集:人性化的軟件開發
- Python程序員面試算法寶典