我正在为facebook messenger在azure bot框架中构建一个简单的自动响应机器人。
到目前为止,我有:
public async Task StartAsync(IDialogContext context)
{
await context.PostAsync("Welcome!");
context.Wait(MessageReceivedAsync);
}
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
{
var message = await argument;
if (message.Text.StartsWith("REPORT"))
PromptDialog.Choice(
context,
this.OnOptionSelected,
new List<string>() { "Good Driving", "Bad Driving"},
"Report Driver for?",
"Not a valid option", 3);
}
else
{
await context.PostAsync($"Thank you for messaging AutoConscience! We will get back to you shortly <br/> <br/>You can report drivers on the road by replying with REPORT followed by the license plate"
+"(REPORT ABC 123)");
context.Wait(MessageReceivedAsync);
}
}
public async Task OnOptionSelected(IDialogContext context, IAwaitable<string> argument)
{
var confirm = await argument;
if (confirm == "Good Driving")
{
//Having Trouble with the following
PromptDialog.Choice(context,
this.OnOptionSelected,
new List<string>() { "Used Signal", "Allowed Lane Merge", "Kept Intersection Open", "Followed Right of Way","Patient Driver","Defensive Driver","Nice Car"},
"Report Driver for?",
"Not a valid option", 3);
//await context.PostAsync("Good");
}
我希望在第一个之后显示另一个多选对话框,但是在用户从第一个对话框中选择后,僵尸程序会失败。提前谢谢!