我对 Bot Framework SDK V3 有疑问。选择答案后,机器人会回复,机器人会要求再次评分。这里有截图。 在这里我的代码:
private const string fiverate = "★★★★★";
private const string fourrate = "★★★★";
private const string threerate = "★★★";
private const string tworate = "★★";
private const string Onerate = "★";
public async Task ShowRating(IDialogContext context)
{
PromptDialog.Choice(context,this.OnOptionRating, new List<string>() { fiverate,fourrate,threerate,tworate,Onerate }," "," ",3);
}
private async Task OnOptionRating(IDialogContext context, IAwaitable<string> result)
{
try
{
string optionSelected = await result;
switch (optionSelected)
{
case fiverate:
await context.PostAsync("Five Star");
context.Done(String.Empty);
break;
case fourrate:
await context.PostAsync("Four Star");
context.Done(String.Empty);
break;
case threerate:
await context.PostAsync("Three Star");
context.Done(String.Empty);
break;
case tworate:
await context.PostAsync("Two Star");
context.Done(String.Empty);
break;
case Onerate:
await context.PostAsync("One Star");
context.Done(String.Empty);
break;
}
}
catch (TooManyAttemptsException ex)
{
await context.PostAsync($"Ooops! Too many attemps :(. But don't worry, I'm handling that exception and you can try again!");
context.Wait(this.MessageReceivedAsync);
}
}
有什么更好的解决方案吗?我从 Stack Overflow 参考了这么多示例,但仍然没有找到解决方案。
谢谢你。