Как получить значение внутри, если еще в диалоговом окне шага водопада и передать его на следующий шаг?
Пожалуйста, обратитесь к коду ниже, спасибо. Спасибо за любую помощь, спасибо.
ОБНОВЛЕНИЕ: выбор «Рядом со мной» работает нормально, но при выборе «Где-то еще» возникает ошибка.
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