如何根据自己的答案设置提示?
目前我有这段代码:
await context.PostAsync(this._questionGroups[0].Questions[_currentQuestion].Text);
但是我想做点什么:
var question = this._questionGroups[0].Questions[_currentQuestion];
var questionText = question.Text;
var answers = question.Answers;
PromptDialog.Choice(context, StepTwoQuestionsAsync, answers, questionText);
但它看起来没有用。 有人可以帮忙吗?
答案 0 :(得分:0)
经过一些麻烦并使用他们的(废话)文档后,我设法解决了这个问题:
private async Task AskQuestion(IDialogContext context, IAwaitable<IMessageActivity> result)
{
// Get our activity
var activity = await result;
// Get our question and answers
var question = this._questionGroups[_currentStep].Questions[_currentQuestion];
var questionText = question.Text;
var answers = question.Answers.Select(m => m.Text).ToList();
var options = new PromptOptions<string>(questionText, options: answers);
// Ask our question
Choice<string>(context, GetAnswer, options);
}
private async Task GetAnswer(IDialogContext context, IAwaitable<string> result)
{
// Ask our question
await context.PostAsync("Does this work?");
// If our category is a camera, forward to our QuestionDialog
await context.Forward(new StepTwoDialog(), ResumeAfter, new Activity { Text = await result }, CancellationToken.None);
}
很容易理清。
答案 1 :(得分:0)
搜索abou bots和QnA,它最适合您所寻找的......