How To Use Microsoft LUIS With Bot Framework Composer

Here Is A Simple Tutorial To Get You Started With NLU

Cobus Greyling
8 min readJul 24, 2020



How can we integrate Composer with LUIS…

Firstly, we are going to run Composer locally on my machine and connect to LUIS in the cloud. The NLU configurations we create on Composer will be deployed to a LUIS account. What is LUIS?

Language Understanding (LUIS) is a cloud-based API service that applies custom machine-learning intelligence to a user’s conversational, natural language text to predict overall meaning, and pull out relevant, detailed information.

A client application for LUIS is any conversational application that communicates with a user in natural language to complete a task. Examples of client applications include social media apps, chat bots, and speech-enabled desktop applications.

And, Composer is a tool from Microsoft which allows for graphic development of a conversational application; with language generations, state management and integration points.

Setup Composer Recognizer

Within Composer you can setup three recognizer types:

  • None (Of course)
  • Regular Expressions
  • LUIS
Composer Has Three Recognizer Types

It has to be stated that the regular expressions are very powerful and handy.

Without using any NLU, you can build a decent conversational interface merely based on regular expressions.

You will see the moment we select LUIS a text editor appears.

This text editor is where the intents and entities are defined which will be uploaded to LUIS in the cloud.

The file format is very simplistic and the editor alerts you to syntax errors.

Whenever a change is required, you can update the LUIS configuration file and the changes will be deployed to LUIS. Successful deployment can be verified by logging into LUIS.

LUIS File Format

This simple demo cover all the aspects you will require. This demo can easily be built out into a larger application.

The language understanding file we will use:

# BookFlight
- I want to book a flight
- I need to book a flight
- book a flight for me please
- My family and I want to go on holiday to {toCity=Seattle}
- We are thinking of traveling to {toCity=Denver}
- Our destination will be {toCity=Milan} for our holiday
- We want to visit {toCity=Lisbon}
- On our trip our first stop will be at {toCity=Lisbon}
- We want to travel to {toCity=Lisbon}

There are two intents in the file, BookFlight and FlightDetail.

Bookflight does not have any entities, and we merely want to capture the intent for directing the dialog. This intent can be used to determine which dialog to invoke.

The FlightDetail intent has entities defined. There is only one entity of toCity type. The aim is to capture the city name which will be the travel destination.

Three things need to be noted on these entities:

  • There is no lookup list or reference table, these are truly contextual entities.
  • The value and position of the entity is detected by the context in which the entity appears, within the sentence.
  • Machine Learning is employed by LUIS to define the entities and the process of determining them.
Microsoft Bot Framework Composer LUIS File

Greeting Dialog

When you create a bot, you can choose an existing template, or creating from scratch. For this project I chose Create from scratch.

Creating a Bot from Scratch

In doing this, a Greeting dialog is always created automatically. All we have to do, is add a Send a response conversational node. This node will present the user with a message saying: Welcome to the travel bot!

Adding a “Send a response” Conversational Node

This is the Greeting conversational flow after we have added the greeting. The text is entered in the properties tab on the right.

Two Dialogs Are Visible: Greeting & BookFlight

Travel Dialog With NLU Integration

The principle if Composer is to have different dialogs for different sections of your application. We will only have one dialog called book flight. This dialog will be invoked when the #BookFlight intent is satisfied.

Create a new Dialog on the left and Define the Intent Criteria on the Right

The intents which are defined in the text editor shows up on the top-right; which is a convenient automatic propagation of the defined NLU elements. The moment our user enters the following text, or a variation of it…

I want to book a flight
- I need to book a flight
- book a flight for me please

…this dialog will be invoked.

Dialog Flow for Booking a Flight

The dialog asks the user to state their destination city. The city name is captured in the variable and we are extracting the entity toCity.

Application Deployment

On deployment of your Composer application, you will be prompted for your LUIS credentials. The deployment process is seamless and relatively fast. When in, click on your email address at the very top right-hand corner, and the User Settings page will be visible, containing your LUIS primary key.

LUIS Credential Window

To deploy the application from Composer, click on Start Bot, allow the process to run from Publishing to Reload to the Test In Emulator state.

Deploy the Composer Application

After deployment in composer, check back in if the new conversational app is visible. You can click on the App name to view the intents and entities transposed into the LUIS environment. view with the app loaded

Bot Framework Emulator

To test your bot, you will need to have the Bot Framework Emulator installed. It is a lightweight test interface or chat client, if you like.

In composer, click on Test in Emulator and from here click yes to launch the emulator.

And here is our conversation, with the toCity entity extracted and presented in isolation as we planned.

Emulator View of Our Conversation

Within the emulator, full conversation traces are available. The LUIS return values are also visible in the Emulator.

LUIS return JSON

This helps when Composer is not perhaps presenting the correct information, and you want to determine if the problem sits with LUIS or Composer.

Reservations & Observations

Intents Only

For a larger conversational agent, you will always have multiple dialogs. Defining intents for each of the dialogs is a good way of sending your user on a specific journey within the chatbot.

Especially if the chatbot is task orientated and the user needs to move from state to state.

Using intents per dialog makes for a more conversational and unstructured experience.

Compound Entities

It is highly likely to have two or more entities per intent. LUIS has the capability to detect and identify these compound or multiple entities per user utterance fully contextual.

I would like to take a bus from

I found this hard to do in Composer, and all things considered, I feel tempted to access LUIS from Composer with an API call just for more flexibility and control.

Nested Entities

Taking the idea of compound entities even further, in LUIS you can define nested entities within a single sentence.

I would like to take a 
{Travel Detail={Mode=bus}}
{Travel Detail={City={From City=Madrid}}}
{Travel Detail={City={To City=Lisbon}}}
{Travel Detail={Time Frame=tomorrow}}

By using machine learned methods, LUIS can extract the contextual entities and decompose them. So you have this idea of complex entities with sub-entities, and sub-sub-entities etc.

I have yet to see how Composer will accommodate these.

Fragmented NLU Model

Having the Composer client push NLU configurations to can lead to a fragmented structure on LUIS. You will have multiple smaller applications which will be continually updated as Composer applications are deployed. Changes in LUIS will not be propagated.

Training the NLU Model

Managing and training a single NLU model within LUIS has advantages and propagating the NLU functionally from LUIS down to the applications and clients and not visa versa makes more sense.

LUIS Tools

LUIS has an array of remarkable training and bench marking tools which really comes to the fore with a single NLU model.

Complexities can easily be catered for and presented via an API in a simple way.

Composer might detract from this as the LUIS visibility and functionality in Composer seems rudimentary compared to what is available.


One thing is for sure, Microsoft is following a multi-pronged approach to solving for Conversational AI. With LUIS, Bot Framework, Power Virtual Agents and Composer, it is evident that their arsenal is growing.

Microsoft allows for high level configuration, GUI’s and also native code when it comes to developing a chatbot.



Cobus Greyling

I explore and write about all things at the intersection of AI & language; LLMs/NLP/NLU, Chat/Voicebots, CCAI.