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

馋奶兔 提交于 2019-12-13 03:32:15

问题


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?

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.

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?


回答1:


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 - 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.

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.



来源:https://stackoverflow.com/questions/56453199/how-to-create-a-step-waterfall-inside-the-virtual-assistant-where-the-steps-are

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!