属性' luismodel'对此声明类型无效

时间:2016-06-08 07:17:09

标签: c# botframework

我正在尝试使用botbuilder Botframework完成一个非常基本的机器人。问题是luis.ai整合。我使用了带有.js文件的luis.ai但是当我尝试从我的c#项目中引用时,我收到了标题中的错误。

using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
// using System.Web.Http;
// using System.Web.Http.Description;
// using System.Collections.Generic;
// using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
// using Newtonsoft.Json;


namespace MyBot
{
    [LuisModel("80ba6a3b-8f62-47e6-81d0-350211b85580", "9b593fab21d54a328c0b9aeb0a64138b")]

    [LuisIntent("")]
    public async Task None(IDialogContext context, LuisResult result)
    {
        string message = "I'm sorry I didn't understand. Try asking about your bill.";
        await context.PostAsync(message);
        context.Wait(MessageReceived);
    }

    [LuisIntent("NextInvoiceDate")]
    public async Task NextInvoiceDate(IDialogContext context, LuisResult result)
    {
        string message = "Your next payment will go out on the 17th of the month.";
        await context.PostAsync(message);
        context.Wait(MessageReceived);
    }
}

这看起来像我可以找到的示例代码中使用lusimodel的方式所以我不确定它为什么在这里工作。我只是试图掌握c#所以我有点迷失。

1 个答案:

答案 0 :(得分:3)

你可能错过了你的班级声明。

尝试

namespace MyBot
{
    [LuisModel("80ba6a3b-8f62-47e6-81d0-350211b85580", "9b593fab21d54a328c0b9aeb0a64138b")]
    public MyBotClass
    {
        [LuisIntent("")]
        public async Task None(IDialogContext context, LuisResult result)
        {
            string message = "I'm sorry I didn't understand. Try asking about your bill.";
            await context.PostAsync(message);
            context.Wait(MessageReceived);
        }

        [LuisIntent("NextInvoiceDate")]
        public async Task NextInvoiceDate(IDialogContext context, LuisResult result)
        {
            string message = "Your next payment will go out on the 17th of the month.";
            await context.PostAsync(message);
            context.Wait(MessageReceived);
        }
    }
}