问题
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