如何在虚拟助手中创建步骤瀑布,其中步骤是在运行时生成的 AdaptiveCards?

How to create a step waterfall inside the Virtual Assistant where the steps are AdaptiveCards that are generated at runtime?

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

可以使用 AdaptiveCard class 在运行时创建自适应卡片,但就将这些添加到对话框堆栈而言,我可以在运行时调用 AddDialog() 并添加瀑布台阶?我的 API returns JSON 带有要在对话框中显示的文本以及它的控件类型 - 它使用 React-JSONSchema 和 UISchema 属性 根据 this documentation。这是我正在使用的外部 API。

The documentation for dialogs focuses on static content. Could I begin with an empty Waterfall and use something like beginDialog 还是我必须使用 CustomDialog 实现?

我设法通过使用 ComplexDialogBot 作为我的机器人工作方式的基础来实现这一点。

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

  • SelectionStepAsync - 向用户显示一个选择
  • LoopStepAsync - 处理用户输入并决定当前对话流程是应该进入下一步还是结束。

我用两个步骤(DisplayCardAsyncProcessCardAsync)创建了一个 WaterfallStep[],这与上面 class 中的方法类似。在我的例子中,我收集了所有可能的步骤,以及用于确定流程是否满足完成标准的逻辑,这意味着所有繁重的工作都发生在 ProcessCardAsync.[=18= 内]