我使用Dialogs创建了一个简单的基于规则的bot。我使用bot框架将Cortana频道添加到我的机器人中。为此,我使用我在浏览机器人框架中的个人Outlook帐户登录。我也在Azure中发布了我的机器人。但是当我在Cortana中调用机器人的调用名称时,它显示了机器人并且它已连接。但问题是,它没有回答我的问题。但我检查了bot框架模拟器,代码正在运行并给出正确的回复。任何人都可以解决我的问题吗?
using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
namespace SuperheroesBot.Dialogs
{
[Serializable]
public class RootDialog : IDialog<object>
{
public Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
return Task.CompletedTask;
}
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
string receiveMessage = activity.Text;
string returnMessage = "Hi How are you";
if (receiveMessage == "Yes Are you Ready")
{
returnMessage = "Yeah am ready";
}
else if (receiveMessage=="i am fine")
{
returnMessage = "nice you can ask me questions";
}
else if (receiveMessage=="what are the houses available now")
{
returnMessage = "Blue red green and yellow";
}
else if (receiveMessage == "who is going to win")
{
returnMessage = "i don't know. can u guess it";
}
else if (receiveMessage == "blue")
{
returnMessage = "alright.let's see";
}
await context.SayAsync(text: returnMessage, speak: returnMessage);
context.Wait(MessageReceivedAsync);
}
}
}
答案 0 :(得分:0)
检查您设备的区域和语言设置。他们需要被设置到美国来调用Cortana Skill的机器人。见Microsoft Cortana Skills FAQ
- &GT;在SayAsync()之后有一个等待语句小心使用wait语句。它们在context.forward,context.call方法之后抛出错误。如果取消注释等待语句有帮助,请尝试。除此之外不知道可能是什么问题。