Create you own bot with Microsoft Bot Composer

Chatbots have been a major hype in the IT industry for some time now. One of the major players in the enterprise spectrum is Microsoft with the Microsoft Bot Framework suite. In the last year the MBF low-code, open-source, platform has grow quite impressively. Microsoft Bot Framework Composer, or just Composer for character saving (Amazonia ain't gonna save itself) is a very robust platform for chatbot development.

This article is part of a Microsoft Bot Framework dedicated series, where we will look at the advantages of using Microsoft Chatbot solution, and how can we overcome the current pitfalls in the tool. The main goal is to reach a broader audience, but we will cover some deep topics that may require some IT/development knowledge, but don't stop now, we will tackle it together. 

Although easy to use, the platform set up isn't that straight forward. For that reason this article will cover the how to install and get it started running up on the local emulator, and to your Azure subscription as well.

So summing up, we will install and run Microsoft Bot Framework Composer, build a sample chatbot, configure the Azure necessary resources, and deploy it to Azure! Excited? Let's go.

You can access the example code at my github page.

When it comes to chatbots, 60% of millennials have used them, 70% of those report positive experiences, and of the millennials who have not used them, more than half say they are interested in using them.

Forbes

Step 1: Set Up Composer

First things first, we need to install the necessary software in our machine, to do that go to botframework.com and download the Microsoft Bot Framework Composer installer. It's right there in the second section of the page with the button "Download Composer", impossible to miss. You can also get it from Microsoft's github page.

Afterwards you will also need the Microsoft Bot Framework Emulator, we need to test our bot locally somewhere right? Just go the Microsoft github page and get the correct version for your environment.

Installing it is pretty straight forward, unless you want any specific option, should be next, next, next.

Bot Framework Composer Setup

After installing, try running Bot Composer to see if everything is ok. You should be presented with something like this:

Congratulations, you've finished the first step! Yeah it's that easy, let's proceed?

Step 2: Creating a bot

We have the tool, we have the emulator, what now? Now let's create a chatbot and test it locally!

How we do that? Glad you ask:

  1. Rule of thumb, create a folder in you environment to hold your Bots, it seems pretty simple, but having bots lost in your file system never made any good, you think Michelangelo left his brushes uncounted for? I've created mine at C:\BotComposer\ but feel free to select one for you.
  2. After that, let's start by creating a simple Empty Bot, we will cover the templates later on so don't worry to much. For that just go to Bot Composer and select New in the Home Page.


    At the pop window select the Create from template option, and then select Empty Bot.


    In the third step just select a cool name for the chatbot project and a small description, don't forget to use the folder you created at Step 1!
    With this you created an Empty Bot project!

  3. So, now that we have our clean canvas, let's start by changing the greeting command of your chatbot, go over to Bot Responses in the left vertical menu, and take your time analysing the page.


    Can you notice that you already have 2 bot responses trees? One for "common" and the other with your bot name (yes mine is EmptyBot-0, original!). You can also see that the reply configured for the initial greeting flow is not a direct answer, but the calling of a function.
    Bot Composer uses a syntax called Language Generation that allows the developer to enrich the regular text answer with logic. There is a lot of potiential in Language Generation and that could be an article on its own, so for now you can learn more about it at Microsoft docs.
    In this case it is used to provide a better organization to your answers, it is okay in the first 2 or 3 flows, but when you have 100 answers to manage, it can get tricky (brushes analogy all over again).
  4. With the last step in context, we will now open the Common bot responses section and change the Welcome User message.


    Here we can edit the welcome message sent on the first user interaction, so let's change it to something more personal like: "Hi! Welcome to my creator first Microsoft Bot Composer chatbot, how can I help you?".

  5. Now we have a chatbot we a custom greeting, let's add now the default intent unrecognized message. This message is pretty important since it will be the default bot reaction when he doesn't understand the user intention.
    Open the Design option in the left vertical menu, and select the ... option near your chatbot name:


    Afterwards, in the pop up form, select the option Unknown Intent for the "What is the type of this trigger?" question.
    Next, click on the add button (+) in the flow designer to add a new step to the diagram. There select Send a response as stated in the next image:


    When you add a response step, the right window will let you edit the responses, even more, with Language Generation you can set a number of different replies, which will be randomly picked by the chatbot to reply to the user. I've added the following ones:
    - Sorry but i didn't understand the request, can you rephrase it?
    - I didn't quite catch that, can you repeat?
    - Couldn't understand the request, if you are having difficulties, contact us at info@filipelteixeira.com


    Only thing missing now is testing our bot locally. A quick reminder that you need to have Microsoft Bot Emulator installed in your machine.

  6. To test the bot, just click on the Start bot button on the top right corner of the application. After the bot service is running press the option Test in Emulator as shown in the next image.


    After the Emulator application starts and connects to your bot you can now test your example, here is a screenshot of my test:

Now that we have a running chatbot, we need to extend it with more intelligent features, to do that we will look into Microsoft Natural Language Processing service. 

Step 3: Add LUIS to the Chatbot

To be able to provide the natural user experience of talking to a human, the chatbot needs to have the intelligence to understand what the user is trying to say. To do that we rely on Natural Language Processors that aid the application understanding the intent of the user in a specific phrase.

Don't go overboard, NLP's services are far beyond what we would wish them to be, they have to be trained and reiterated within the application lifecycle to provide accurate results and to increase the understandability of your own users.

LUIS is Microsoft Language Understanding services, and we will take advantage of the out-of-the-box integration that is provided by Microsoft Bot Composer to create realistic use cases.

With this in mind there are 2 main tasks in this step, create the new flow inside Microsoft Bot Composer, and create and configure LUIS service. Following that order, let's start:

  1. First step is to create a new intent recognition, this can be made by going to the bot designer page, clickying the ... option in the dialog window and selecting Create a trigger. Afterwards specify the name of the trigger and add some simple ways to ask it. In the example the bot will reply what should be considered the best Pokémon.


    After that we add a cool message to the bot reply and we finish our new simple flow.


    You notice the red error we are getting in the application? It says that we are missing LUIS key, it's fine since we didn't create a LUIS service and configured it in the Bot Composer.

  2. Let's head over to LUIS portal to create the resource to be assigned in Bot Composer. You should be presented with the following page:


    This means that you don't have yet an authoring resource to manage LUIS applications, so let's create one. Ensure that the subscription is the correct one and continue. Aftewards you will be presented with a form like this:


    Just make sure the values are ok, if necessary create a specific Resource Group to host your environment authoring resource (recommended).
    After the resource is created, go to the settings option (top right cogwheel) and select your subscription and resource. Then you will be presented with the keys to access LUIS, copy the primary key, we will need it later on.

  3. We successfully created the LUIS resource, now we just need to configure it in Bot Composer's settings. Head to the application and select Project Settings in the left vertical menu.
    Now copy your LUIS primary key and paste it in the LUIS authoring key field, then select the region you created your resource in. The final result should be something like this:

  4. After the configuration is completed we can test our bot to ensure that the connection to LUIS is successful. Go ahead and launch your bot, when you press Start bot your training model will be sent to your LUIS account, the first time will take a little more time than usual (mine took about 40 seconds).
    And here is the final test:


    We now have a chatbot running locally, connecting remotely to the LUIS service for natural language understading, amazing right?

Conclusion

So we created and tested a local bot based entirely on Microsoft ecosystem, we took advantage of Bot Composer and Bot Emulator to build and test the chatbot, and we also used the LUIS cloud service to support our chatbot functionalities. You can also access the developed chatbot project here.

This was the first step, in the following article we will look at how can we deploy this chatbot in Azure, and use it remotely, so stay tunned for more Azure stuff!

Thank you for reading, and if you want to support the page or just give feedback in the comments below or share it on your social media by tagging me @filipelteixeira.

Bye!

Filipe Teixeira

Filipe Teixeira

Hello, I'm a CS Engineer with 5 years of experience and a passion for technology. Currently I work for Microsoft as an Azure Cloud Engineer.
Any opinions expressed are solely my own and do not express the views or opinions of Microsoft.

Comments (0)

wave

Leave Comment

wave

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.

Press ESC to close