Setting up Azure Bot Service locally

Michael Gillett
3 min readFeb 14, 2017

--

For my and Aimee’s wedding I have decided to build a bot to help keep our guests informed about the special day and I’m using Microsoft’s Bot Framework to do this.

I’ve played around with the Bot Framework before but this time I thought I would try out the new Bot Service which makes use of Azure Functions. Everything went very well in terms of setting it up in Azure but things became a bit more tricky when trying to get this working on my local machine to debug it.

I dabbled about with the bot for a bit, making changes, committing them and then seeing the updates happen almost instantly on live thanks to Continuous Integration. But really I wanted to be able to see my changes locally before committing anything. I used this information on the Bot Framework site to get started on debugging the bot locally.

I tried to run the debughost.cmd command that comes within the source code of the Azure bot and boom, my console was full of warning and errors.

dotnet restore

First off I hadn’t realised I need to run dotnet restore, let’s put that down to not having used the .Net CLI or Azure Functions before. That builds a cache of the required dependencies to get a .Net Core/Azure Functions application running.

After running this .Net command the errors went away and my bot was started up fine. I opened the Bot Frameowkr Emulator, set it up to look at the URL provided by the bot in the console and boom, again I had warnings and errors in the console.

Missing reference and wrong culture

There was only 1 now warning that was being thrown and it was occruing before any errors so I thought it worth investigating, I could see that the Microsoft.Bot.Builder.resources couldn’t be found.

It had a culture of “en-US” but I wasn’t sure where that was coming from, my PC is set to the UK. I killed the bot in the console and started it in the console again. Upon setting it up in the Emulator I noticed that there was a culture reference of “en-US”, I changed it to “en-GB” and tried again.

No luck. Same error but the dependency now listed “en-GB” as its culture. At least I was on to something. After some searching I found a list of the different .DLLs that Microsoft.Bot.Builder.resources has available and there was only 1 English culture for it, “en”.

I killed the bot, set it up in the Emulator again but this time with a culture of “en” and boom, the warning message was gone. After sending a message to the bot I was just left with an error about a missing modelID.

LUIS App Setting required

I couldn’t find any references to modelID in the local code so assumed it was needed by one of the injected packages. Off I went to GitHub to search the source code. There I found a reference to modelID that related to the LUIS AppId and it made me wonder.

I know that when setting up my bot in Azure I could see App Setting values for LUIS but realised there was nothing like this on my local. Maybe I needed some App Settings for my bot to connect to LUIS.

But, there’s no web.config. This threw me for a bit, but I soon found that I can add an appsettings.json file to achieve the same thing. I added the LuisAppId and LuisAPIKey values, restarted the bot, set it up in the Emulator and boom, it worked.

No more warning or errors.

I am now able to work on my bot locally and test it out before pushing it live.

I’ll be sharing more information about this bot as I build it as I have a few interesting ideas for it. Let me know of any tips or examples for working with the Azure Bot Service, I’m keen to learn more about this technology.

--

--

Michael Gillett

Windows Insider MVP (MVP since 2012) | Lead Web Dev based in Camden, London