Proactive Waterfall Dialog don't continue in Microsoft Bot

大兔子大兔子 提交于 2020-05-30 08:43:07

问题


There. I am trying to implement Proactive Waterfall dialog to start dialog from external service.

I have implemented CompoenentDialog called SimpleDialogWithCardAndActions, configured it in IBot and now I can start this dialog manually and continue dialog after clicking buttons. It works fine as expected.

Then I have created Controller's action method which is starts proactive dialog

   private async Task BotCallback(ITurnContext turnContext, CancellationToken cancellationToken)
        {
              var conversationStateAccessors = conversationState.CreateProperty<DialogState>(nameof(DialogState));
              var dialogs = new DialogSet(conversationStateAccessors);

              var dialogAccessor = conversationState.CreateProperty<SimpleDialogWithCardAndActionsState>(nameof(SimpleDialogWithCardAndActionsState));
              dialogs.Add(new SimpleDialogWithCardAndActions(dialogAccessor));

              var dc = await dialogs.CreateContextAsync(turnContext, cancellationToken);
              var results = await dc.ContinueDialogAsync(cancellationToken);
              if (results.Status == DialogTurnStatus.Empty)
              {
                  await dc.BeginDialogAsync(nameof(SimpleDialogWithCardAndActions), null, cancellationToken);
                  await conversationState.SaveChangesAsync(dc.Context, false, cancellationToken);
              }

              await userState.SaveChangesAsync(turnContext, false, cancellationToken);
              await conversationState.SaveChangesAsync(turnContext, false, cancellationToken);
        }

This code successfully executed and display card as expected and I can even tap button and send an activity and handle it in IBot, but it does not continue waterfall dialog within await dc.ContinueDialogAsync(cancellationToken);. I guess that context is lost, but as you can see above, I have saved ConvesationState which is also injected to both IBot and Controller as a Singletone.

So my question is: Is it possible to continue proactive waterfall dialog in IBot if it was started within IBotFrameworkHttpAdapter from controller? If it is possible, how can I do that and what I did wrong?

FYI: IBotFrameworkHttpAdapter is used only to access ITurnContext and start dialog and IBot does not use it. Is it possible that I should use same BotAdapter instance for both notify Controller and IBot implementation?

UPD: I have change Bot-To-Controller binding mechanism and now IBot and NotifyController are using same singleton IBotFrameworkHttpAdapter and that is have no effect. Issue still relevant

来源:https://stackoverflow.com/questions/61885871/proactive-waterfall-dialog-dont-continue-in-microsoft-bot

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