1. Home
  2. Training Library
  3. Microsoft Azure
  4. Courses
  5. Creating a Bot Using Microsoft Bot Framework Composer

Debugging Chatbots in Bot Framework Composer

Start course

This course shows you the fundamentals of how to create, test, troubleshoot, and publish chatbots using the Microsoft Bot Framework Composer. You’ll learn about dialogs, triggers, and prompts and how these can be used to model conversational logic in your chatbots. We'll cover how to work with state and variables before moving on to how to control chatbot output by using language generation and how to implement adaptive cards to create rich user experiences.

Then we'll explore how the Bot Framework Emulator, Webchat Window, Watch Window, and Application Insights can be used to debug your chatbot. Finally, we'll show you how to get your chatbot published on Azure and how to test your chatbot using the Azure Portal.

Learning Objectives

  • Use Bot Framework Composer to create chatbots
  • Implement dialogs and maintain state
  • Implement logging for a bot conversation
  • Implement prompts for user input
  • Troubleshoot a conversational bot
  • Add language generation for a response
  • Design and implement adaptive cards
  • Test and publish a chatbot 

Intended Audience

This course is intended for developers or software architects who want to learn more about Bot Framework Composer and how it can be used to create conversational AI solutions in Microsoft Azure. 


To get the most out of this course, you should have:

  • Intermediate knowledge of coding techniques
  • Familiarity with Azure concepts such as App Service and resources
  • An understanding of JSON

Let's look at some ways you can debug chatbots in Bot Framework Composer. In this lecture, we're going to look at the Bot Framework Emulator. We'll look at the web chat window. We'll see how you can use the watch window to debug your chatbot in real time. You'll learn about application insights. And finally, we'll see a demo of debugging a chatbot using the watch window. The three main ways you can normally debug your chatbot include using the Bot Framework Emulator via the inbuilt web chat window or using the watch window to inspect variables. We'll take a closer look at each of these now.

So what is the Bot Framework Emulator? The Bot Framework Emulator is an application that lets you test and debug your chatbot. You can use the Bot Framework Emulator to test chatbots on your local machine or chatbots that have been published in Microsoft Azure. The emulator can be launched directly from Bot Framework Composer and it lets you interact with your chatbot. You can use the emulate to inspect messages that are sent back and forth between your chatbot. Your chatbot will probably implement the NLP service, LUIS, or surface data from QnA Maker service in Azure.

You can inspect data from each of these services too. For example, identifying the user intent. The Bot Framework Emulator is open source and free and is available from the following URL. You can access the Bot Framework Emulator directly in Composer from the menu at the top right. That's what we can see here. You can also run it from the Windows desktop. We can see the Bot Framework Emulator in action here. On the left we can see the emulator displaying the web chat experience.

Here we can see the messages that are sent back and forth between the chatbot. Each message is date time stamped. Selecting a message refreshes the JSON Inspector. This is the JSON Inspector. This displays detailed inform for a selected message. I cover more about the Bot Framework Emulator in my other course, Creating chatbots Using the Bot Framework SDK. So be sure to check that out for more information on the Bot Framework Emulator.

Let's learn more about the web chat window in Bot Framework Composer. So what is the Web Chat Window? The web chat is another tool that lets you quickly test your chatbot. A good thing about the Web Chat Window is that it's accessed directly within Bot Framework Composer. I personally like this. It gives you instant feedback and you can see the immediate effect of your changes in just a few clicks. One thing to remember is that the Web Chat Window in Composer only lets you see how your chatbot will behave in the web chat channel.

You access the Web Chat Window in Composer from the top right. You can see this here. Clicking on the open web chat will run your chatbot. After your chatbot launches, you can interact with it as if it were installed on the website. That's what we can see here. One of the good things about using the Web Chat Window is that you can still browse around the designer canvas of Composer. This lets you verify the conversation is flowing as expected. If you need to restart a conversation from the beginning you can do this by clicking here.

When debugging chatbots using the Bot Framework Emulator in web chat you also have the option of saving what is known as the bot transcript file. The transcript is a specialized JSON file. It contains the interactions between the user and the chatbot. The data recorded in the transcript contains valuable debugging information such as the user ID, communicating with the bot, the date time of an interaction, and much more. Use the transcript feature in the Bot Framework Emulator or web chat to help you understand the logic being involved in your chatbot and to help accelerate the debugging process.

We've introduced the Bot Framework Emulator and Web Chat Window and some of the features on how you can use them to debug chatbots. Let's look at another feature that lets you inspect variables being used by your chatbot in real time. The watch one window, like other features we have seen, the watch window is accessed directly within Composer. It's accessed by selecting the watch tab that you can see here. Some of the key features of the watch window include providing you with a familiarity bugging experience that's similar to the likes of Microsoft Visual Studio.

Use the watch window to track multiple properties and variables being used by your chatbot. When using the watch window, you also have access to all memory scopes, such as dialogue, turn, this, and user. As your chatbot grows in complexity, the watch window will be crucial to your debugging process and helping you identify and create values and data. Some of the benefits of the watch window include being able to inspect variables and debug in real time.

Older versions of Composer didn't include the watch window. This meant you had to create manual bot responses to omit the contents of a variable. The watch window removes the need for additional logging like this. All of this means that you can accelerate the chatbot development process and identify potential issues within your chatbot. Using the watch window is straightforward. You select your variable, run your chatbot, and evaluate the contents of your variables. You can see the watch window in action here in this screenshot.

A property is set, dialogue time of day, a watch is being placed on a dialogue scope variable. That's what we can see here. And here we can see the value has been identified by the debugger. So we've just seen here to inspect variables in real time using the watch window and Bot Framework Composer, but what about capturing insights and errors when your chatbot is deployed to Microsoft Azure? This is where application insights can be useful. We'll learn about this now.

So what are application insights? Application insights are a telemetry service in Microsoft Azure. You can use application insights to identify commonly used code, to detect errors, and monitor performance metrics. When creating chatbots using Bot Framework Composer, some of the key features that can help you analyze your chatbot behavior include tracking channel level events set by the bot framework run time. For example, the volume of activity your chatbot receives in a particular channel, tracking data center received by your chatbot, tracking specific events such as the dialogue start or the number of adaptive dialogues that have been run to completion.

Some of the benefits of using application insights include being able to create a chatbot telemetry data in Azure using the data to generate rich reports and dashboards. For example, telemetry data can tell you the most or least popular dialogues on your chatbot. Present these insights in a product such as Power BI to help you see, at a glance, which areas of your chatbot need work are possibly need removed. To enable application insights in Bot Framework Composer, the logActivities setting must be set to true. You can find this in the app settings file for your chatbot. Don't worry about having to set this as it's defaulted to true when you initially create your chatbot.

There's another setting logPersonalInformation. This defaults to false and controls if your chatbot should log information that could be used to identify a person. For example, this can include, but is not limited to, a person's name, address, or phone number. Setting this to true will let your chatbot log personally identifiable information and application insights for reporting. After the settings have been configured, you use the telemetry track event activity in the designer canvas in Composer and set the relevant values.

You can see an example of emitting an event at app insights here. Here we can see a name being captured and here we can see the events being tracked. And over here we can see the custom event, user supplied name event. We can also see some custom data being sent to app insights. The property key for the data being captured has been defined as user data. The value being sent to app insights is the user name. It's now time for a demo.

In this demo will see how to debug a chatbot using the watch window in Bot Framework Composer. So here we can see we have a chatbot in Bot Framework Composer. The chatbot we're looking at is a simple calculator and lets this perform simple calculations. We can see two numbers are captured here. First number and second number. We can see the operation the user wants to perform is asked for here. Here we can see how the input operation is used in the switch statement.

We can run this chatbot and try the addition operation. Select web chat and restart the conversation. We can supply the first number followed by the second number. We can try the addition operation. After running the operation, we can see the chatbot isn't calculating the value that we'd expect. We can see what's going on here by adding a watch to the user input variable. To do this, first expand the watch window.

Next, supply the variable that we're interested in. User input. By examining the watch window, we can see the value and the variable user input is set to addition, but the switch statement doesn't have any logic to handle this. We need to update the switch statement from add to addition. We'll do that just now. We can rerun the chatbot and try the addition operation. Open in web chat. Restart the conversation. Supply the first number, followed by the second number again. Select addition. And now the chatbot calculator is behaving as expected for the addition operation.

In this lecture, we've introduced features that help you test and debug chatbots in Bot Framework Composer. We've seen a demo of how you can use the watch window to debug a chatbot in real time. Next, we'll look at the available options for deploying a chatbot to Microsoft Azure.

About the Author
Jamie Maguire
Software Architect, Developer, and Microsoft MVP (AI)

Jamie Maguire is a Software Architect, Developer, Microsoft MVP (AI), and lifelong tech enthusiast with over 20 years of professional experience.

Jamie is passionate about using AI technologies to help advance systems in a wide range of organizations. 

He has collaborated on many projects including working with Twitter, National Geographic, and the University of Michigan. Jamie is a keen contributor to the technology community and has gained global recognition for articles he has written and software he has built. 

He is a STEM Ambassador and Code Club volunteer, inspiring interest at grassroots level. Jamie shares his story and expertise at speaking events, on social media, and through podcast interviews. 

He has co-authored a book with 16 fellow MVPs demonstrating how Microsoft AI can be used in the real world and regularly publishes material to encourage and promote the use of AI and .NET technologies.