具有复杂对话框流的顺序瀑布模型Bot Framework C#v4 [英] Sequential Waterfall Models with Complex Dialog flows Bot Framework C# v4

查看:91
本文介绍了具有复杂对话框流的顺序瀑布模型Bot Framework C#v4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个独立的瀑布模型,这些模型是由使用Luis的意图触发的. 我想依次链接这3个模型,我一直遵循

I have 3 Independent waterfall models which are triggered by intents using Luis. I want to link these 3 models sequentially, I have been following the PictureBot coding style, and each dialog/waterfall has it's on state properties.

3种瀑布方法如下

  • WaterFall_1-查询Azure搜索,基于用户提供的过滤器,响应是名称"列表
  • WaterFall_2-将执行一些REST操作,并从waterFall_1中获取名称
  • WaterFall_3-将再次执行一些REST操作,并取自WaterFall_1的名称

到目前为止,我一直在通过聊天窗口传递值,因为3个Waterfall步骤是松散耦合的,因此用户可以将它们作为bot的独立组件/功能进行调用,所以我的问题是

As of now, I have been passing the values through the chat-window, as the 3 Waterfall steps are loosely coupled, they can be called by the user as an independent component/feature of the bot, so my questions are

  1. 如何链接这三个模型,即在如果用户触发了Waterfall_1,并转到2或3,则将跳过询问用户"的对话框?我在想每个瀑布都需要全局和本地Getters和Setters.

  1. How do link the 3 Models, ie in If the user has triggered waterfall_1, and goes to 2 or 3, the dialog where the "Users" are asked is to be skipped? I am thinking that I would need both a Global and Local Getters and Setters for each Waterfall.

在WaterFall_1中,最后一个响应从Azure搜索发送查询结果,即名称",是否应该在endFendDialog之后立即调用,或者WaterFall_1调用WaterFall_2和/或WaterFall_3,然后我endDialog for 3, 2,1?

In the WaterFall_1, the last response sends the Query Result from Azure Search, ie the "Names", Should I endDialog right after or does the WaterFall_1 call the WaterFall_2 and/if WaterFall_3 and then I endDialog for 3,2,1?

该图形可能会提供更多上下文简单图形

The figure might give more context Simple figure

推荐答案

在您的问题1中,您的总体思路有所下降.您需要的是一个共享"或全局状态,与Bot Framework的状态类似 CafeBot (查看示例=> dotnet =>#50).

You have the general idea down, in your question 1. What you would need is a 'shared' or global state not unlike the state demonstrated in the Bot Framework's CafeBot (Look under samples => dotnet => #50).

如果设置了全局"状态,则可以将在Waterfall 1中检索到的用户名列表保存到该列表中.然后,当通过LUIS意图调用第二个或第三个瀑布时,会将状态1的状态访问器传递给瀑布2的父类,从而使其他瀑布可以访问它们.

If you have a 'global' state set, you could save the list of user names retrieved in your Waterfall 1 to that. Then, when your second or third waterfall are called via your LUIS intents, you pass in the state accessor to the Waterfall 1 results to the parent class of Waterfall 2, thus making them accessible to the other waterfalls.

如果您依赖LUIS,则无需使它们连续.您可以使用LUIS来使搜索用户"触发WF1,对用户执行XYZ"触发2和对用户执行ABC"触发3.这将使您的机器人对机器人用户的僵化程度降低,因为他们可以进行搜索,然后根据需要执行2或3(或两者).

You would not need to make them sequential, if you're relying on LUIS. You could use LUIS to have 'Search Users' trigger WF1, 'Do XYZ to Users' trigger 2, and 'Do ABC to Users' trigger 3. This would make your bot less rigid for your bot users, as they could do a search, then do either 2 OR 3, (or both) as needed.

我能够通过简单地在Bot Framework MessageRoutingBot中添加一个基于瀑布的额外类(samples => dotnet =>#09)来模拟这一点

I was able to simulate this by simply adding an extra, waterfall based class to the Bot Framework MessageRoutingBot (samples => dotnet => #09)

这是收藏的动物"提示的瀑布设置,包括从原始示例漫游器访问greetingState:

Here is the waterfall setup for the 'Favorite Animal' prompt, including accessing the greetingState from the original sample bot:

public TestDialog(IStatePropertyAccessor<TestState> testStateAccessor, IStatePropertyAccessor<GreetingState> greetingStateAccessor, ILoggerFactory loggerFactory)
        : base(nameof(TestDialog))
    {
        TestStateAccessor = testStateAccessor ?? throw new ArgumentNullException(nameof(testStateAccessor));
        GreetingStateAccessor = greetingStateAccessor ?? throw new ArgumentNullException(nameof(greetingStateAccessor));

        // Add control flow dialogs
        var waterfallSteps = new WaterfallStep[]
        {
                InitializeStateStepAsync,
                PromptForAnimalStepAsync,
                // PromptForCityStepAsync,
                DisplayTestStateStepAsync,
        };
        AddDialog(new WaterfallDialog(ProfileDialog, waterfallSteps));

        // AddDialog(new TextPrompt(NamePrompt, ValidateName));
        AddDialog(new TextPrompt(AnimalPrompt));
    }

插入greetingState访问器后,它使我能够继续从第二个瀑布中按名称呼叫用户,而无需再次提示它:

With the greetingState accessor pulled in, it allowed me to continue to call my user by name, from a second waterfall, without needing to reprompt for it:

 private async Task<DialogTurnResult> GreetUser(WaterfallStepContext stepContext)
    {
        var context = stepContext.Context;
        var testState = await TestStateAccessor.GetAsync(context);
        var greetingState = await GreetingStateAccessor.GetAsync(context);

        // Display their profile information and end dialog.
        await context.SendActivityAsync($"Hi {greetingState.Name}, who likes {testState.Animal}s, nice to meet you!");
        return await stepContext.EndDialogAsync();
    }

希望这会有所帮助!

这篇关于具有复杂对话框流的顺序瀑布模型Bot Framework C#v4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆