Debug with the emulator
The Bot Framework Emulator is a desktop application that allows bot developers to test and debug their bots, either locally or remotely. Using the emulator, you can chat with your bot and inspect the messages that your bot sends and receives. The emulator displays messages as they would appear in a web chat UI and logs JSON requests and responses as you exchange messages with your bot. Before you deploy your bot to the cloud, run it locally and test it using the emulator. You can test your bot using the emulator even if you have not yet created it with Azure Bot Service or configured it to run on any channels.
- Install Bot Framework Emulator
Run a bot locally
Before connecting your bot to the Bot Framework Emulator, you need to run your bot locally. You can use Visual Studio or Visual Studio Code to run your bot, or use command line. To run a bot using command line, do the following:
Go to the command prompt and change directory to your bot project directory.
Start the bot by running the following command:
Copy the port number in the line before Application started. Press CTRL+C to shut down.
At this point, your bot should be running locally.
Connect to a bot running on localhost
To connect to a bot running locally and click Open bot. Add the port number your copied earlier into the following URL and paste the updated URL in the Bot URL bar:
If your bot is running with Microsoft Account (MSA) credentials, enter these credentials too.
Use bot credentials
When you open the bot, set the Microsoft App ID and Microsoft App password if your bot is running with credentials. If you created your bot with the Azure Bot Service, the credentials are available on the bot's App Service, under the Settings -> Configuration section. If you do not know the values, you can remove those from the locally running bot's configuration file, then run the bot in the Emulator. If the bot isn't running with these settings, you don't need to run the emulator with the settings either.
View detailed Message Activity with the Inspector
Send a message to your bot and the bot should respond back. You can click on the message bubble within the conversation window and inspect the raw JSON activity using the INSPECTOR feature to the right side of the window. When selected, the message bubble will turn yellow and the activity JSON object will be displayed to the left of the chat window. The JSON information includes key metadata, including the channel ID, activity type, conversation ID, the text message, endpoint URL, and so on. You can inspect activities sent from the user, as well as activities the bot responds with.
You can debug state changes in a bot connected to a channel by adding Inspection Middleware to the bot.
With the new v4 emulator you can also inspect the JSON responses from LUIS and QnA. Using a bot with a connected language service, you can select trace in the LOG window to the bottom right. This new tool also provides features to update your language services directly from the emulator.
With a connected LUIS service, you'll notice that the trace link specifies Luis Trace. When selected, you'll see the raw response from your LUIS service, which includes intents, entities along with their specified scores. You also have the option to re-assign intents for your user utterances.
With a connected QnA service, the log will display QnA Trace, and when selected you can preview the question and answer pair associated with that activity, along with a confidence score. From here, you can add alternative question phrasing for an answer.
Login to Azure
You can use Emulator to login in to your Azure account. This is particularly helpful for you to add and manage services your bot depends on. Log into Azure by following these steps:
- Click on File -> Sign in with Azure
- On the welcome screen click on Sign in with your Azure account You can optionally have Emulator keep you signed in across Emulator application restarts.
Disabling data collection
If you decide that you no longer want to allow the Emulator to collect usage data, you can easily disable data collection by following these steps:
Navigate to the Emulator's settings page by clicking on the Settings button (gear icon) in the nav bar on the left side.
Uncheck the checkbox labeled Help improve the Emulator by allowing us to collect usage data under the Data Collection section.
Click the "Save" button.
If you change your mind, you can always enable it by re-checking the checkbox.
For troubleshooting, see troubleshoot general problems and the other troubleshooting articles in that section.
Use inspection middleware to debug a bot connected to a channel.