简体   繁体   English

如何在dialogflow中验证用户表达

[英]how to validate user expression in dialogflow

I have created a pizza bot in dialogflow. 我在dialogflow中创建了一个比萨机器人。 The scenario is like.. 情况就像..

Bot says: Hi What do you want. Bot说:嗨,你想要什么。

User says : I want pizza. 使用者说:我要披萨。

If the user says I want watermelon or I love pizza then dialogflow should respond with error message and ask the same question again. 如果用户说I want watermelonI love pizza那么dialogflow应该以错误消息响应并再次询问相同的问题。 After getting a valid response from the user the bot should prompt the second like 在收到用户的有效回复后,机器人应提示第二个类似

Bot says: What kind of pizza do you want. Bot说:您想要哪种披萨。

User says: I want mushroom(any) pizza. 使用者说:我要蘑菇披萨。

If the user gives some garbage data like I want icecream or I want good pizza then again bot has to respond with an error and should ask the same question. 如果用户提供了一些垃圾数据,例如I want icecreamI want good pizza那么机器人必须再次以错误进行响应,并应该问同样的问题。 I have trained the bot with the intents but the problem is validating the user input. 我已经用意图训练了机器人,但是问题是验证用户输入。 How can I make it possible in dialogflow? 我如何才能在dialogflow中实现它? A glimpse of training data & output 培训数据和输出概览 交易数据

If you have already created different training phrases, then invalid phrases will typically trigger the Fallback Intent. 如果您已经创建了不同的训练短语,则无效的短语通常会触发“后备意图”。 If you're just using @sys.any as a parameter type, then it will fill it with anything, so you should define more narrow Entity Types. 如果仅使用@sys.any作为参数类型,则它将用任何东西填充它,因此您应该定义更窄的实体类型。

In the example Intent you provided, you have a number of training phrases, but Dialogflow uses these training phrases as guidance , not as absolute strings that must be matched. 在您提供的示例Intent中,您有许多训练短语,但是Dialogflow使用这些训练短语作为指导 ,而不是必须匹配的绝对字符串。 From what you've trained it, it appears that phrases such as "I want .+ pizza" should be matched, so the NLU model might read it that way. 根据您的训练,似乎应该匹配诸如“我想要。+披萨”之类的短语,因此NLU模型可能会这样读取。

To narrow exactly what you're looking for, you might wish to create an Entity Type to handle pizza flavors. 为了精确地缩小您要查找的内容,您可能希望创建一个实体类型来处理披萨口味。 This will help narrow how the NLU model will interpret what the user will say. 这将有助于缩小NLU模型如何解释用户的意见。 It also makes it easier for you to understand what type of pizza they're asking for, since you can examine just the parameters, and not have to parse the entire string again. 这也使得它更容易让了解他们在问什么类型的比萨饼了,因为你可以检查刚刚参数,而不必重新解析整个字符串。

How you handle this in the Fallback Intent depends on how the rest of your system works. 在“后备意图”中如何处理此问题取决于系统其余部分的工作方式。 The most straightforward is to use your Fulfillment webhook to determine what state of your questioning you're in and either repeat the question or provide additional guidance. 最简单的方法是使用“实现”网络挂钩来确定您所处问题的状态,然后重复问题或提供其他指导。

Remember, also, that the conversation could go something like this: 同样,请记住,对话可能会如下所示:

Bot says: Hi What do you want. Bot说:嗨,你想要什么。

User says : I want a mushroom pizza. 用户说:我要蘑菇披萨。

They've skipped over one of your questions (which wasn't necessary in this case). 他们已经跳过了您的一个问题(在这种情况下是不必要的)。 This is normal for a conversational UI, so you need to be prepared for it. 对于对话式UI,这是正常的,因此您需要为此做好准备。

The type of pizzas (eg mushroom, chicken etc) should be a custom entity. 披萨的类型(例如蘑菇,鸡肉等)应为自定义实体。

披萨口味的实体

Then at your intent you should define the training phrases as you have but make sure that the entity is marked and that you also add a template for the user's response: 然后,您应按自己的意愿定义培训短语,但要确保已标记实体,并且还要为用户的响应添加模板:

意图

There are 3 main things you need to note here: 您需要在此处注意3件主要事情:

  1. The entities are marked 实体已标记
  2. A template is used. 使用模板。 To create a template click on the quote symbol in the training phrases as the image below shows. 要创建模板,请单击培训短语中的引号,如下图所示。 Make sure that again your entity is used here 确保再次在此处使用您的实体
  3. Make your pizza type a required parameter. 将您的披萨类型设为必填参数。 That way it won't advance to the next question unless a valid answer is provided. 这样,除非提供有效答案,否则它不会前进到下一个问题。

从示例切换到模板,反之亦然

One final advice is to put some more effort in designing the interaction and the responses. 最后的建议是在设计交互和响应时付出更多的努力。 Greeting your users with "what do you want" isn't the best experience. 用“您想要什么”向用户打招呼并不是最好的体验。 Also, with your approach you're trying to force them into one specific path but this is not how a conversational app should be. 另外,您尝试使用这种方法将其强制进入一条特定的路径,但这并不是对话式应用程序应采用的方式。 You can find more about this here . 您可以在这里找到更多关于此的信息 A better experience would be to greet the users, explain what they can do with your app and let them know about their options. 更好的体验是与用户打招呼,说明他们可以使用您的应用做什么,并让他们知道他们的选择。 Example : - Hi, welcome to the Pizza App! 示例 :-嗨,欢迎使用Pizza App! I'm here to help you find the perfect pizza for you [note: here you need to add any other actions your bot can perform, like track an order for instance]! 我在这里是为了帮助您为您找到最理想的披萨[注意:在这里,您需要添加您的机器人可以执行的其他任何操作,例如跟踪订单]! Our most popular pizzas are mushroom, chicken and margarita? 我们最受欢迎的比萨饼是蘑菇,鸡肉和玛格丽塔? Do you know what you want already or do you need help? 您知道您想要的还是需要帮助?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM