属性“luismodel”不在此声明类型有效(Attribute 'luismodel

2019-09-27 19:41发布

我试图让使用botbuilder Botframework做一个非常基本的机器人。 问题是luis.ai整合。 我已经使用了luis.ai名为.js的文件,但是当我试图从我的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#,所以我有点失落。

Answer 1:

You missing your class declaration probably.

Try

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);
        }
    }
}


文章来源: Attribute 'luismodel' is not valid on this declaration type