Use Bot Framework Emulator Correctly to Test Your Bots


You can use the Bot Framework to build and connect bots to interact with your users in apps (or communication channels) such as your website, Skype, Facebook Messenger, and Office 365 mail. Before or after deploying and publishing bots, you can use the Bot Framework Emulator to test them. In the post I will share a few tips on how to use the emulator correctly.

Install and use the latest version of the emulator

You can download the latest version (currently 3.5.23) at github. (At the time of writing the post the other download link didn’t seem to be working.) If you have the older version, 1.0.0.73, on your Windows computer, you should replace it.

image     image

 

Test a Bot Connected to Azure Bot Service in the Emulator

With an Azure subscription, you can create a bot through the Azure portal by following the instructions here. You can test the bot directly through the portal chat channel as shown below.

image

To test the same bot in the emulator, you will need to find the end point, application ID and password for the bot service. The Settings tab only provides the partial message endpoint (ending with three dots). Therefore you will need to go to the developer site, https://dev.botframework.com/. Click on the Edit link. You will find the message endpoint there. Copy the entire URL and enter it in the emulator. Also, copy and paste the application ID and password from the bot developer portal.

imageimage

You will also need to download free utility, ngrok, which creates a tunnel between the bot hosted remotely (in this case on Azure) and your computer behind the firewall. Click App Settings in the emulator. Browse to the location where ngrok.exe is located. Save the setting. The utility will be launched automatically from the emulator. At this point, the emulator is ready. Click “Connect” or the refresh icon. Type something in the input box. You’ll see a response.

 

image

 

Test a Bot Connected to localhost in the Emulator

You can use Visual Studio to create a bot using the Bot Framework Connector SDK .NET template. See detailed instructions here.

image

 

Note that the documentation is a bit outdated. It still shows the old emulator interface. It refers the portal to 3978. Your bot app actually uses port 3979. It says you can leave the application ID and application password blank, but the emulator (version 3.5.23) asks you for application ID and password.

If you just want to test the bot locally with the emulator, without registering the bot and publishing it to Azure, you can disable or enable bot authentication.

To disable bot authentication – Leave application id and password blank in the web.config file. Comment out the attribute BotAuthentication in the MessagesController file.

image

To enable bot authentication – Provide the application ID and password in your Visual Studio project code. Interestingly, you have to provide a valid application ID and password, not something random.

- If you leave the values of MicrosoftAppId and MicrosoftAppPassword blank, you will receive an error: “The bot's MSA appId or passsword is incorrect. Click here to edit your bot's MSA info.”

- If you set the value of MicrosoftAppId to “MyApp” and MicrosoftAppPassword to “12345”, you will received an errror: “Refresh access token failed with status code: 400”

image  image

 

image

I used the same application ID and password from the bot I created from the Azure portal. And it worked. Note that ngrok is not required for local message service.

image

 

To test your bot in Skype, follow the simple step here. The bot basically works like a new contact that will interacts with you.

image

 

 


Comments (0)

Skip to main content