I am attempting to write a bot which would allow users to create a request (Example. I want to buy a t-shirt or I want to fix my computer ). Depending on the request they pick, they will be asked a series of questions associated with that request; the questions are related directly to the request they choose. Currently I am attempt to iterate through this list of questions and use the PromptDialog.Text method to get the answers. However, this only asks the last question in the List and when an answer is given I get an error with invalid need: expected Wait, have Done as the message.
private async Task ListOfferings(IDialogContext context, IAwaitable<string> result)
{
string name = await result;
var offerings = Offerings.Where((x) =>
CultureInfo.CurrentCulture.CompareInfo.IndexOf(x.Name, name,
CompareOptions.IgnoreCase) >= 0
);
if (offerings.Count() != 0)
{
PromptDialog.Choice(context, CreateOffering, offerings, "Which of these would you like?");
}
else
{
await context.PostAsync(string.Format("Could not find an offering with name {0}", name));
context.Wait(MessageReceived);
}
}
private async Task CreateOffering(IDialogContext context, IAwaitable<Offering> result)
{
var offering = result.GetAwaiter().GetResult();
await context.PostAsync(string.Format("***CREATING {0}***", offering.Name.ToUpper()));
foreach (var question in offering.Questions)
{
PromptDialog.Text(context, null, question.Question);
}
}
Is it possible to do something like this, where I want to dynamically decide the questions the user will be asked at runtime or am I required to take a more static, scripted approach?