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

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

问题描述

我需要在运行时生成瀑布步骤,因为它们基于 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 和要在对话框中显示的文本以及它的控件类型 - 它使用 React-JSONSchema 和 UISchema 属性,如 本文档.这是我正在使用的外部 API.

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?

推荐答案

我设法通过使用 ComplexDialogBot 作为我的机器人如何工作的基础.

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.

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

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