Use ContinueDialogAsync in ProActive message after ending dialog turn

1

I am trying to 'pause' a bot conversation and resume it via a ProActive Message.

The way I have been trying to do so is by ending the dialog turn to 'pause' the conversation. Following I'm using ContinueDialogAsync in my ProActive message to 'resume' the conversation. Below is how I'm doing this as part of the ProActive message:

DialogManager dialogManager = new DialogManager(this.resourceExplorer.LoadType<AdaptiveDialog>(this.resourceExplorer.GetResource("echobot-final.dialog")));
dialogManager.UseResourceExplorer(this.resourceExplorer);
dialogManager.UseLanguageGeneration();

var conversationStateAccessors = conversationState.CreateProperty<DialogState>(nameof(DialogState));
var dialogSet = new DialogSet(conversationStateAccessors);
dialogSet.Add(dialogManager.RootDialog);
var dialogContext = await dialogSet.CreateContextAsync(turnContext, cancellationToken);

However, when running the ContinueDialogAsync after the dialog turn had been ended previously, I run into this error:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.Bot.Builder.Dialogs.Adaptive
  StackTrace:
   at Microsoft.Bot.Builder.Dialogs.Adaptive.Generators.ResourceMultiLanguageGenerator.TryGetGenerator(DialogContext dialogContext, String locale, LanguageGenerator& languageGenerator)

I'm not getting this NullReferenceException though when removing the EndTurn from the dialog, so I believe I my dialogContext object should be correct?

Am I misunderstanding the concept of ending a dialog turn?

What is the correct approach to pause a conversation, and resume the conversation later?

botframework
azure-bot-service
bot-framework-composer
asked on Stack Overflow Jun 25, 2020 by bartbilliet • edited Jun 27, 2020 by bartbilliet

1 Answer

2

In the Bot Framework, a turn is the time between the bot receiving an activity in an HTTP request and the bot responding to that request. Note that responding to an HTTP request is different from replying to an activity. The bot can reply by sending new activities to ABS in their own HTTP requests, and it can do this many times in a turn. The HTTP response is not another activity, it's just a status code (like 200 OK) that signifies the end of the turn.

There's not really a concept of a "dialog turn." There are "steps" in waterfall dialogs and adaptive dialogs, though they don't correlate to turns since a step can span multiple turns and a turn can span multiple steps. There is an "End Dialog Turn" action in adaptive dialogs which I think is what you're talking about, but it just ends the turn. The word "Dialog" may be superfluous/misleading there.

There also isn't really a concept of "pausing" a conversation. A conversation is understood to be a series of turns and activities exchanged between a bot and one or more users. Your bot always needs to know what to do about every request that reaches its endpoint, so it's up to you to define what pausing a conversation means.

I'm guessing you want the bot to respond differently or not respond at all while the conversation is paused. You will need some sort of bot state for the bot to know that it's paused for a given user or conversation, and dialogs use bot state so a dialog would do. Whatever you do to indicate to the bot that the conversation is paused, you can just undo it to unpause it. Just ending the turn won't work because that doesn't add anything to state and the next turn will start as soon as the user sends a message.

answered on Stack Overflow Jul 3, 2020 by Kyle Delaney

User contributions licensed under CC BY-SA 3.0