问题
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 selectionLoopStepAsync
- 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