Now that we’ve built our first bot with Bot Framework that’s running locally, let’s move forward by making it publicly available. We’ll do so by running the bot in Microsoft Azure. By doing this, we’ll make it easier to connect your bot with services like Slack or Messenger. Take note Azure is not required (any hosting platform will do), but since it makes things a lot easier we’ll go for Azure.
Before we continue, make sure you have met the following requirements:
- Once again, I’ll be using Visual Studio as my IDE.
- The Bot Framework project that we’ll be running in Azure. I’ll be using the one from my previous article.
- A Microsoft Azure account.
Head over to Bot Framework to register your bot. Under My Bots, select Create a bot. Continue in order to create a new bot and fill in the required fields. I decided to call my bot
mfRestaurant and use that as BotID as well (
mf is short for Marcofolio).
Under Configuration, you’ll have to set your Messaging endpoint. When hosting in Azure, your endpoint will look somewhat like:
BOT_URL will contain the URL of your bot in Azure, in my case
mfrestaurant. Although this value can be changed later, it’s valuable to make sure this name hasn’t been taken yet before we proceed. Register your bot with Microsoft by clicking the button, which will add the bot to the overview of apps that you have registered. Store the given App ID and App password since we’ll need them later. We’ll keep the Analytics-section empty (for now) and Register to continue.
Head over to Visual Studio and open up the
Web.config. Locate the following lines:
<appSettings> <!-- update these with your BotId, Microsoft App Id and your Microsoft App Password--> <add key="BotId" value="YourBotId" /> <add key="MicrosoftAppId" value="" /> <add key="MicrosoftAppPassword" value="" /> </appSettings>
Simply fill in the values that were entered/given during the Registration-phase and save the file. Now Right-click your solution and select Publish in order to deploy your bot. This will pop-up a new window to enter all the needed details.
Select Microsoft Azure App Service as your publish target. You’ll need to enter your Azure credentials and select the right Subscription on the next page. Once everything has been configured, you’ll be able to publish the App Service through a Web Deploy. Here you’re also able to see which URL is used to host the bot. Hit the Publish button and your bot will be deployed to Azure.
Once deployed, you can head over to your
azurewebsites.net-URL to view the
default.htm page. If you’re able to see that page, the deployment was successful! You can also view your App Service in the Azure Portal.
The easiest way to test if your bot is working, is by heading back to Bot Framework and select your bot. Here you’ll find the channels your bot is connected to (by default Skype and Web Chat), but you’re also able to Test. Simply press the Test-button on the top of the page and start chatting with your bot. If everything has been done correctly, it should be able to respond as if it was running on your local machine.
By now, we got our bot succesfully running in Microsoft Azure. Once these configuration steps are completed, deploying in the future will be a lot easier – simply publish from Visual Studio (or VSTS) and you’re done! In the next articles we’ll dive into the possibilities to connect these to another channel like Slack or Messenger. Stay tuned and let me know what you think in the comments or on Twitter.
Want to learn more about this subject?
Join my “Weaving Cognitive and Azure Services“-presentation at TechDaysNL 2017!