Reputation: 39
Not sure how to use choiceprompt
private async Task<DialogTurnResult> PromptForRequestStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
return await stepContext.PromptAsync(
RequestPrompt,
new PromptOptions
{
Prompt = MessageFactory.Text("Please choose a location."),
RetryPrompt = MessageFactory.Text("Sorry, please choose a location from the list."),
Choices = ChoiceFactory.ToChoices(new List<string> { "1", "2", "3" }),
});
}
private async Task<DialogTurnResult> PromptForTutorialStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
// Save name, if prompted.
var context = stepContext.Context;
var location = stepContext.Result;
var greetingState = await UserProfileAccessor.GetAsync(context);
greetingState.Request = stepContext.Result as string;
await UserProfileAccessor.SetAsync(stepContext.Context, greetingState);
if (greetingState.Request == "1")
{
var opts = new PromptOptions
{
Prompt = new Activity
{
Type = ActivityTypes.Message,
Text = $"1- Login to OneDrive" + Environment.NewLine + "2- Upload a file" + Environment.NewLine + "3- Create a folder",
},
};
return await stepContext.PromptAsync(OneDrivePrompt, opts);
}
When I run the bot. The options show up and I can press the button with "1" to input 1. I am not sure how to make the next step of the waterfallstep work with the choiceprompt I used. The code worked when i was doing a simple textprompt. I changed it to choiceprompt and it does not work. What do I need to do to make it work?
Upvotes: 0
Views: 353
Reputation: 33379
I assume you're saying that the prompt with the id value in your RequestPrompt
variable is defined as a ChoicePrompt
?
If so a ChoicePrompt
's result will be a FoundChoice
instance. So, assuming the step that follows that prompt is the PromptForTutorialStepAsync
you show here, you would cast the result to a FoundChoice
and then use that API to access the actual value.
The simplest, though arguable not the most legible, way would be as follows:
var location = ((FoundChoice)stepContext.Result).Value;
Upvotes: 1
Reputation: 179
Do you have a repository to look at to see the difference between working and broken?
From the current glance, here are a couple of things to check: 1) The "return await stepContext.PromptAsync(OneDrivePrompt, opts);" looks like an unnecessary await. Let the Task class do it's work.
2) Do you know at which line the program stops?
Upvotes: 0