简体   繁体   English

将LUIS实体放在子对话框中

[英]Getting LUIS entities inside a child dialog

I'm developing a bot using Bot Framework, LUIS and ActionBinding. 我正在使用Bot Framework,LUIS和ActionBinding开发机器人。

In one of my intent handlers I call a new Dialog which has the methods StartAsync(IDialogContext context) and ReceiveMessageAsync(IDialogContext context, IAwaitable<IMessageActivity> result) 在我的一个intent处理程序中,我调用了一个新的Dialog,它具有StartAsync(IDialogContext context)ReceiveMessageAsync(IDialogContext context, IAwaitable<IMessageActivity> result)

As I understand it, the messages typed by the user while waiting (with context.Wait(ReceiveMessageAsync) ) won't be sent to LUIS, right? 据我了解,用户在等待时输入的消息(使用context.Wait(ReceiveMessageAsync) )将不会被发送到LUIS,对吗?

So if I need to understand what the user is saying without having to parse the string, which are my options? 因此,如果我需要了解用户所说的内容而不必解析字符串,这是我的选择吗? Could call the ILuisService.QueryAsync with the message.Text for each message be an option? 可以用每个消息的message.Text调用ILuisService.QueryAsync作为选项吗?

I want to be able to detect entities typed by the user so I can map them to missing fields. 我希望能够检测用户键入的实体,以便将它们映射到缺少的字段。 For example in this conversation: 例如在这个对话中:

User: I want to book a flight.                   // LUIS detects intent
Bot: Ok. Can you tell me more about your flight? // child dialog is called to handle the rest of the conversation
User: I want to go to Madrid.
Bot: To fly to Madrid you can choose between company A, B or C.
User: I want to go with A tomorrow night
Bot: Ok, searching for available tickets for tomorrow night in A...

In this case there are no initial entities when the intent is detected, but there could be, and in that case the bot would not ask for the already given information. 在这种情况下,当检测到意图时没有初始实体,但是可能存在,并且在那种情况下,机器人不会要求已经给出的信息。

For my project, a simple Form with one to one question-answer is not enough. 对于我的项目,一个简单的表格与一对一的问答是不够的。 I also need to make more validations and confirmations on previously set parameters if the user wants to change one or more parameters (ie, I need to go back to all parameters and check if the changed parameter affects them). 如果用户想要更改一个或多个参数,我还需要对先前设置的参数进行更多验证和确认(即,我需要返回所有参数并检查更改的参数是否影响它们)。 For example: 例如:

User: Wait, I want to fly to Barcelona instead.
Bot: Company A does not fly to Barcelona. You can choose between C and D.
User: Ok I want to fly with C.
Bot: There are tickets available for tomorrow night in company C. Keep the flight for tomorrow night?
User: yes.

Any tips or guidance for best practices would help a lot. 任何有关最佳实践的提示或指导都会有很大帮助。

Thanks in advance. 提前致谢。


Edit: 编辑:

With the Sub Action solution, where would my validators operate? 使用Sub Action解决方案,验证器在哪里运行? On the FulfillAsync method? 在FulfillAsync方法? I'd need to validate and then send a question to the user and understand the reply he sent (parsing entities). 我需要验证然后向用户发送问题并理解他发送的回复(解析实体)。 Would that be possible inside a LuisAction? 这可能在LuisAction中可行吗?

I'd like to use the QueryValueFromLuisAsync but after looking at it, I'd need to pass the paramName , which is one of the action properties (if i'm not mistaken) and that is what I'm trying to avoid. 我想使用QueryValueFromLuisAsync但在查看之后,我需要传递paramName ,这是一个动作属性(如果我没有记错的话),这就是我想要避免的。 I don't want to map one answer (ie, message.Text) to one field, i want to map one answer to multiple fields. 我不想将一个答案(即message.Text)映射到一个字段,我想将一个答案映射到多个字段。

Let's say i need to fill a model that has 6 properties. 假设我需要填充具有6个属性的模型。 If the bot asks one question to the user and in his reply there are 3 entities I want to map those entities to 3 fields and only make questions about the remaining non mapped fields afterwards. 如果机器人向用户询问一个问题,并且在他的回复中有3个实体我想将这些实体映射到3个字段,并且之后只对剩余的非映射字段提出问题。

My first reaction to this is to avoid using a custom child dialog and go with SubActions and create your own validators if you want to have complex logic there or even override the IsValid method from the sub action. 我对此的第一反应是避免使用自定义子对话框并使用SubActions并创建自己的验证器,如果你想在那里有复杂的逻辑,甚至从子操作覆盖IsValid方法。

However, if that's not a possibility, then I would consider reusing the QueryValueFromLuisAsync method, where the action should be the model you want to interact with. 但是,如果这不可能,那么我会考虑重用QueryValueFromLuisAsync方法,其中操作应该是您要与之交互的模型。 That function will end up calling LUIS and will try to assign the result or return another intent/action depending on the scenario. 该函数将最终调用LUIS并将尝试分配结果或返回另一个意图/操作,具体取决于方案。 I would give this a try. 我试试看。

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

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