Reputation: 810
I want to initiate a dialog proactively with BotBuilder in C#. Proactive message works fine, but I want to initiate a dialog. They way I would do it is with the dialogSet within my Bot class, but in this case I'm on another class executing the callback and don't have access to the dialogSet. What's the correct approach to do this?
Upvotes: 1
Views: 642
Reputation: 810
I just found what the problem was. I solved it by:
var _dialogSet = new DialogSet(accessors.DialogStateAccessor);
_dialogSet.Add(new CrazyDialog("CrazyDialog"));
DialogContext dc = await _dialogSet.CreateContextAsync(turnContext, cancellationToken);
await dc.BeginDialogAsync("CrazyDialog", cancellationToken);
await accessors.ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);
Upvotes: 5