Reputation: 13
I am working on a bot framework project (C# - Bot Framework v4) which contains at least 2 dialogs. I want to transfer informations that I've created (not from the user) from a first dialog to another one. How can I do it ?
I tried to set the second parameter of the BeginDialogAsync function but it was empty on the arrival.
EDIT :
I have a first dialog (SignInDialog) which is used to connect the user with OAuthPrompt. When the user is connected, in the same class, I will then handle his intent with the Dispatcher (Microsoft) and LuisRecognizer, to tell if I have to use QnA or LUIS.
What I am trying to do is to call a specific dialog located in another Dialog class (PersonalInfoDialog), according to the user's intent. But whenever I pass some arguments to the BeginDialogAsync
method, I don't find a way to get it from the destination dialog.
SignInDialog class
private async Task<DialogTurnResult> PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
}
private async Task<DialogTurnResult> DispatchStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var tokenResponse = (TokenResponse)stepContext.Result;
if (tokenResponse != null)
{
var recognizerResult = await BotServices.Dispatch.RecognizeAsync(stepContext.Context, cancellationToken);
var topIntent = recognizerResult.GetTopScoringIntent();
var intent = topIntent.intent;
switch (intent)
{
case "CASE_1":
return await stepContext.BeginDialogAsync(nameof(PersonalInfoDialog), recognizerResult, cancellationToken);
case "CASE_2":
...
default:
Logger.LogInformation($"Dispatch unrecognized intent: {intent}.");
break;
}
}
return await stepContext.EndDialogAsync(null, cancellationToken);
}
PersonalInfoDialog class
Here, in debug mode, test is null.
private async Task<DialogTurnResult> PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var test = stepContext.Options as LuisResult;
return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
}
Thanks for the help.
Upvotes: 1
Views: 534
Reputation: 361
If I understood you correctly and you really have no other options to transfer the data in one Waterfall-Dialog:
You could use state property accessors to store/ load the data.
In the Docs you find a example. Have a look at the UserProfile
: https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-state?view=azure-bot-service-4.0&tabs=csharp
And for more information I recommend the Doc article about states: https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-concept-state?view=azure-bot-service-4.0
Upvotes: 1