Introduction to the Dispatch CLI - Bot Builder Tool

In the previous article, we introduced Ludown, LUIS, QnA Maker, and MSBot CLI tools. With these, we created two cognitive services (LUIS application, QnA Maker Knowledgebase) and we configured the .bot file to make use of those.

But what if we have more than just two Cognitive Services, this is solved with the Dispatch LUIS Application. The Dispatch app is another LUIS instance that decides which Cognitive Service is the correct one for the request.

Dispatch determining the correct Cognitive Service for the request

Fig. 1. Dispatch determining the correct Cognitive Service for the request

As seen on the image the request is initially forwarded to the Dispatch Luis application, it returns the intent which defines which is the appropriate Cognitive Service, which in the end gets the request.

Benefits: Reduced cost.

Training the bot would be a burden but that is solved with the Dispatch CLI.

This article builds upon the previous article "Learn the Bot Builder Tools", to follow along with this article completing the first one is a prerequisite.

The Dispatch CLI

The Dispatch CLI reads the Services of the .bot file of your Bot Application and according to the services it creates the LUIS Dispatch Application. This is done by executing the command below:

dispatch create -b \ 
  | msbot connect dispatch --stdin

The Dispatch tool will query the services from the .bot file and will create the Dispatch Service in and then with the MSBot CLI we add the dispatch application to the services in the .bot file.

Creating the Dispatch Service with the Dispatch CLI

Fig. 2. Creating the Dispatch Service with the Dispatch CLI

Now our application is ready to be started. The main pieces of code that are important are in the following classes.


This class is provided by Microsoft in their bot samples, it basically sends the Request to the Dispatch Service and then according to the returned intent forwards it to the appropriate cognitive service.

If during the previous steps, you changed the name of any of the bots then you need to update the following properties in this class:

    private const string CarRentalLuisKey = "CarRental";
  private const string QnAMakerKey = "CarQnA";
  private const string DispatchKey = "CarRentalDispatch";

And as well update the intends accordingly:

     const string carRentalLuisKey = "l_CarRental";
    const string noneDispatchKey = "None";
    const string qnaDispatchKey = "q_CarQnA";


A service that stores all the Cognitive Services and provides those to classes that require them, e.g. the NlpDispatchBot uses them.

The BotService is set up in the Startup class in the method InitBotServices where the contents of the .bot configuration file are read and the Services initialized.


Because the .bot file has sensitive data you can encrypt those by executing:

$ msbot secret -n
Your bot is encrypted with secret:

Copy the generated secret and add it in the application.json file (but understandably don’t commit the secret)


Your dispatch bot is ready for action. In this two-part series, you learned the Bot Builder Tools and how those can be used to streamline the process of Bot Development. Additionally, it was not mentioned explicitly but these tools are very important when building CI/CD pipelines.

  • Erstellt am .
Copyright by Orange Networks GmbH