Get Started With Azure Bot With Bot Framework SDK V4

Azure Bot Service provides an integrated environment that is purpose-built for bot development, enabling you to build, connect, test, deploy, and manage intelligent bots.
 
In this tutorial, you will learn the following:
  1. Create Bot using VS2017 (Bot Framework SDK V4 template)
  2. Launch Emulator to run and test the Bot locally
  3. Create Azure Bot using Azure Bot Services
  4. Deploy and test the Bot at Web Chat
Below are the prerequisites:
Step 1 - Create Bot using VS2017 (Bot framework SDK V4 template)
  • Launch Visual Studio 2017, create a new project, and select the Bot Framework.
  • Select the Echo Bot (Bot Framework V4) template.
  • Select the location and give the bot name.
  • Click OK to create the project.
Get Started Azure Bot with Bot Framework SDK V4
  • The project consists of all necessary code to get started with a quick bot. Expand the solution followed by the Bot folder. Click on the EchoBot.cs file.
EchoBot.cs file consists of two main methods.
  • OnMessageActivityAsync -> Invoke with every new message
  • OnMembersAddedAsync -> invoke first time to add to any channel
Get Started Azure Bot with Bot Framework SDK V4
 
Step 2 - Launch Emulator to run and test the Bot locally
  • Fill out the fields for your bot. Use your bot's welcome page address (typically http://localhost:3978) and append routing info '/api/messages' to this address.
  • Click "Connect".
Get Started Azure Bot with Bot Framework SDK V4
 
As you connect with Bot Framework Emulator.
  • A welcome message will appear at the initial stage, i.e., “Hello and Welcome”.
  • Type the message “How r u “. You will get back the echo with the same message.
Get Started Azure Bot with Bot Framework SDK V4
 
So, a simple echo bot is created and tested locally using Bot Framework V4.
 
Step 3 - Create an Azure Bot using Azure Bot Services
 
Log into the Azure portal.
  • Click the "Create a new resource" link found on the upper left-hand corner of the Azure portal.
  • Select AI + Machine Learning.
  • Select Web App bot.
Get Started Azure Bot with Bot Framework SDK V4
 
Navigate to Azure Bot Service blade.
  • Set all the required information.

    • Name
    • Subscription
    • Resource Group
    • Location
    • Pricing
    • App Name
  • Select the Bot Template, i.e., Echo Bot (C#).
  • Click OK to select the template.
  • Click "Create" to the Azure Bot Service and deploy the bot to the cloud.
Get Started Azure Bot with Bot Framework SDK V4
 
Navigate to the App Service Setting to get the Publish profile.
  • Select "All App Service Settings".
  • Select "Overview".
  • Click on "Get Publish Profile" to download.
Get Started Azure Bot with Bot Framework SDK V4
 
Step 4 - Deploy and test the Bot at Web Chat
  • Navigate and right-click on Visual Studio Project solution.
  • Select "Build" and then publish it.
  • As you are doing the first time, the profile is not selected till yet. Click the Start button.
Get Started Azure Bot with Bot Framework SDK V4
  • Browse the downloaded profile and click the Publish button.
  • The solution will get deployed to the cloud.
Get Started Azure Bot with Bot Framework SDK V4
 
Now that your bot is created, test it in Web Chat.
 

Test the bot

 
In the Bot Management section, click Test in Web Chat. The Azure Bot Service will load the Web Chat control and connect to your bot.
 
Get Started Azure Bot with Bot Framework SDK V4
 
I hope you have enjoyed and learned something new in this article. Thanks for reading and stay tuned for the next article. 


Similar Articles