Attribute 'luismodel' is not valid on this declaration type

佐手、 提交于 2020-01-06 02:38:07

问题


I am trying to get a pretty basic bot done using the botbuilder Botframework. the problem is luis.ai integration. I have used the luis.ai with a .js file but when I am trying to reference from my c# project, I am getting the error in the title.

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

That looks like the way that lusimodel is used in the sample code I can find so I am not sure why it doesn't work here. I am just trying to get to grips with c# so I am a bit lost.


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


来源:https://stackoverflow.com/questions/37695677/attribute-luismodel-is-not-valid-on-this-declaration-type

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!