Contents
You’ve definitely heard a lot about bots, bot messages, artificial intelligence, and the cutting-edge machine learning capabilities. You’ve also probably wondered to what extent practical .NET bot is and whether it’s worth adopting this trendy tech.
The major thing you need to know about bots and the technology that stands behind them is that bots are here to stay. The primary reason for this is that they’re way cheaper than your local working guy. If you feel like getting some proof, check out our post – AI Bots are Coming for Your Testing Jobs or just browse the web.
A bot with machine learning capabilities is sure to save you money. And regardless of what people might be saying, they’re not difficult to make. In this guide, we’ll teach you how to create your own bot in 6 easy steps. Let’s jump right in!
1. THE BOT FRAMEWORK FOR .NET EXPLAINED
So what is a bot .NET? By using the word ‘bot’, we refer to an application that interacts with users in a conversational way. In fact, you can create your own bot from scratch but still, let’s leave it to digital gurus. There exists a framework for virtually anything software today, and bots are no exception. In addition, the .NET bot framework can solve some of your fundamental problems with the help of:
- Basic input-output processing
- Language skills
- Connection with users
- Robust language support
The framework consists of the following tools and features:
- Bot Builder (with SDKs for .NET)
- Bot Framework Emulator
- Developer Portal
- Bot Connector Service
- Channel APIs
How does it work? First, you get your Bot Builder SDK for coding along with the Developer Portal for additional services such as APIs, databases, Azure, machine learning, etc. Plus, you can use a Bot Framework Emulator to test your code.
Next, you have a Bot Connector Service for dealing with the input-output messaging.
Finally, there’s a huge collection of Channel APIs with social media included. If you need to add a bot to a channel that’s not provided, you can always use a custom API builder. As you see, you have all you need for your first .NET bot.
2. BUILD YOUR FIRST .NET BOT
We guess it’s high time to move from theory to practice. To create your own chat bot, follow these steps:
Step 1. Install Bot Builder SDK using Nuget Package Manager.
Step 2. Add the Bot Application template to your Visual Studio.
Step 3. Use the GitHub source code to get a bot.
Step 4. Utilize the Bot Framework Emulator to test out your creation.
The final step will secure your freshly-built bot. Although it will call for some extra effort, securing a good piece of software is known to always pay back.
Here are a couple of rules for properly securing your bot:
– use exclusively an HTTPS endpoint
– enable a Bot .NET Framework authentication method by registering your bot to obtain a Microsoft App ID with a password
– specify the app ID and password in the bot’s web.config file
– utilize the [BotAuthentication] attribute to specify authentication credentials when utilizing Bot Builder SDK for .NET.
Tip: For ID authentication, add the Microsoft App ID in the appropriate field and wait for the initial authentication. Then, add the freshly generated BotID to the appropriate field and to the config (Bot handle). Done!
Still have questions? Go to Microsoft tutorial on how to build your bot.
What is more, in its Bot Framework, Microsoft provides an awesome glossary with all the concepts that you could be struggling to understand: https://docs.microsoft.com/en-us/bot-framework/dotnet/bot-builder-dotnet-concepts.
Hopefully, now you know how to make a bot .NET. Now, let’s learn how to make your bot-net smarter.
3. MAKE YOUR BOT SMARTER
Your bot is alive but still primitive and, to be honest, useless. Good news is that Microsoft provides some solid solutions to boost your bot’s brains — 5 different APIs for language understanding.
If you’re hesitating about which one to choose, I’m here to give you a good tip. Consider the first one — LUIS — since it’s the most helpful. LUIS (Language Understanding Intelligent Service) can process natural language with the help of pre-built or custom-trained language models and is loved for the indisputable advantages it offers.
Now, let’s plan your LUIS app. For starters, answer these questions:
- What is the goal of your bot?
- How do you see it helping your customers?
Now, let’s plan your LUIS app. For starters, answer these questions:
- What is the goal of your bot?
- How do you see it helping your customers?
Go through the next steps:
Step 1. Determine your domain — the way in which LUIS works is built around a domain-specific topic. For instance, you have an application for selling tickets or tracking one’s fitness. It’s a no-brainer that these apps belong to different domains, meaning they will call for different LUIS settings. There are 20 pre-built domains that can be found here.
Step 2. Make your intents clear — intents are keywords related to your customer’s wants. If your customer types in ‘buy tickets’, apparently, that’s what they want. If a fitness bot spots the word ‘pulse’, most probably, the user needs to know something about their pulse. so make a list of keywords your customers will likely use in conversations with your bot and link them with relevant actions from the side of the bot.
Step 3. Determine your entities — for example, to enable your users to book a flight, you’ll need data such as the destination, airlines, dates, ticket category, and travel class — these are entities, and you need to add them to accomplish your customer’s intent.
There are many types of entities:
- Simple entities (ones describing a single concept)
- Hierarchical entities (ones representing a category and its members)
- Composite entities (entities made up of other entities that belong to a whole)
- Prebuilt entities (LUIS provides pre-built entities for the most common types)
- List entities (explicitly specified lists of values that consist of one or more synonyms, such as airport names for a travel app)
In case you’re not sure about something, you’ll be able to change the settings later. It’s time to build your actual LUIS app and make your bot smarter!
To go right to building a LUIS app for the bot, consult a step-by-step Microsoft manual here.
If you have a clear plan for your LUIS, creating it will not be complex and take minutes.
4. BRINGING YOUR .NET BOT TO LIFE
Once you have a sophisticated bot that leverages LUIS service for brains, it’s time to launch the bot .NET kid. Yes, you need to deploy it, but don’t hurry — remember to test it before it goes live.
For this, it’s a good idea to use ngrok or any other tool that secures tunnels to your localhost. Don’t worry if your bot is a bit ‘slow’ during the testing. This time lag will disappear once your bot is deployed.
There are two ways to handle the deployment:
- Use Azure, a truly out-of-the-box solution from Microsoft with a free trial available for a month. However, it’s not very expensive — around $10 / month for a basic hosting of a bot. For more accurate numbers, use Microsoft’s calculator (link).
- DIY it — you’ll need three things though:
- Your own server or a third-party provider
- Internet-accessible endpoint
- A valid HTTPS certificate
You’re almost there! However, before we move on, you have to register your bot in the Bot Framework Portal. A word of advice: when you generate Microsoft App credentials, remember to copy and securely store the password since there’s no way of restoring lost passwords here.
5. CONNECTING THE BOT TO CHANNELS
Finally, your bot is alive and ready to start doing its job — interacting with users through chat messages. There are multiple places where you can publish it: Messenger, Bing, Cortana, Skype, etc. Two of the choices — Skype and Web Chat — are pre-configured for you. Provided you don’t find a channel you need, there’s always a custom API available.
Let’s take a closer look at the available channels:
- Skype — it’s a default channel with simple one-to-one messaging. Still, you can additionally configure web control, calling, and group chatting. Regarding the calls, you have two options: interactive voice response — it is restricted to audio, and, what is more, there’s no group call option, and real-time media — it has the chat and the group call options but is not interactive at any level. In order to leverage the real-time media capability, you need to download and implement Bot.Builder.RealTimeMediaCalling SDK and Microsoft.Skype.Bots.Media lib.
- Web-chat — like Skype, it’s a default channel that features only a simple chatting option. In Microsoft Bot Framework, you can generate code and add to virtually any website.
- Facebook Messenger — obviously, it calls for a Facebook company page where you should enable your Messenger app and use all the configurations for your channel.
- Telegram — this is the simplest way — you just have to register your bot with @BotFather.
- Bing — users can interact with the bot right in the Bing search results page. This is a great way to reinforce your SEO strategy with the keywords that you might want to link with your bot.
- Cortana — you can connect your bot to Cortana. Still, remember that for this, your bot should be designed both for speech and text.
- Email — connecting to this traditional channel can also be helpful. However, your .NET bot will be able to communicate with users only via Office 365.
- Direct Line (Custom API) — this is a REST API you can utilize to build a channel for any platform that’s not yet available. You can find detailed features of the Direct API in this link.
It’s up to you to decide which channels to use — think of your business needs and your target audience in the first place. You should create a bot specifically for your users and their unique needs, and only then your bot will drive value and even profit.
6. GIVING YOUR BOT A VOICE
You have an elaborate bot that’s becoming smarter and smarter with every interaction. Still, at this point, it’s only okay for a silent chatbox. Good news is that we can make it talk with the help of the Bot Builder Calling SDK. For the detailed instructions, read Skype Call your bot—Microsoft Bot Framework with Bing Speech.
CONCLUSION
Now you know what is bot .NET and what are the basic steps of creating your own virtual machine. We wish you luck with creating and using your bot. Still, in case application code base, environment variable, message types, status code, message payload & Co are rocket science to you, or you just don’t have time to do it yourself, you can always address DevCom with the request here. Oh and don’t forget to check out our Trivia Chatbot, it’s a wonderful entertainment .NET bot with machine learning capabilities.
In case you need additional help with anything written above or with the documentation for the .NET Bot Framework, or if everything written above seems to be rocket science to you, you can always address DevCom with the request here.