Microsoft Bot Framework helps you build interactive chat bots that interact with your users on websites, Skype, Slack, and many more places. These bots can run completely in the cloud and be enhanced with cognitive features such as language understanding, sentiment analysis, image analysis, and much more.
Microsoft Bot Framework consists of three main components:
- The Bot Builder is an open source SDK available on GitHub with source code in C#, Node.js and a REST API.
- The Developer Portal is where you register and publish your bots.
- The Bot Directory is a listing of publicly available bots.
Bots can also be created and published in the Azure Portal. Bots created in the Azure Portal use Azure Functions (a serverless code architecture) instead of the SDK on GitHub. This looks very interesting, but the Azure Portal Bots are still very experimental (as of April 2017).
Getting a Bot handle, an App ID and a password for your bot
To use the Bot Framework you will need an App ID and a password. You will get that when registering you bot on the Developer Portal.
Note:
- The Bot handle (also called BotId) will determine the API address of your bot. It has to be unique and it cannot be changed later.
- The messaging endpoint should be left empty. You will configure it later.
- A password will be generated for your bot. Make sure to copy it because it won’t be displayed again.
Downloading the Bot Builder samples
To get started I recommend downloading the GitHub BotBuilder samples.
On the GitHub samples you also have the option to Deploy to Azure. Clicking on that button will take you to a deployment page where you can customize some parameters and enter your App ID and password. It will then create an Azure Website that works as the bot backend. Finally you will need to manually enter the messaging endpoint (which is in the format https://yourwebsite.azurewebsites.net/api/messages) in the bot developer portal. You won’t be able to make any customizations without downloading the sample source code from GitHub.
Running a Bot Builder sample
After downloading the GitHub samples, you will get a lot of examples. Each of them demonstrates some functionality in Bot Framework. Let’s start by testing the core-State bot.
- In the folder core-State you will find the solution file StateBot.sln. Open it in Visual Studio.
- The README.md file contains some information about the particular bot. For this bot it describes how to persist user data (“state”).
- Edit the Web.config file. Enter your BotId (bot handle), App ID and password.
- Deploy your project to Azure by right-clicking on the project and then Publish. Then you can select Azure and configure your publish settings.
- Finally you will need to manually enter the messaging endpoint (which is in the format https://yourwebsite.azurewebsites.net/api/messages) in the bot developer portal.
- You can test the bot in the bot developer portal, in the chat window on the right side.
Using the Visual Studio Template for Bot Framework
There is a template for Visual Studio that helps you creating new bots. It is available on the Bot Framework Downloads page. Click on Tools -> Visual Studio Template – C#. You will get a zip-file. Copy this zip-file to your Visual Studio template directory (something like C:\Users\YourUserName\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#).
You will now have the Bot Application option in Visual Studio.
After creating a project you will manually need to edit Web.config to enter your Bot Handle (also called BotId), App ID and password:
<add key="BotId" value="YourBotId" /> <add key="MicrosoftAppId" value="" /> <add key="MicrosoftAppPassword" value="" />
Deploy your project to Azure by right-clicking on the project and then Publish. Then you can select Azure and configure your publish settings.
Finally you will need to manually enter the messaging endpoint (which is in the format https://yourwebsite.azurewebsites.net/api/messages) in the bot developer portal.
Next step
Read about debugging your bots in my next blog post.
For further reading there is also this book (as of April 2017 only available for preorder).