By default this is how can we send text to LUIS for processing and returns intents.
[Serializable]
public class LuisDialogController : LuisDialog<FAQConversation>
{
private readonly BuildFormDelegate<FAQConversation> _newConversation;
public LuisDialogController(BuildFormDelegate<FAQConversation> newConversation) : base(new LuisService(new LuisModelAttribute(
ConfigurationManager.AppSettings["LuisAppId"],
ConfigurationManager.AppSettings["LuisAPIKey"],
domain: ConfigurationManager.AppSettings["LuisAPIHostName"])))
{
this._newConversation = newConversation;
}
[LuisIntent("None")]
public async Task NoneIntent(IDialogContext context, LuisResult result)
{
await this.ShowLuisResult(context, result);
}
}
I am wondering how can I send text to LUIS programmatically.
//pseudocode
var foo = new Luis();
var luisIntent = foo.processLanguage("How are you?");
switch(luisIntent)
{
case LuisIntent.Inquiry:
{
//do something; break;
}
default:
{
//do something else; break;
}
}
I've been looking in this solution, however he did not answer by giving a regex.
Would the idea be possible?
In publish section of your LUIS model you have "Resources and Keys" subsection
Below "Endpoint" column you have url(s) that may be used to retrieve data from LUIS by http GET:
https://*.api.cognitive.microsoft.com/luis/v2.0/apps/
*?subscription-key=*&verbose=true&timezoneOffset=0&q=this%20is%20test%20sentence
It will provide you JSON result with structure similar to this:
{
"query": "this is test sentence",
"topScoringIntent": {
"intent": "None",
"score": 0.522913933
},
"intents": [
...
],
"entities": []
}
See more detail and sample C# code here.
Alternatively you may use:
using Microsoft.Bot.Builder.Luis;
...
var model = new LuisModel() {};
var luisService = new LuisService(model);
var result = await luisService.QueryAsync(textToAnalyze, CancellationToken.None);