Quickstart: Get intent with REST APIs

In this quickstart, add example utterances to a Travel Agent app and train the app. Example utterances are conversational user text mapped to an intent. By providing example utterances for intents, you teach LUIS what kinds of user-supplied text belongs to which intent.

Prerequisites

  • Starter key.
  • Import the TravelAgent app from the cognitive-services-language-understanding GitHub repository.
  • The LUIS application ID for the imported TravelAgent app. The application ID is shown in the application dashboard.
  • The version ID within the application that receives the utterances. The default ID is "0.1".
  • .NET Core V2.2+
  • Visual Studio Code

Example utterances JSON file

The example utterances follow a specific format.

The text field contains the text of the example utterance. The intentName field must correspond to the name of an existing intent in the LUIS app. The entityLabels field is required. If you don't want to label any entities, provide an empty array.

If the entityLabels array is not empty, the startCharIndex and endCharIndex need to mark the entity referred to in the entityName field. The index is zero-based, meaning 6 in the top example refers to the "S" of Seattle and not the space before the capital S. If you begin or end the label at a space in the text, the API call to add the utterances fails.

[
  {
    "text": "go to Seattle today",
    "intentName": "BookFlight",
    "entityLabels": [
      {
        "entityName": "Location::LocationTo",
        "startCharIndex": 6,
        "endCharIndex": 12
      }
    ]
  },
  {
    "text": "purple dogs are difficult to work with",
    "intentName": "BookFlight",
    "entityLabels": []
  }
]

Get LUIS key

Keys and endpoints are provided in the LUIS portal in the Manage Section on the Azure Resources page.

  1. Sign in to the LUIS portal.
  2. Create a new app, or select an existing app from the apps list.
  3. Select Manage then select Azure Resources.
  4. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.

    Note

    The Starter key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

Change model programmatically

Use C# to add a machine-learned entity API to the application.

  1. Create a new console application targeting the C# language, with a project and folder name of model-with-rest.

    dotnet new console -lang C# -n model-with-rest
    
  2. Install required dependencies with the following dotnet CLI commands.

    dotnet add package System.Net.Http
    dotnet add package JsonFormatterPlus
    
  3. Overwrite Program.cs with the following code:

    using System;
    using System.IO;
    using System.Net.Http;
    using System.Text;
    using System.Threading.Tasks;
    using System.Collections.Generic;
    using System.Linq;
    
    // 3rd party NuGet packages
    using JsonFormatterPlus;
    
    namespace AddUtterances
    {
        class Program
        {
            // NOTE: use your starter key value
            static string authoringKey = "YOUR-KEY";
    
            // NOTE: Replace this endpoint with your starter key endpoint
            // for example, westus.api.cognitive.microsoft.com
            static string endpoint = "YOUR-ENDPOINT";
    
            // NOTE: Replace this with the ID of your LUIS application
            static string appID = "YOUR-APP-ID";
    
            // NOTE: Replace this your version number
            static string appVersion = "0.1";
    
            static string host = String.Format("https://{0}/luis/authoring/v3.0-preview/apps/{1}/versions/{2}/", endpoint, appID, appVersion);
    
            // GET request with authentication
            async static Task<HttpResponseMessage> SendGet(string uri)
            {
                using (var client = new HttpClient())
                using (var request = new HttpRequestMessage())
                {
                    request.Method = HttpMethod.Get;
                    request.RequestUri = new Uri(uri);
                    request.Headers.Add("Ocp-Apim-Subscription-Key", authoringKey);
                    return await client.SendAsync(request);
                }
            }
            // POST request with authentication
            async static Task<HttpResponseMessage> SendPost(string uri, string requestBody)
            {
                using (var client = new HttpClient())
                using (var request = new HttpRequestMessage())
                {
                    request.Method = HttpMethod.Post;
                    request.RequestUri = new Uri(uri);
    
                    if (!String.IsNullOrEmpty(requestBody))
                    {
                        request.Content = new StringContent(requestBody, Encoding.UTF8, "text/json");
                    }
    
                    request.Headers.Add("Ocp-Apim-Subscription-Key", authoringKey);
                    return await client.SendAsync(request);
                }
            }        
            // Add utterances as string with POST request
            async static Task AddUtterances(string utterances)
            {
                string uri = host + "examples";
    
                var response = await SendPost(uri, utterances);
                var result = await response.Content.ReadAsStringAsync();
                Console.WriteLine("Added utterances.");
                Console.WriteLine(JsonFormatter.Format(result));
            }
            // Train app after adding utterances
            async static Task Train()
            {
                string uri = host  + "train";
    
                var response = await SendPost(uri, null);
                var result = await response.Content.ReadAsStringAsync();
                Console.WriteLine("Sent training request.");
                Console.WriteLine(JsonFormatter.Format(result));
            }    
            // Check status of training
            async static Task Status()
            {
                var response = await SendGet(host  + "train");
                var result = await response.Content.ReadAsStringAsync();
                Console.WriteLine("Requested training status.");
                Console.WriteLine(JsonFormatter.Format(result));
            }    
            // Add utterances, train, check status
            static void Main(string[] args)
            {
                string utterances = @"
                [
                    {
                    'text': 'go to Seattle today',
                    'intentName': 'BookFlight',
                    'entityLabels': [
                        {
                        'entityName': 'Location::LocationTo',
                        'startCharIndex': 6,
                        'endCharIndex': 12
                        }
                    ]
                    },
                    {
                        'text': 'a barking dog is annoying',
                        'intentName': 'None',
                        'entityLabels': []
                    }
                ]
                ";            
                AddUtterances(utterances).Wait();
                Train().Wait();
                Status().Wait();
            }
        }
    }
    
  4. Replace the following values:

    • YOUR-KEY with your starter key
    • YOUR-ENDPOINT with your endpoint, for example, westus2.api.cognitive.microsoft.com
    • YOUR-APP-ID with your app's ID
  5. Build the console application.

    dotnet build
    
  6. Run the console application. The console output displays the same JSON that you saw earlier in the browser window.

    dotnet run
    

LUIS keys

This quickstart uses the starter key for convenience. The key is primarily for authoring the model but does allow a small number (1000) of endpoint requests. When you are ready for more endpoint requests in a test, stage or production environment, create a Language Understanding resource in the Azure portal and assign it to the LUIS app in the LUIS portal.

Clean up resources

When you are finished with this quickstart, delete the file from the file system.

Next steps

Prerequisites

  • Starter key.
  • Import the TravelAgent app from the cognitive-services-language-understanding GitHub repository.
  • The LUIS application ID for the imported TravelAgent app. The application ID is shown in the application dashboard.
  • The version ID within the application that receives the utterances. The default ID is "0.1".
  • JDK SE (Java Development Kit, Standard Edition)
  • Visual Studio Code or your favorite IDE

Example utterances JSON file

The example utterances follow a specific format.

The text field contains the text of the example utterance. The intentName field must correspond to the name of an existing intent in the LUIS app. The entityLabels field is required. If you don't want to label any entities, provide an empty array.

If the entityLabels array is not empty, the startCharIndex and endCharIndex need to mark the entity referred to in the entityName field. The index is zero-based, meaning 6 in the top example refers to the "S" of Seattle and not the space before the capital S. If you begin or end the label at a space in the text, the API call to add the utterances fails.

[
  {
    "text": "go to Seattle today",
    "intentName": "BookFlight",
    "entityLabels": [
      {
        "entityName": "Location::LocationTo",
        "startCharIndex": 6,
        "endCharIndex": 12
      }
    ]
  },
  {
    "text": "purple dogs are difficult to work with",
    "intentName": "BookFlight",
    "entityLabels": []
  }
]

Get LUIS key

Keys and endpoints are provided in the LUIS portal in the Manage Section on the Azure Resources page.

  1. Sign in to the LUIS portal.
  2. Create a new app, or select an existing app from the apps list.
  3. Select Manage then select Azure Resources.
  4. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.

    Note

    The Starter key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

Change model programmatically

Use Go to add a machine-learned entity API to the application.

  1. Make a subdirectory named lib and copy in the following java libs:

  2. Create a new file named Model.java. Add the following code:

    import java.io.*;
    import java.net.URI;
    import org.apache.http.HttpEntity;
    import org.apache.http.HttpResponse;
    import org.apache.http.client.HttpClient;
    import org.apache.http.client.methods.HttpGet;
    import org.apache.http.client.methods.HttpPost;
    import org.apache.http.client.utils.URIBuilder;
    import org.apache.http.impl.client.HttpClients;
    import org.apache.http.util.EntityUtils;
    
    //javac -cp ":lib/*" Model.java
    //java -cp ":lib/*" Model
    
    public class Model {
    
        public static void main(String[] args) 
        {
            try
            {
    
                // The ID of a public sample LUIS app that recognizes intents for turning on and off lights
                String AppId = "YOUR-APP-ID";
    
                // Add your endpoint key 
                String Key = "YOUR-KEY";
    
                // Add your endpoint, example is westus.api.cognitive.microsoft.com
                String Endpoint = "YOUR-ENDPOINT";
    
                String Utterance = "[{'text': 'go to Seattle today','intentName': 'BookFlight','entityLabels': [{'entityName': 'Location::LocationTo',"
                    + "'startCharIndex': 6,'endCharIndex': 12}]},{'text': 'a barking dog is annoying','intentName': 'None','entityLabels': []}]";
    
                String Version = "1.0";
    
                // Begin endpoint URL string building
                URIBuilder addUtteranceURL = new URIBuilder("https://" + Endpoint + "/luis/authoring/v3.0-preview/apps/" + AppId + "/versions/" + Version + "/examples");
                URIBuilder trainURL = new URIBuilder("https://" + Endpoint + "/luis/authoring/v3.0-preview/apps/" + AppId + "/versions/" + Version + "/train");
    
                // create URL from string
                URI addUtterancesURI = addUtteranceURL.build();
                URI trainURI = trainURL.build();
    
                // add utterances POST
                HttpClient addUtterancesClient = HttpClients.createDefault();
                HttpPost addutterancesRequest = new HttpPost(addUtterancesURI);
                addutterancesRequest.setHeader("Ocp-Apim-Subscription-Key",Key);
                addutterancesRequest.setHeader("Content-type","application/json");
                HttpResponse addutterancesResponse = addUtterancesClient.execute(addutterancesRequest);
                HttpEntity addutterancesEntity = addutterancesResponse.getEntity();
                if (addutterancesEntity != null) 
                {
                    System.out.println(EntityUtils.toString(addutterancesEntity));
                }
    
                // train POST
                HttpClient trainClient = HttpClients.createDefault();
                HttpPost trainRequest = new HttpPost(trainURI);
                trainRequest.setHeader("Ocp-Apim-Subscription-Key",Key);
                trainRequest.setHeader("Content-type","application/json");
                HttpResponse trainResponse = trainClient.execute(trainRequest);
                HttpEntity trainEntity = trainResponse.getEntity();
                if (trainEntity != null) 
                {
                    System.out.println(EntityUtils.toString(trainEntity));
                }
    
                // training status GET
                HttpClient trainStatusClient = HttpClients.createDefault();
                HttpGet trainStatusRequest = new HttpGet(trainURI);
                trainStatusRequest.setHeader("Ocp-Apim-Subscription-Key",Key);
                trainStatusRequest.setHeader("Content-type","application/json");
                HttpResponse trainStatusResponse = trainStatusClient.execute(trainStatusRequest);
                HttpEntity trainStatusEntity = trainStatusResponse.getEntity();
                if (trainStatusEntity != null) 
                {
                    System.out.println(EntityUtils.toString(trainStatusEntity));
                }            
            }
    
            catch (Exception e)
            {
                System.out.println(e.getMessage());
            }
        }   
    }
    
  3. Replace the following values:

    • YOUR-KEY with your starter key
    • YOUR-ENDPOINT with your endpoint, for example, westus2.api.cognitive.microsoft.com
    • YOUR-APP-ID with your app's ID
  4. With a command prompt in the same directory as where you created the file, enter the following command to compile the Java file:

    javac -cp ":lib/*" Model.java
    
  5. Run the Java application from the command line by entering the following text in the command prompt:

    java -cp ":lib/*" Model
    

LUIS keys

This quickstart uses the starter key for convenience. The key is primarily for authoring the model but does allow a small number (1000) of endpoint requests. When you are ready for more endpoint requests in a test, stage or production environment, create a Language Understanding resource in the Azure portal and assign it to the LUIS app in the LUIS portal.

Clean up resources

When you are finished with this quickstart, delete the file from the file system.

Next steps

Prerequisites

  • Starter key.
  • Import the TravelAgent app from the cognitive-services-language-understanding GitHub repository.
  • The LUIS application ID for the imported TravelAgent app. The application ID is shown in the application dashboard.
  • The version ID within the application that receives the utterances. The default ID is "0.1".
  • Python 3.6 or later.
  • Visual Studio Code

Example utterances JSON file

The example utterances follow a specific format.

The text field contains the text of the example utterance. The intentName field must correspond to the name of an existing intent in the LUIS app. The entityLabels field is required. If you don't want to label any entities, provide an empty array.

If the entityLabels array is not empty, the startCharIndex and endCharIndex need to mark the entity referred to in the entityName field. The index is zero-based, meaning 6 in the top example refers to the "S" of Seattle and not the space before the capital S. If you begin or end the label at a space in the text, the API call to add the utterances fails.

[
  {
    "text": "go to Seattle today",
    "intentName": "BookFlight",
    "entityLabels": [
      {
        "entityName": "Location::LocationTo",
        "startCharIndex": 6,
        "endCharIndex": 12
      }
    ]
  },
  {
    "text": "purple dogs are difficult to work with",
    "intentName": "BookFlight",
    "entityLabels": []
  }
]

Get LUIS key

Keys and endpoints are provided in the LUIS portal in the Manage Section on the Azure Resources page.

  1. Sign in to the LUIS portal.
  2. Create a new app, or select an existing app from the apps list.
  3. Select Manage then select Azure Resources.
  4. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.

    Note

    The Starter key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

Change model programmatically

Use Go to add a machine-learned entity API to the application.

  1. Create a new file named model.py. Add the following code:

    ########### Python 3.6 #############
    import requests
    
    # Starter key
    LUIS_authoringKey  = "YOUR-KEY"
    
    LUIS_APP_ID = "YOUR-APP-ID"
    
    # Authoring endpoint, example: westus.api.cognitive.microsoft.com
    LUIS_ENDPOINT = "YOUR-ENDPOINT"
    
    # The version number of your LUIS app
    LUIS_APP_VERSION = "0.1"
    
    URI_AddUtterances = f'https://{LUIS_ENDPOINT}/luis/authoring/v3.0-preview/apps/{LUIS_APP_ID}/versions/{LUIS_APP_VERSION}/examples'
    URI_Train = f'https://{LUIS_ENDPOINT}/luis/authoring/v3.0-preview/apps/{LUIS_APP_ID}/versions/{LUIS_APP_VERSION}/train'
    
    HEADERS = {'Ocp-Apim-Subscription-Key': LUIS_authoringKey}
    
    def addUtterances():
        r = requests.post(URI_AddUtterances,headers=HEADERS)
        print(r.json())
    
    def train():
        r = requests.post(URI_Train,headers=HEADERS)
        print(r.json())
    
    def trainStatus():
        r = requests.get(URI_Train,headers=HEADERS)
        print(r.json())
    
    addUtterances()
    train()
    trainStatus()
    
  2. Replace the following values:

    • YOUR-KEY with your starter key
    • YOUR-ENDPOINT with your endpoint, for example, westus2.api.cognitive.microsoft.com
    • YOUR-APP-ID with your app's ID
  3. With a command prompt in the same directory as where you created the file, enter the following command to run the file:

    python model.py
    

LUIS keys

This quickstart uses the starter key for convenience. The key is primarily for authoring the model but does allow a small number (1000) of endpoint requests. When you are ready for more endpoint requests in a test, stage or production environment, create a Language Understanding resource in the Azure portal and assign it to the LUIS app in the LUIS portal.

Clean up resources

When you are finished with this quickstart, delete the file from the file system.

Next steps

Prerequisites

  • Starter key.
  • Import the TravelAgent app from the cognitive-services-language-understanding GitHub repository.
  • The LUIS application ID for the imported TravelAgent app. The application ID is shown in the application dashboard.
  • The version ID within the application that receives the utterances. The default ID is "0.1".
  • Node.js programming language
  • Visual Studio Code

Example utterances JSON file

The example utterances follow a specific format.

The text field contains the text of the example utterance. The intentName field must correspond to the name of an existing intent in the LUIS app. The entityLabels field is required. If you don't want to label any entities, provide an empty array.

If the entityLabels array is not empty, the startCharIndex and endCharIndex need to mark the entity referred to in the entityName field. The index is zero-based, meaning 6 in the top example refers to the "S" of Seattle and not the space before the capital S. If you begin or end the label at a space in the text, the API call to add the utterances fails.

[
  {
    "text": "go to Seattle today",
    "intentName": "BookFlight",
    "entityLabels": [
      {
        "entityName": "Location::LocationTo",
        "startCharIndex": 6,
        "endCharIndex": 12
      }
    ]
  },
  {
    "text": "purple dogs are difficult to work with",
    "intentName": "BookFlight",
    "entityLabels": []
  }
]

Get LUIS key

Keys and endpoints are provided in the LUIS portal in the Manage Section on the Azure Resources page.

  1. Sign in to the LUIS portal.
  2. Create a new app, or select an existing app from the apps list.
  3. Select Manage then select Azure Resources.
  4. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.

    Note

    The Starter key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

Change model programmatically

Use Go to add a machine-learned entity API to the application.

  1. Create a new file named model.js. Add the following code:

    var request = require('request');
    var requestpromise = require('request-promise');
    
    const LUIS_authoringKey = "YOUR-KEY";
    const LUIS_endpoint = "YOUR-ENDPOINT";
    const LUIS_appId = "YOUR-APP-ID";
    const LUIS_versionId = "0.1";
    const addUtterancesURI = `https://${LUIS_endpoint}/luis/authoring/v3.0-preview/apps/${LUIS_appId}/versions/${LUIS_versionId}/examples`;
    const addTrainURI = `https://${LUIS_endpoint}/luis/authoring/v3.0-preview/apps/${LUIS_appId}/versions/${LUIS_versionId}/train`;
    
    const utterances = [
    		{
    		  'text': 'go to Seattle today',
    		  'intentName': 'BookFlight',
    		  'entityLabels': [
    			{
    			  'entityName': 'Location::LocationTo',
    			  'startCharIndex': 6,
    			  'endCharIndex': 12
    			}
    		  ]
    		},
    		{
    			'text': 'a barking dog is annoying',
    			'intentName': 'None',
    			'entityLabels': []
    		}
    	  ];
    
    const main = async() =>{
    
    
        await addUtterance();
        await train("POST");
        await trainStatus("GET");
    
    }
    const addUtterance = async () => {
    
        const options = {
            uri: addUtterancesURI,
            method: 'POST',
            headers: {
                'Ocp-Apim-Subscription-Key': LUIS_authoringKey
            },
            json: true,
            body: utterances
        };
    
        const response = await requestpromise(options)
        console.log(response.body);
    }
    const train = async (verb) => {
    
        const options = {
            uri: addTrainURI,
            method: verb, 
            headers: {
                'Ocp-Apim-Subscription-Key': LUIS_authoringKey
            },
            json: true,
            body: null // The body can be empty for a training request
        };
    
        const response = await requestpromise(options)
        console.log(response.body);
    }
    
    // MAIN
    main().then(() => console.log("done")).catch((err)=> console.log(err returned));
    
  2. Replace the following values:

    • YOUR-KEY with your starter key
    • YOUR-ENDPOINT with your endpoint, for example, westus2.api.cognitive.microsoft.com
    • YOUR-APP-ID with your app's ID
  3. With a command prompt in the same directory as where you created the file, enter the following command to run the file:

    node model.js
    

LUIS keys

This quickstart uses the starter key for convenience. The key is primarily for authoring the model but does allow a small number (1000) of endpoint requests. When you are ready for more endpoint requests in a test, stage or production environment, create a Language Understanding resource in the Azure portal and assign it to the LUIS app in the LUIS portal.

Clean up resources

When you are finished with this quickstart, delete the file from the file system.

Next steps

Prerequisites

  • Starter key.
  • Import the TravelAgent app from the cognitive-services-language-understanding GitHub repository.
  • The LUIS application ID for the imported TravelAgent app. The application ID is shown in the application dashboard.
  • The version ID within the application that receives the utterances. The default ID is "0.1".
  • Go programming language
  • Visual Studio Code

Example utterances JSON file

The example utterances follow a specific format.

The text field contains the text of the example utterance. The intentName field must correspond to the name of an existing intent in the LUIS app. The entityLabels field is required. If you don't want to label any entities, provide an empty array.

If the entityLabels array is not empty, the startCharIndex and endCharIndex need to mark the entity referred to in the entityName field. The index is zero-based, meaning 6 in the top example refers to the "S" of Seattle and not the space before the capital S. If you begin or end the label at a space in the text, the API call to add the utterances fails.

[
  {
    "text": "go to Seattle today",
    "intentName": "BookFlight",
    "entityLabels": [
      {
        "entityName": "Location::LocationTo",
        "startCharIndex": 6,
        "endCharIndex": 12
      }
    ]
  },
  {
    "text": "purple dogs are difficult to work with",
    "intentName": "BookFlight",
    "entityLabels": []
  }
]

Get LUIS key

Keys and endpoints are provided in the LUIS portal in the Manage Section on the Azure Resources page.

  1. Sign in to the LUIS portal.
  2. Create a new app, or select an existing app from the apps list.
  3. Select Manage then select Azure Resources.
  4. Copy the values for the key and endpoint for the Starter resource. You'll need these to run the sample below.

    Note

    The Starter key allows free requests to the authoring API and up to 1000 queries to the prediction endpoint API per month for all your LUIS apps.

Change model programmatically

Use Go to add a machine-learned entity API to the application.

  1. Create a new file named predict.go. Add the following code:

    // dependencies
    package main
    import (
    	"fmt"
    	"net/http"
    	"io/ioutil"
    	"log"
    	"strings"
    )
    
    // main function
    func main() {
    
    	// NOTE: change to your app ID
    	var appID = "YOUR-APP-ID"
    
    	// NOTE: change to your starter key
    	var authoringKey = "YOUR-KEY"
    
    	// NOTE: change to your starter key's endpoint, for example, westus.api.cognitive.microsoft.com
    	var endpoint = "YOUR-ENDPOINT"	
    
    	var version = "0.1"
    
    	var exampleUtterances = `
    	[
    		{
    		  'text': 'go to Seattle today',
    		  'intentName': 'BookFlight',
    		  'entityLabels': [
    			{
    			  'entityName': 'Location::LocationTo',
    			  'startCharIndex': 6,
    			  'endCharIndex': 12
    			}
    		  ]
    		},
    		{
    			'text': 'a barking dog is annoying',
    			'intentName': 'None',
    			'entityLabels': []
    		}
    	  ]
    	`
    
    	fmt.Println("add example utterances requested")
    	addUtterance(authoringKey, appID, version, exampleUtterances, endpoint)
    
    	fmt.Println("training selected")
    	requestTraining(authoringKey, appID, version, endpoint)
    
    	fmt.Println("training status selected")
    	getTrainingStatus(authoringKey, appID, version, endpoint)
    }
    
    // get utterances from file and add to model
    func addUtterance(authoringKey string, appID string,  version string, labeledExampleUtterances string, endpoint string){
    
    	var authoringUrl = fmt.Sprintf("https://%s/luis/authoring/v3.0-preview/apps/%s/versions/%s/examples", endpoint, appID, version)
    
    	httpRequest("POST", authoringUrl, authoringKey, labeledExampleUtterances)
    }
    func requestTraining(authoringKey string, appID string,  version string, endpoint string){
    
    	trainApp("POST", authoringKey, appID, version, endpoint)
    }
    func trainApp(httpVerb string, authoringKey string, appID string,  version string, endpoint string){
    
    	var authoringUrl = fmt.Sprintf("https://%s/luis/authoring/v3.0-preview/apps/%s/versions/%s/train", endpoint, appID, version)
    
    	httpRequest(httpVerb,authoringUrl, authoringKey, "")
    }
    func getTrainingStatus(authoringKey string, appID string, version string, endpoint string){
    
    	trainApp("GET", authoringKey, appID, version, endpoint)
    }
    // generic HTTP request
    // includes setting header with authoring key
    func httpRequest(httpVerb string, url string, authoringKey string, body string){
    
    	client := &http.Client{}
    
    	request, err := http.NewRequest(httpVerb, url, strings.NewReader(body))
    	request.Header.Add("Ocp-Apim-Subscription-Key", authoringKey)
    
    	fmt.Println("body")
    	fmt.Println(body)
    
    	response, err := client.Do(request)
    	if err != nil {
    		log.Fatal(err)
    	} else {
    		defer response.Body.Close()
    		contents, err := ioutil.ReadAll(response.Body)
    		if err != nil {
    			log.Fatal(err)
    		}
    		fmt.Println("   ", response.StatusCode)
    		fmt.Println(string(contents))
    	}
    }    
    
  2. Replace the following values:

    • YOUR-KEY with your starter key
    • YOUR-ENDPOINT with your endpoint, for example, westus2.api.cognitive.microsoft.com
    • YOUR-APP-ID with your app's ID
  3. With a command prompt in the same directory as where you created the file, enter the following command to compile the Go file:

    go build model.go
    
  4. Run the Go application from the command line by entering the following text in the command prompt:

    go run model.go
    

LUIS keys

This quickstart uses the starter key for convenience. The key is primarily for authoring the model but does allow a small number (1000) of endpoint requests. When you are ready for more endpoint requests in a test, stage or production environment, create a Language Understanding resource in the Azure portal and assign it to the LUIS app in the LUIS portal.

Clean up resources

When you are finished with this quickstart, delete the file from the file system.

Next steps