You’ve heard a lot of buzz about bots, artificial intelligence, and machine learning. Maybe, you’ve wondered how practical a . NET bot is and should you adopt the new, trendy tech. All in all, one thing you should know about bots and all the tech that empowers them. Bot technologies are here to stay! The main reason: they are cheaper than your local working guy. If you need the proof, check out our wonderful blog post — AI Bots are Coming for Your Testing Jobs or just browse the web.
Bots will save you money. And despite all the hi-tech chatter in the media, they’re not that complicated to make. We will tell you how to create your own .NET bot in 6 easy steps and 2 short blog posts:
DIY (Part 1)
- Introduction to the Bot Framework for .NET
- Create Your First .NET Bot
- Make the Bot Smarter
DIY (Part 2)
- Bring Your Bot to Life
- Connect the Bot to Channels
- Give Your Bot a Voice
Introduction to the Bot Framework for .NET
Let’s make everything clear from the start. When we use the word ‘bot’, we mean an app that users interact with in a conversational way. You can always create a proper bot from scratch but let’s leave it to digital cavemen. There’s a framework for everything software nowadays, especially bots. Moreover, the .NET bot framework will solve some of your basic issues by providing:
- Basic I/O (input-output processing)
- Language and dialogue skills
- Connection to users
- Language support
The .NET bot framework itself consists of the following tools and features:
- Bot Builder (with SDKs for .NET)
- Bot Framework Emulator
- Developer Portal
- Bot Connector Service
- Channel APIs
How it all works? So simple you won’t believe it. First, you’ve got your Bot Builder SDK for actual coding together with the Developer Portal for additional services like APIs, databases, Azure, machine learning etc. Additionally, there’s a Bot Framework Emulator for testing your code.
Second, you have a Bot Connector Service for managing the input-output messaging
Third, there’s a whole collection of Channel APIs, including social media. If you want to add the bot to the channel that’s not provided (image below), remember there’s a custom API builder. In other words, you’ve got everything you need for your first .NET bot.
Create Your First .NET Bot
Okay, enough with the theory! Let’s get to the business. Follow the steps:
Step 1. Install Bot Builder SDK via Nuget Package Manager
Step 2. Install the Bot Application template to your Visual Studio
Step 3. Use the source code from GitHub to get a ready-made bot
Step 4. Use the Bot Framework Emulator, in order to test out your bot
The final step will be securing your newly built bot. This will require a few additional measures. However, securing a good piece of software always pays back.
There are several rules how to secure your bot properly:
- use only an HTTPS endpoint
- Enable a Bot Framework authentication by registering your bot to acquire a Microsoft App ID and a password
- specify its app ID and password in your bot’s web.config file (look for the tip)
- use the [BotAuthentication] attribute to specify authentication credentials when using Bot Builder SDK for .NET
Tip: The ID authentication goes like this. You add the Microsoft App ID in a proper field. Wait for the initial authentication. Add the newly generated BotID to a proper field and to the config(Bot handle). That’s it!
Still puzzled? Click here for a Microsoft tutorial on how to build your bot.
Moreover, in its Bot Framework, Microsoft offers a wonderful glossary of all the concepts that can be unfamiliar: https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-concepts.
Hopefully, at the end of the chapter, you’re all set and done with creating your first bot. In case it’s not the case, please address me — the author of the article — Oleh Romanyuk @ Linkedin here. I will make sure you have a proper .NET bot created!
Make Your Bot Smarter
Congratulations — you’ve made it this far. Your bot is alive and you are a proud botfather. However, the bot is still primitive and pretty much useless. At this point, Microsoft provides a whole bunch of solution for boosting the brains of your bot, specifically 5 different APIs for language understanding.
Don’t know which to choose? Don’t panic. The first one is the most useful one. The name is LUIS. LUIS (Language Understanding Intelligent Service) is able to process natural language using pre-built or custom-trained language models. It has a bunch of advantages that will suit you just fine (image below).
Without any further introduction, let’s get to the drawing board and plan your LUIS app. What is the purpose of your bot and your business? How do you see your bot helping your clients?
For a smart plan for teaching the bot, let’s go through the following steps:
Step 1. Identify your domain — The way how LUIS functions is usually built around a domain-specific topic. For example, you have an app for selling tickets or an app for tracking your fitness. Both of them will be apps in different domains, and they will require different LUIS settings. In addition, there are 20 pre-built domains for your convenience that can be found here.
Step 2. Identify your intents — Intents are keywords that explain what your customer wants. If your customer writes ‘buy tickets’ obviously that’s what (s)he wants. If a fitness bot sees the word ‘pulse’ anywhere in the conversation, most probably the client needs to know something about his or her pulse. Plain and simple, make a list of all the keywords your customers can use in a conversation with your bot and connect them with an appropriate action from the side of the bot.
Step 3. Identify your entities — In order to book your flight, you need some information like the destination, date, airline, ticket category and travel class — that’s entities. You must add them in order to truly accomplish an intent.
So, here’s where all the fun starts. There are many types of entities you can create:
- Simple entities — A simple entity describes a single concept.
- Hierarchical entities — A hierarchical entity represents a category and its members.
- Composite entities — A composite entity is made up of other entities that form parts of a whole.
- Prebuilt entities — LUIS provides pre-built entities for common types like Number, which you can use for the number of tickets in a ticket order.
- List entities — A list entity is an explicitly specified list of values. Each value consists of one or more synonyms. In a travel app, you might choose to create a list entity to represent airport names.
lanned your LUIS App? Sure what intents and entities you’ll use? Perfect! And no worries, if you’re not sure about everything, you’ll be able to change the settings afterward. Now’s the time to create an actual LUIS app and make your bot smarter!