I want to create the APP, INTENTS, UTTERANCE ..... TRAIN and PUBLISH my app but not going to the www.luis.ai website.... i want to do it grammatically by calling its API and i came across this website https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c2f
In that i am getting confused for what to pass in BODY parameter while making a post request for APP, INTENTS, UTTERANCE ..... TRAIN and PUBLISH.
So can any one please provide me some C# code for making all this post request with parameters .
As i want every thing to do from my own application and not going to the luis.ai website.
Is it possible to have a conversation in particular flow? I want a single luis utterance to have different response in a particular conversation flow, how can i do it? because my utterance hits to a single intent and luis can give a single response everytime. please give solution for C# code.
@sayyednazeer you have to learn how to call REST web services in C#, it is not Luis specific. You can have a look here for example: https://stackoverflow.com/questions/10679214/how-do-you-set-the-content-type-header-for-an-httpclient-request
@NehaShaikh786 there is no link between your comment/question and the initial question. If you have question on how to do specific things, please post your question to StackOverflow (with all the necessary context and the code you tried)
@nrobert
Thanks for the response, i know how to call the REST web services in C# and i am able to call it.
My question was.... what will be the BODY parameter for making a POST request.
The only body parameter of the service i know is of Creating Intent Api and it something looks like
{
"Name": "TEST INTENT"
}
so what are the parameters APP, UTTERANCE ..... TRAIN and PUBLISH
Sorry, I thought you were asking for how to call! You're right, the API reference is unclear as it only says {body} for the value like in TRAIN API call
Did you try with an empty body? I tested TRAIN with the API testing console and it seems to be working.
For App, Intent, Utterances (see Label) => sample values are in the API reference
@sayyednazeer for training your model via the authoring API, I took the below snippet from the batch testing portion at the LUIS portal. Have you tried sending the following as the body in a POST request?
[
{
"text": "hey dad, are you hungry?",
"intent": "None",
"entities":
[
{
"entity": "FamilyMember",
"startPos": 4,
"endPos": 6
}
]
},
{
"text": "hey mom, are you hungry?",
"intent": "None",
"entities":
[
{
"entity": "FamilyMember",
"startPos": 4,
"endPos": 6
}
]
}
]
I am seeing the request body in the linked API docs, for example:

Create LUIS app - request body:
{
"name": "MyFirstDummyApp",
"description": "This is my first dummy application",
"culture": "en-us",
"usageScenario": "IoT",
"domain": "Comics",
"initialVersionId": "1.0"
}
If there's no request body example for the API call you are looking for, it's probably because there are not a lot of parameters required. For example, to train your app, just use the provided code samples at the bottom.

@stevengum97
If i want to train application then i think body parameter should only suppose to contains the application id and looking to the sample you have provided it contains the text and intent..!!
Then which text and intent i have to pass all or the newly added...?
@nwhitmont: the Train sample (your last one) may be the case that is not clear: in the red zone for the cURL sample it says {body} but the request body section above is empty, hence the doubt.
@sayyednazeer: Look at the website, in train section you can train the model (without parameters as you said) but also batch test (as @stevengum97 said). That's 2 different things.
For the basic train part as I said yesterday you just have to pass an empty body (try it, you will see training status change on the website)
@nwhitmont , @stevengum97
I was referring the API version 1.0
Now i have done the same thing with the Version 2.0 and done the testing with the API Console option which they have provided i pass my App id and key and in response it returns 202 accepted but on luis.ai it till shows not trained yet.
Have a look at below snap.



In TRAIN API , if i see the default code, overe there also it show the body parameter

@nrobert
If you see in my above snap, i am testing it with the option "Open Api Testing Console"
Over there you can see in the first snap i am passing the request body as an empty.
I used it yesterday and worked (with an app already trained before), the train date changed after a few seconds. Remember that there is a queue so don't hesitate to wait a bit and force a good refresh of the page
@nrobert
Still not trained.. :(
Can you provide me that javascript sample..
I will try it.
I wasn't using javascript but the API testing console as you did.
I did a POST and checked again, no change in train date. In fact the train date value in luis.ai website changed only after calling the other method in the train section of the API: GET Get application version training status !
That's not the behaviour I thought it would have.
@nrobert
Now mine also start working.
What i have done is.... First i have manually train it buy going on the portal.
After that whenever i make a get request , it gets train and not on post.
Even i have read somewhere on stack overflow about this training luis works with get and not with post.
Thanks for your help. :)
And do you have any idea about the Publish API
In body parameter it was asking accepting the parameter for slack channel also, i have not enable my bot for slack channel so if i remove that parameter it shows error that slack parameter required.
And if add the slack channel and pass any value in slack parameter or blank value it says 404 Bad Request with message Invalid argument. Service response: BadRequest
lol... but the funniest thing is that my application get publish :P
Sorry I lost you for your last question. You are talking about Publish API for LUIS (this one: https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c3b)? I can't see any Slack parameter.
@nrobert
You are referring the API Version 2.0
It is present in Version 1.0
There are many API's present in Version 1.0 which is not there in V 2.0
Let me check with the Version 2.0
Oh, okay! But should we still use this v1.0? It was during the project phase...
Now methods have been improved and as you said, there's no need to talk about Slack in the publish phase of LUIS, so use 2.0 ;-)
I think that most of the API's method in 1.0 are still in 2.0 but rebranded / refactored. But it would be interesting to get the before/after gap
yes its working fine with v 2.0.
@nrobert @nwhitmont
When i create intent with API TESTING CONSOLE (https://dev.projectoxford.ai/docs/services/56d95961e597ed0f04b76e58/operations/56f8a55119845511c81de468/console)
It creates the intent successfully.
But when i do it from my javascript it gives me error of BadArgument
SCRIPT
$('#btnNewIntent').click(function () {
debugger;
var intent = $("#txtNewIntent").val();
var params = {
// Request parameters
};
debugger;
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/luis/v1.0/prog/apps/{f93134bd-e0b6-4dee-a****9}/intents?" + $.param(params),
beforeSend: function (xhrObj) {
// Request headers
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", "045fe2c14f924c59*****e");
},
type: "POST",
// Request body
//data: {"Name": "Test"},
data: {Name: intent},
})
.done(function (data) {
debugger;
alert("success");
})
.fail(function () {
debugger;
alert("error");
});
});
ERROR

Did had time to check, but one thing that seems to be wrongly passed:
url: "https://westus.api.cognitive.microsoft.com/luis/v1.0/prog/apps/{f93134bd-e0b6-4dee-add3-85d3f5744a69}/intents?" should not contain { and }, remove them
I can’t test your scenario at the moment, but try removing the curly braces from the URL and see
Sent from my Windows 10 phone
From: sayyednazeer
Sent: 09 July 2017 17:37
To: Microsoft/BotBuilder
Cc: Subscribed
Subject: Re: [Microsoft/BotBuilder] [LUIS] Programmatic API? (#3083)
@nrobert
When i create intent with API TESTING CONSOLE (https://dev.projectoxford.ai/docs/services/56d95961e597ed0f04b76e58/operations/56f8a55119845511c81de468/console)
It creates the intent successfully.
But when i do it from my javascript it gives me error of BadArgument
SCRIPT
$('#btnNewIntent').click(function () {
debugger;
var intent = $("#txtNewIntent").val();
var params = {
// Request parameters
};
debugger;
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/luis/v1.0/prog/apps/{f93134bd-e0b6-4dee-add3-85d3f5744a69}/intents?" + $.param(params),
beforeSend: function (xhrObj) {
// Request headers
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", "045fe2c14f924c5994e7c1d5f25501ce");
},
type: "POST",
// Request body
//data: {"Name": "Test"},
data: {Name: intent},
})
.done(function (data) {
debugger;
alert("success");
})
.fail(function () {
debugger;
alert("error");
});
});
ERROR
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
let me check
@nrobert @michaelhutchful
Still same error after removing {}
@michaelhutchful Please remove that sub and app id from the post... i have paste by mistake
@nrobert @michaelhutchful
any update ??
Can you add also the HTML, so that we can quickly test?
Firstly, I am not too conversant with JS, but it seems that you are not sending any URL parameters. The documentation specifies an appID so you have to add that to your params
var params = {
// Request parameters
};
Michael
Sent from Mail for Windows 10
From: sayyednazeer
Sent: 10 July 2017 12:46
To: Microsoft/BotBuilder
Cc: michaelhutchful; Mention
Subject: Re: [Microsoft/BotBuilder] [LUIS] Programmatic API? (#3083)
@nrobert @michaelhutchful
any update ??
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
I am specifying my appid in the url
In my html part i only have a button anf on this button click i am calling the JavaScript function...
From what I understand in the documentation, your final url should look something like
this is according to the documentation. I can’t test it out though. Try it and let us know
Sent from Mail for Windows 10
From: sayyednazeer
Sent: 10 July 2017 16:57
To: Microsoft/BotBuilder
Cc: michaelhutchful; Mention
Subject: Re: [Microsoft/BotBuilder] [LUIS] Programmatic API? (#3083)
In my html part i only have a button anf on this button click i am calling the JavaScript function...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
And why are you still using v1.0?
@nrobert
I didn't find creating intent api in v 2.0
@sayyednazeer , this one? https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c0c
I got it working (and I think the problem was the same on your v1 use: missing quotes in data
$('#btnNewIntent').click(function () {
var intent = var intent = $("#txtNewIntent").val();
$.ajax({
url: "https://westus.api.cognitive.microsoft.com/luis/api/v2.0/apps/{yourAppId}/versions/{yourAppVersion}/intents",
beforeSend: function (xhrObj) {
// Request headers
xhrObj.setRequestHeader("Content-Type", "application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", "{yourSubscriptionKey}");
},
type: "POST",
// Request body
data: "{ 'name': '" + intent + "' }",
success: function (response) {
debugger;
alert("success");
},
error: function (xhr, ajaxOptions, thrownError) {
debugger;
alert(xhr.status + ' ' + xhr.statusText + ' ' + xhr.responseText + ' '
+ xhr.responseJSON.error.code + ' ' + xhr.responseJSON.error.message);
}
});
});
Yes this is working fine now...
But i am not clear... is this because of new url or modification in data paramater..!!
From where did you get this URL...
Ok the problem is with only the data parameter which we are passing as a body.
I have try with this url... and its work.
url: "https://westus.api.cognitive.microsoft.com/luis/v1.0/prog/apps/f93134bd-e0b6-4dee-add3-8*a69/intents",
Again many thanks for your valuable time @nrobert and @michaelhutchful :)
@nrobert please share the link for the latest doc, because i didn't find creating intent api in this
I don't have a "latest doc", I just searched in the links I provided from the start what method has 'intent' in its name and found Create intent classifier, whose description is: Adds an intent classifier to the application
So I guessed it was the right one and tested it ;)
It is under models tab
Hi guys! You use LUIS (Microsoft Cognitive Services for NLP) in your bots or applications and have always wanted to create intentions, entities, train your template and publish it programmatically, now you can!
I developed an SDK for .NET that allows you to do this and more!
It is an open-source project and is available on my GitHub with installation and usage details. It even has a roadmap with the features of the next version!
If you liked it, so follow me and give a star there on the project! Thanks!
https://github.com/andreluizsecco/Cognitive-LUIS-Programmatic
@andreluizsecco , that's fine but you should quickly make an update to your project to handle domains... Your package is useless for Europe / Australia at the moment because your base url is hardcoded
Thanks @nrobert! I Fixed it now!
I'm using the LUIS Programmatic APIs v2.0 to deploy from one environment across several others. I can Export, Import, Train and Publish. However, I can't find a way to activate the newly published version. In the interface, you would select the version and select 'Activate' from the menu. How do I do this programmatically?
What do you mean by "activate the version"? This activation is only useful for the portal, because when you use the API you always specify the version id in the calls.
If you look at your "network console" while doing this activation, you will see that a specific PUT is made on an endpoint like the following: https://REGION.api.cognitive.microsoft.com/luis/webapi/v2.0/apps/YOUR_APP_ID/activeversion, with a payload corresponding to the required version

Perfect! That works. Really should be part of the API documentation.
Really should be part of the API documentation.
I'm not sure, as you may not be supposed to use this endpoint.
For my curiosity, why are you trying to do this activation?
We currently have a bot deployed across 8 environments and growing.
Currently, each time we update the model / train it on new things in Dev, I have to manually go through the process of Cloning and Exporting out of Dev and Importing, Training, Publishing in each of the environments. This is tedious and potentially error-prone. I am in the process of automating this.
Thanks, I fully understand the needs of automating things here.
But why do you need this step of activating? Everything can be done through the "official" API (without using "web" api endpoints): export, import, train, publish. No need of activating a version (except maybe if you need your end-users to be on the right version when they connect to luis.ai, that the only case where I see why you would need it)
You are correct, the last step is not required.
Originally I thought it might affect the call to the API, but I can see that the only factor is if you ask for the 'Production' or 'Staging' endpoint.
Most helpful comment
yes its working fine with v 2.0.