This post is a write up about my experiences of building a bot using the Microsoft Bot Framework. This isn't a best practice, it's just practical advice about what I learned on the way and hope it might help others who are looking to learn how to build bots. 

The output of this work was presented at Episerver Ascend Europe and was ultimately connected to a running instance of Episerver. At a simple level the architecture looked like this:

Steps to building a bot

Getting started

It's possible to build bots using Node.js or .net. Being a .net developer I decided to do down the .net route. After reading the getting started guide for Bot Builder for .NET I was ready to start building.

Building my bot

My bot was a simple POC that was designed to query an Episerver site to look for outstanding content approvals and allow content to be rejected or approved in Skype.

The code is simple and not ready for production use - however if you are really curious to see what I built then head over to Gist to see the Episerver extensions and the Bot code itself.

There are plenty of examples on how to build your first bot here so I will not show my code and refer readers to the links below:

Testing my bot

In order to test bots locally Microsoft provide a bot emulator that you can run on your own machine. The emulator is available for download here: https://docs.botframework.com/en-us/tools/bot-framework-emulator/. Once installed you point it to the URL of your bot runnning locally and interact with it as shown below:

Deploying my bot

When working with the Microsoft Bot Framework all communication quite rightly needs to be over SSL. My bot was built using ASP.net so I could have deployed it to an Azure App Service and use the wildcard SSL cert you get there meaning my bot URL would be something like https://<bot name>.azurewebsites.net.

However I had a VM running IIS so decided to deploy my bot there. I didn't want to pay for a cert or even generate one so I used the free SSL on Cloudflare. Troy Hunt has written a great article about using Cloudflare for free SSL. I used the same approach to get free SSL on my bot ASP.net site hosted in IIS.

Registering my bot with the Microsoft Bot Framework

Once I was happy with my bot I needed to register it with the Microsoft Bot Framework to connect it to real clients (such as Skype in my case). The Microsoft Bot Framework provides the "glue" between your bot and any channels you want people to be able to interact with it on.

Head here: https://dev.botframework.com/bots/new and sign in with a Microsoft account and fill in the details. The most important part here is the URL of the bot API that can be accessed over SSL.

The bot I wanted was for Skype but you can pick from any of the available channels in the portal. Once your bot is registered you can simply hit the "Add to Skype" button:

This sends you to a URL where you need to sign in with your Skype account which adds the bot to Skype. Once there head back to your Skype client and you'll see the bot registered:

This now meant I could interact with my bot in Skype chat:

Conclusion

My bot never got pushed to production and was used purely for demonstration purposes. However as .net developer I found working with the Microsoft Bot Framework a familar experience which meant the barrier to entry felt low. If a customer asked me to build a bot in the future I would not be concerned!

Finally by adding some Microsoft Cognitive Services to the mix I can see that building an incredibly powerful bot can be achieved with little skill. 


Comments

Recommendations for you