Bots are great, and really easy to create with Visual Studio and the Bot Framework. But if you want to take your Bots to the next level then you really want to set them free and deploy them to the cloud as a Bot Service.
In this quick walkthrough we will show you how you can do just that.
49. About the Author
Murray Fife is an Author of over 20 books on Microsoft Dynamics including the Bare Bones
Configuration Guide series. These guides comprise of over 15 books which step you through
the setup and configuration of Microsoft Dynamics including Finance, Operations, Human
Resources, Production, Service Management, and Project Accounting.
Throughout his 25+ years of experience in the software industry he has worked in many
different roles during his career, including as a developer, an implementation consultant, a
trainer and a demo guy within the partner channel which gives him a great understanding of
the requirements for both customers and partners perspective.
If you are interested in contacting Murray or want to follow his blogs and posts then here is
all of his contact information:
Email: murray@murrayfife.com
IM/Skype: murrayfife
Twitter: @murrayfife
Facebook: facebook.com/murraycfife
Google: google.com/+murrayfife
LinkedIn: linkedin.com/in/murrayfife
Blog: atinkerersnotebook.com
Docs: docs.com/atinkerersnotebook
SlideShare: slideshare.net/murrayfife
Amazon: amazon.com/author/murrayfife
Bots are great, and really easy to create with Visual Studio and the Bot Framework. But if you want to take your Bots to the next level then you really want to set them free and deploy them to the cloud as a Bot Service.
In this quick walkthrough we will show you how you can do just that.
The first thing that we need to do is to register our Bot.
We can register our Bots through the Bot Framework site.
So open up the Bot Framework website by browsing to dev.botframework.com.
Now that we are on the Bot Framework site we can start registering a new Bot.
To do this, just click on the Register a bot link at the top of the page.
This will open up the Bot Registration form where we can start the setup of our Bot Service.
We will start off the registration process by giving our Bot a name.
We do that by entering our Bots name into the Name field.
For this Bot we set the Name to VoightKampffBot.Name: Set to VoightKampffBot
Next we will want to give out Bot a Handle.
The Handle will be the name that is used by the Bot whenever it is interacting with you.
To do this, just enter a value into the Bot handle field.
For this Bot we set the Bot handle to Voight-Kampff.Bot handle: Set to Voight-Kampff
If we want, we can also give our Bot a Description to give people a general idea as to what our Bot does.
To do this, just enter in an overview of the Bot into the Description field.
Now that we have entered in the profile information for the Bot, we can move on to setting up the Configuration details.
If we scroll down on the Bot creation page then we will see that there are some more details within the Configuration section that we need to specify.
The first one that we will want to fill in is the App ID, which is the unique identifier for the Bot, which we need to create.
To create a new App ID, click on the Create Microsoft App ID and password button.
This will take us to a login page where we need to log in with a Microsoft account.
After we have logged in, we will be taken to a Generate App ID and Password page.
The App name will be automatically populated from the Bot registration form, and also a unique App ID will be created for us, which we will want to note down.
All we need to do is to create an app password.
To do this, click on the Generate an app password to continue button.
This will open up a dialog box with a new App password.
Note down the App password and then click on the OK button to exit from the form.
Note: This will be the only time that you will be able to see this password, so make sure you copy it down.
Now that we have our App ID and our Password we can return back to the Bot registration page and assign the App ID to our Bot.
To do this, just click on the Finish and go back to Bot Framework button.
When we return to the Bot registration form, we can then paste our App Id into the App Id field in the form.
Every Bot needs to have a brain, so before we can continue on we will want to build a Bot Service that we can deploy to Azure.
We will do this through Visual Studio 2017.
So the next thing to do is to open up Visual Studio and then click on the Create new project link in the Start Page.
This will open up the New Project dialog box and we will want to select the Bot Application.
To do this, find the Bot Application template within the Template list.
Then change the Name for the project to be something a little less generic.
For this example we set the Project Name to VoightKampffBot.
After we have done that we can just click on the OK button to create the project.Name: Change to VoightKampffBot
This will create our new Bot project for us.
Now that we have our Bot project, we will want to link it with our Bot registration information that we created earlier.
To do this, double click on the web.config file within the Solution Explorer.
Within the web.config file there are some keys that we will want to update to link it with the Azure Bot service.
To start with, update the BotId key with the ID that we registered earlier.
For this bot we set the BotId key to VoightKempffBot.BotId: Set to VoightKempffBot
Next, paste the AppId into the MicrosoftAppId key.MicrosoftAppId: Paste in the AppId
Then, paste the Password into the MicrosoftAppPassword key.MicrosoftAppPassword: Paste in the Password
If this is the first time that we are doing this, if we open up the MessageController.cs class in the Solution Explorer then we may see that there are a number of errors that are showing up in the code.
Don’t worry, this is just because we do not have the latest version of the Bot Framework extensions.
To fix this, we just have to update the NuGet package for the Bot Framework.
To do this, click on the Tools menu, then select the NuGet Package Manager, and then click on the Manage NuGet Packages for Solution menu item.Tools > NuGet Package Manager > Manage NuGet Packages for Solution
When the Solution manager is displayed, if we look at the Updates that need to be applied we will probably see that the Microsoft.Bot.Builder package needs an update.
All we need to do here is select the Microsoft.Bot.Builder package and then click on the Update button.
When we return back to our code we should see that all of the errors magically disappear.
Now we will just want to publish our bot.
To do this, click on the Build menu and then select the Publish menu item.Build > Publish
This will open up the Publish wizard.
The Microsoft Azure App Service should already be selected.
All we need to do here is click on the Publish button.
This will open up a Create App Service dialog box where we can define the App Service properties for the Bot.
Before we create the service though we will want to make a couple of changes.
The first change that we will make is to create a new Resource Group for the service.
To do this, just click on the New button beside the Resource Group and then enter in a New resource group name.
For this Bot we changed the New Resource Group Name to VoughtKempffBot.New Resource Group Name: Change to VoughtKempffBot
Also, we may want to put our bot on its own App Service Plan.
The App Service Plans host the actual service and are Azure servers. Keep in mind that depending on the type of App Service that you choose from, this may cost money. So before you chew up all of your Azure credits, check the pricing here: https://azure.microsoft.com/en-us/pricing/details/app-service/
For example, the S1 App Service will run around $75 a month.
To do this, just click on the New button beside the App Service Plan, and then click on the OK button.
Now that we have configured our App Service all that is left to do is to create it.
All you need to do here is click on the Create button.
This will start the deployment of the App Service.
When the App Service is deployed we will return back to the Publish form and Visual Studio will continue with the publishing of the Bot.
After a few seconds the Bot Service will be published and then a browser window will open up and take us to the new Bot Service endpoint.
All we need to do here is note down the URL of the Bot Service.
Now that we have created our basic service we can return back to the Bot Registration form and link our Bot Service to the Bot itself.
Now we will want to link the Bot Service with the Bot.
To do this we just paste the URL of the bot into the Messaging endpoint field with a couple of changes.
First, change the URL from http:// to https://.
And then add /api/messages to the end of the URL.
Now we can finish the registration process.
All we need to do now is click on the Register button at the bottom of the form.
We will then get a message saying that the Bot has been created.
Just click on the OK button.
This will take us to our Bot details page.
Before we move on we will want to make sure that our Bot is really working.
To do this, just click on the Test button.
If everything is working properly we will see a message saying the the Endpoint authorization succeeded.
Also if we like, we can test the interaction with the report.
To do this, just type in something into the Chat window.
For example, just say hi.
Now that we have the Bot out in the wild we can start adding it to some Channels.
If we scroll down in the Bot details we will see all of the different Channels that we can publish the Bot to. Sone have already been selected, but for this example we want to make the Bot available through Teams.
So all we need to do here is click on the Add link for the Teams Channel.
This will open the settings for the Teams Channel and enable it.
All we need to do here is click on the I’m done configuring Microsoft Teams button at the bottom of the page.
Now Teams will be in the enabled Channels.
Now we just want to add the Bot to Teams so that we can use it.
To do this, all we need to do is click on the Add to teams link.
This will make the Bot show up within Teams.
If we want to make sure that the Bot is really there, just start interacting with it.
For example, just say hi again.
How easy was that!
Now that we have a Bot published we just need to teach it how to be a little more helpful.