How to get the value inside if else in a waterfall step dialog and pass it to the next step? Please refer to the code below thank you. Any help is appreciated thank you.
UPDATE: Choosing "Near me" is working fine but when choosing "Somewhere Else" it's getting an error.
AddStep(async (stepContext, cancellationToken) =>
{
var realEstateType = stepContext.Result as FoundChoice;
var state = await (stepContext.Context.TurnState["FPBotAccessors"] as FPBotAccessors).FPBotStateAccessor.GetAsync(stepContext.Context);
state.RealEstateType = realEstateType.Value;
return await stepContext.PromptAsync("choicePrompt",
new PromptOptions
{
Prompt = stepContext.Context.Activity.CreateReply("Which location are you considering?"),
Choices = new[] {new Choice {Value = "Near me"},
new Choice {Value = "Somewhere else"}
}.ToList()
});
});
AddStep(async (stepContext, cancellationToken) =>
{
var nearOrSomewhereElse = stepContext.Result as FoundChoice;
var state = await (stepContext.Context.TurnState["FPBotAccessors"] as FPBotAccessors).FPBotStateAccessor.GetAsync(stepContext.Context);
state.NearOrSomewhereElse = nearOrSomewhereElse.Value;
var value = "";
if (state.NearOrSomewhereElse == "Somewhere else")
{
await stepContext.PromptAsync("textPrompt",
new PromptOptions
{
Prompt = stepContext.Context.Activity.CreateReply("Which location are you considering?")
});
value = stepContext.Result as string; // i think this is the error. How can i get the result of the block of code inside this if block?
}
else if (state.NearOrSomewhereElse == "Near me")
{
value = "Near me";
}
return await stepContext.NextAsync(value, cancellationToken);
});
AddStep(async (stepContext, cancellationToken) =>
{
var nearOrSomewhereElse = stepContext.Result as string;
var state = await (stepContext.Context.TurnState["FPBotAccessors"] as FPBotAccessors).FPBotStateAccessor.GetAsync(stepContext.Context);
state.NearOrSomewhereElse = nearOrSomewhereElse;
return await stepContext.PromptAsync("choicePrompt",
new PromptOptions
{
Prompt = stepContext.Context.Activity.CreateReply($"Please indicate the size of {state.RealEstateType}"),
Choices = new[] {new Choice {Value = "Size 1"},
new Choice {Value = "Size 2"},
new Choice {Value = "Size 3"}
}.ToList()
});
});
enter code here