C# 机器人程序框架-无法连接Luis-AI对话框

C# 机器人程序框架-无法连接Luis-AI对话框,c#,botframework,azure-language-understanding,C#,Botframework,Azure Language Understanding,下面是从我的机器人应用程序与LUIS-AI通信的源代码。当我尝试沟通时,我总是得到拒绝访问的回应。我不知道我错过了什么 [LuisModel("8c9285fb-198a-4f49-8fe4-b08ac5541ac2", "5c47c63887e346c2aee24d1755e07d29")] [Serializable] public class LUISDialog:LuisDialog<RoomReservation>

下面是从我的机器人应用程序与LUIS-AI通信的源代码。当我尝试沟通时,我总是得到拒绝访问的回应。我不知道我错过了什么

 [LuisModel("8c9285fb-198a-4f49-8fe4-b08ac5541ac2", "5c47c63887e346c2aee24d1755e07d29")]
    [Serializable]
    public class LUISDialog:LuisDialog<RoomReservation>
    {
        private readonly BuildFormDelegate<RoomReservation> Reservation;

        public LUISDialog(BuildFormDelegate<RoomReservation> reservceRoom)
        {
            this.Reservation = reservceRoom;
        }
        [LuisIntent("")]
        [LuisIntent("None")]
        public async Task None(IDialogContext dialogContext, LuisResult luisResult)
        {
            await dialogContext.PostAsync("I am sorry I don't know what you mean ");
            dialogContext.Wait(MessageReceived);
        }

        [LuisIntent("Greeting")]
        public async Task Greeting(IDialogContext dialogContext, LuisResult luisResult)
        {
         dialogContext.Call(new GreetingDialog(), CallBack);
        }

        private async Task CallBack(IDialogContext context, IAwaitable<object> result)
        {
            context.Wait(MessageReceived);
        }

        [LuisIntent("Reservation")]
        public async Task RoomReservation(IDialogContext dialogContext, LuisResult luisResult)
        {
            FormDialog<RoomReservation> enrollmentForm =new FormDialog<RoomReservation>(new RoomReservation(),this.Reservation, FormOptions.PromptInStart);
            dialogContext.Call(enrollmentForm, CallBack);
        }

        [LuisIntent("QueryAmenities")]
        public async Task QueryAmenities(IDialogContext dialogContext, LuisResult luisResult)
        {
            foreach (var entity in luisResult.Entities.Where(entity=>entity.Type=="Amenity"))
            {
                var value = entity.Entity.ToLower();
                if (value == "pool" || value == "gym" || value == "wifi" || value == "towels")
                {
                    await dialogContext.PostAsync("Yes we have that");
                    dialogContext.Wait(MessageReceived);
                    return;
                }
                await dialogContext.PostAsync("I'am sorry we don't have that");
                dialogContext.Wait(MessageReceived);
                return;
            }
            await dialogContext.PostAsync("I'am sorry we don't have that");
            dialogContext.Wait(MessageReceived);
        }
    }
[LuisModel(“8c9285fb-198a-4f49-8fe4-b08ac5541ac2”,“5c47c63887e346c2aee24d1755e07d29”)]
[可序列化]
公共类LUISDialog:LUISDialog
{
私人只读BuildFormDelegate预订;
公共LUISDialog(BuildFormDelegate ReservcRoom)
{
这个.Reservation=reservceRoom;
}
[路易辛顿(“”)
[路易辛顿(“无”)]
公共异步任务无(IDialogContext对话框上下文,LuisResult LuisResult)
{
等待dialogContext.PostAsync(“对不起,我不知道你的意思”);
dialogContext.Wait(MessageReceived);
}
[问候语]
公共异步任务问候语(IDialogContext对话框上下文,LuisResult LuisResult)
{
dialogContext.Call(new GreetingDialog(),CallBack);
}
专用异步任务回调(IDialogContext上下文,IAwaitable结果)
{
Wait(MessageReceived);
}
[路易辛顿(“保留”)]
公共异步任务室预订(IDialogContext对话框上下文,LuisResult LuisResult)
{
FormDialog enrollmentForm=new FormDialog(new RoomReservation(),this.Reservation,FormOptions.PrompInstart);
dialogContext.Call(注册表单,回调);
}
[LuisIntent(“QueryManities”)]
公共异步任务查询功能(IDialogContext对话框上下文,LuisResult LuisResult)
{
foreach(luisResult.Entities.Where(entity=>entity.Type==“便利性”)中的var实体)
{
var值=entity.entity.ToLower();
如果(值==“游泳池”| |值==“健身房”| |值==“wifi”| |值==“毛巾”)
{
等待dialogContext.PostAsync(“是的,我们有这个”);
dialogContext.Wait(MessageReceived);
返回;
}
等待dialogContext.PostAsync(“很抱歉我们没有这个”);
dialogContext.Wait(MessageReceived);
返回;
}
等待dialogContext.PostAsync(“很抱歉我们没有这个”);
dialogContext.Wait(MessageReceived);
}
}
我收到的错误屏幕截图

控制器代码

[BotAuthentication]
    public class MessagesController : ApiController
    {
        /// <summary>
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// </summary>
        public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                //ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                //// calculate something for us to return
                //int length = (activity.Text ?? string.Empty).Length;

                //// return our reply to the user
                //Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters");
                //await connector.Conversations.ReplyToActivityAsync(reply);
                // await Conversation.SendAsync(activity, () =>  HotelBotDialog.dialog);
                await Conversation.SendAsync(activity, MakeLuisDialog);
            }
            else
            {
                 await HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);
            return response;
        }
[BotAuthentication]
公共类消息控制器:ApiController
{
/// 
///帖子:api/Messages
///接收来自用户的消息并回复
/// 
公共异步任务发布([FromBody]活动)
{
if(activity.Type==ActivityTypes.Message)
{
//ConnectorClient连接器=新的ConnectorClient(新Uri(activity.ServiceUrl));
////算点东西让我们回去
//int length=(activity.Text??string.Empty).length;
////将我们的回复返回给用户
//Activity reply=Activity.CreateReply($“您发送的{Activity.Text}为{length}个字符”);
//等待连接器.Conversations.ReplyToActivityAsync(reply);
//wait Conversation.sendaync(活动,()=>HotelBotDialog.dialog);
等待对话。SendAsync(活动,MakeLuisDialog);
}
其他的
{
等待可处理的系统消息(活动);
}
var response=Request.CreateResponse(HttpStatusCode.OK);
返回响应;
}
路易斯意图


请帮助我解决此问题。

我刚刚测试了与您的LUI的连接,它似乎正在工作:

很可能您使用的是端点键,而不是编程键API。请检查此项:

如果直接调用确实有效,那么我建议通过方法调用LUIS,而不是在顶部添加[Luisint(***])。如果您想在将来实现更多认知API,则更容易。此外,我总是这样调用对话框:wait Conversation.sendaync(activity,()=>new MakeSLuisDialog());而不是等待对话。SendAsync(活动,MakeLuisDialog);我不知道在我的情况下机器人应用程序出了什么问题。有没有办法排除LUIS的故障?但LUIS没有失败,请单击链接,这是你自己的LUIS应用程序!如果你喜欢,我可以通过teamviewer帮助你正确了解,请将我添加到skype:fercomreal1上