如何在Virtual Assistant中创建步骤瀑布,其中步骤是在运行时生成的AdaptiveCard? [英] How to create a step waterfall inside the Virtual Assistant where the steps are AdaptiveCards that are generated at runtime?

查看:94
本文介绍了如何在Virtual Assistant中创建步骤瀑布,其中步骤是在运行时生成的AdaptiveCard?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在运行时生成瀑布式步骤,因为它们基于API响应-甚至可以使用WaterfallDialogWaterfallSteps吗?

I need to generate the waterfall steps at runtime, as they are based off an API response - is this even possible with the WaterfallDialog and WaterfallSteps?

可以使用AdaptiveCard类在运行时创建自适应卡,但是就将这些卡添加到对话框堆栈而言,我可以在运行时调用AddDialog()并添加瀑布步骤吗?我的API返回JSON以及要显示在对话框中的文本以及它的控件类型-它根据

Creating the adaptive cards at runtime can be done using the AdaptiveCard class but in terms of adding these to the dialog stack can I just call AddDialog() at runtime and add the waterfall steps? My API returns JSON with the text to display in the dialog as well as what kind of controls it - it uses React-JSONSchema and the UISchema property as per this documentation. This is an external API that I am working with.

beginDialog 还是与CustomDialog实现有关?

The documentation for dialogs focuses on static content. Could I begin with an empty Waterfall and use something like beginDialog or will I have to do with a CustomDialog implementation?

推荐答案

我设法通过使用

I managed to achieve this by using the ComplexDialogBot as the basis for how my bot would work.

更具体地说,在上面链接的类中,有两种感兴趣的方法:

More specifically inside the class linked above there are two methods of interest:

  • SelectionStepAsync-向用户显示选择内容
  • LoopStepAsync-处理用户输入并确定当前对话框流是应该移到下一步还是结束.
  • SelectionStepAsync - Presents the user with a selection
  • LoopStepAsync - Processes the user input and decides whether the current dialog flow should move to the next step, or be ended.

我用两个步骤(DisplayCardAsyncProcessCardAsync)创建了一个WaterfallStep[],与上述类中的方法类似.以我为例,我收集了所有可能的步骤,以及弄清楚逻辑流程是否满足完成条件的逻辑,这意味着所有繁重的工作都发生在ProcessCardAsync内部.

I created a WaterfallStep[] with two steps (DisplayCardAsync and ProcessCardAsync) which are analogous with the methods in the class above. In my case I had a collection of all the possible steps, along with the logic for figuring out whether completion criteria had been met for a flow which meant that all of the heavy lifting took place inside ProcessCardAsync.

这篇关于如何在Virtual Assistant中创建步骤瀑布,其中步骤是在运行时生成的AdaptiveCard?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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