Microsoft’s Bot Framework

Microsoft’s Bot Framework

Introduction

    The Microsoft’s Bot Framework is an inclusive offering that is used in building, as well as deploying quality bots for their users while enjoying their desired conversational practices. When writing bots, all developers face the same issues. It paramount that the bots have the basic I/O; it is a requirement for them to have language and dialog skills; it is crucial for them to be performant, receptive, and scalable. Moreover, they must connect to the users. The Bot Framework offers all services that an individual requires to build, link, manage, and distribute intelligent web bots that have the capacity to interact naturally when the users are applying them to communicate. Popular services offered by the Bot Framework include Facebook Messenger, text/SMS, Office 365 mail, Skype, Slack, and Kik, among many other current services (Microsoft, 2016).

    Microsoft came up with the bot framework to make the work (building and linking great bots to users) of the developers easier when communicating through various channels including the Microsoft’s own premium channel. The Microsoft bot framework is publicly available since its preview release on March 30th 2016 in conjunction with its yearly developer building guide. The Microsoft bot framework developers are in the process of ensuring the initial bot framework is made available to its users and are also planning to continually enhance it through embracing additional tools, models, and communication channels. They have also made the bot builder SDK free to the public whom they wish to assess their contributions regarding the functionality of the developer framework (Microsoft, 2016).

Components of the Microsoft’s Bot Framework

The Microsoft’s Bot Framework comprises of three main components including the Bot Builder SDK, Developer Portal, and the Bot Directory. These three components help the users when developing any application that their customers will be using to communicate with others.

Bot Builder SDK

    It signifies the various tools used in building great and quality bots that can communicate wherever the users are situated. It is an open source SDK that is hosted on GitHub. It offers the whole lot of things an individual requires to build great and quality dialogs within the users’ Node.js, NET or REST API-based bot. The Bot Builder SDK comprises of dialogs that model the user’s conversation wherever they are. The dialogues are reusable at any time in a particular form thus making it easier for the users to keep on enjoying using the applications developed by Microsoft. Some common types of dialogues include built-in prompts, Yes/No, Strings, Number, and Choices, FormFlow and form slot filling constituting branching, disambiguation and multiturn. It is an advanced approach in developing applications since most of its conversations are scalable to multiple machines that are used by different people in the contemporary world (Microsoft, 2016).

    The Bot Builder SDK is most applicable because it has a rich support for attachment of images, card, video and doc among many others. These are the most desired services that users enjoy sending to their counterparts during any conversation. So, the developers use the Bot Builder SDK to win over their clients’ trust and support. The framework also provides service extensions for language comprehension (LUIS) as well as its translation. This makes it easier to develop an application that will be appealing to the target users. Lastly, the framework offers online as well as offline chat emulator services. This feature makes it desirable to the developers since the users of their applications will be having an added advantage when they are offline (Microsoft, 2016).

Figure 1: Bot Builder SDK


    The bot builder SDK, being an open source SDK that is hosted on GitHub, offers all that developers desire in the process of creating current communication applications. The services it offers include Node.js, .NET or REST as seen earlier. It provides simple prompts and command dialogues to complex and refined FormFlow dialogues that help the users in tricky situations including multiturn and disambiguation. The bot builder SDK also offers libraries, samples and various tools needed by the developers to ensure their bot is up and functional.

Bot Framework Developer Portal

    This portal allows its users to connect their bots seamlessly with various global conversational experiences including the text/sms, Slack, Facebook Messenger, Skype, Office 365 mail, Kik, and other general services. The process requires the users to basically, register their bot, configure their anticipated channels and publish them in the Bot Directory. All bots that are registered within the Bot Framework are normally auto-configured to operate alongside Skype and the World Wide Web (Microsoft, 2016).

Figure 2: Developer Portal


    For an individual to make his/her bot available through the Microsoft bot framework, they must have the following services and products; a bot, a Microsoft account through which they will register and manage the bot in the Microsoft framework, strong internet through which one will access REST endpoint that is usually used in revealing the bot framework conversations API, and lastly but optional, accounts on one or more message services where the bot will be communicating.

Registering

    To register one’s pot requires them to sign in to the Microsoft bot framework providing obligatory details for the pots more especially a bot image. After registration, the developers can use the dashboard to test their bots by verifying if they are conversing well with the connector service. They can also use the webchat controller, outo-configured network to experience what the developers will face when communicating with their various bots.

Connecting to channels

Connecting requires individuals to link their bots to the communication networks of their choice through the configuration page on the developer portal and the developer credentials connected with the chosen communication network. Mostly, Skype and various Web networks are auto-configured for everyone.

Testing

The individual developers ought to test their bot’s connection to the bot framework and attempt using the wb chart controller.

Publishing

During publishing, all bots listed and reviewed through the developer portal will appear in the bot directory in which the various users can discover, attempt and complement bots regarding their favorite communication experiences. The registration exercise is very vital because it will ensure the bots’ public visibility is achieved. The bots’ public visibility can, however, be changed at any time. It is essential for developers to note that individual networks require additional steps to ensure the bots appear in the network-specific directories.

Measuring

For instance, if individuals host their bot in Azure, they can also link them to Azure application insight analytics unswervingly from their bots’ dashboard in the Microsoft bot framework website. There are various analytical tools employed by the developers that can be used to examine the various bot usages.

Managing

The final process of bot building requires that the developers manage their bot through their bot’s dashboard situated in the Microsoft framework developer portal.

Bot Directory

This is a public directory that consists of all reviewed bots that have been registered through this portal. The users of this portal have the permission to discover, attempt, and add bots to their preferred talk experiences from the bot directory. The one condition required for the bots to reflect in the directory is that the developers must submit them for review. The bots are also searchable using the Bot directory making it easier when trying to locate them (Microsoft, 2016).

    Each and every bot directory has its own contact card that constitutes a bot name, its publisher, its description, and the various networks on which it can be retrieved from. This information can help the users to view the details of any bot, attempt to use the web chart controller and complement the bot to any network on which it is configured. The various bot cards can also be used in reporting abuse by the users. The bot directory encompasses all highlighted bots that are searchable to help the users when trying to retrieve them. It is important to note however that the developer can opt to publish or not publish their bots in the directory when engaging themselves in the registration of their bots. The bot directory is open to all developers who are wishing to submit their bots as well review them (Microsoft, 2016).

Why write a Bot?

    Due to the development of the conversational interface (CUI), people are running up and down to understand how various applications developed to function in the process of conveying information to their peers. An overabundance of the global chit-chat bots provides services and products for our numerous communication channels encompassing Skype and Facebook Messenger. As the world is growing old, technology is also advancing at a great speed. This has resulted in the development of a sequence of personal agent services that influence technologies, humans or both of them to complete various tasks for the users. The personal agent services may include x.ai, Task Rabbit, Clara Labs, Fancy Hands, Facebook “M” among many others (Microsoft, 2016).

    The fundamental interface for all the conversational experiences is the use of buttons, email, text, cards, or voice. Therefore, the conversation-driven User Interface enables its users to do all activities ranging from taking a taxi, to the payment of the electric bill or sending money to people all over the world. The provision of services and products such as Google Now, Siri, and Cortana prove value to masses of individuals in the daily activities, mostly through the various mobile devices where the CUI can predominate the GUI or matches it. The Bots and the personal conversation agents are increasingly becoming part and parcel of people’s daily digital experience. These services are very vital in the daily conversations of people as they interact with their peers in other places of the world to meet their daily expectations and experiences of life.

Target users of the Microsoft Bot Framework

    The Microsoft’s Bot Framework is mainly targeted at the global application developers wishing to create new products and services with the application of the great bot interface or seek to enable an existing product or service with the great bot interface. The app developers writing the various bots all face the same issues as seen earlier. They must connect the users in their daily conversations as well as capture the preferred language by the users. The Microsoft Bot Framework offers various tools that are used in addressing the emerging issues while also defining a way how the developers ought to discover, attempt, and add bots to the daily conversational experiences they embrace through the Bot Directory (Microsoft, 2016).

    The users of the Bot Framework may take advantage of the various services offered. They include auto-configured Skype network and Web network, embeddable Web chat controller, programmed card standardization making the bot to be responsive across all networks, the Direct Line API used to host an individual’s bot in an app, the debugging tools together with the Bot Framework Emulator that is functional both online and offline, and the influential service extensions that make one’s bot smarter via the cognitive products and services including LUIS meant for language comprehension, translation used in instinctive conversion of more than thirty common languages worldwide, and FormFlow that is meant for image generated bots. The various cognitive services signify the existing capabilities that have been introduced by Microsoft Build 2016 that will be combined into Cortana intelligence suite situated at GA. These services have been built through holding numerous research studies regarding the use of the popular Microsoft products and services across the world. The combination of the services with Cortana intelligence is meant to help all business organizations in taking advantage of the influence of data, the cloud computing and intelligence to come up with their personal intelligent structures. These structures will be aimed at unlocking new business prospects and increase their way of doing business to become the leaders in the business environment (Microsoft, 2016).

Using the Microsoft Bot Framework

For one to get started in using the Microsoft Bot Framework, he/she is required to first visit the Microsoft Bot Framework, then register a bot in the developer portal if you have a Microsoft account. The developers can also get started building the bot through Node.js, NET or REST API found in the Microsoft bot framework user manual.

Channels Currently Supported by the Microsoft Framework

As of July, this year, the technologies supported by the bot framework include Kik, text/SMS, Facebook Messenger, Office 365 mail, GroupMe, Skype (auto-configured), Telegram, Slack, The Web (auto-configured, embeddable) and the Direct Line (API to host one’s bot in their app

Building bots using the Microsoft bot Framework

The building of bots using Microsoft bot Framework undergoes five steps as follows;

Step 1: create a bot application

Conduct all the registration exercise appropriately by providing all obligatory information.

Step 2: creating the class in one’s project using any name.

For instance, if the name is Google Bot Application, one can write the following code inside the project.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Threading.Tasks;
  6. using System.Web;
  7. namespace StockBot2
  8. {
  9.     public class GoogleBot
  10.     {
  11.         public static async Task<double?> GetStockRateAsync(string StockSymbol)
  12.         {
  13.             try
  14.             {
  15.                 string ServiceURL = $”http://finance.google.com/d/quotes.csv?s={StockSymbol}&f=sl1d1nd”;
  16.                 string ResultInCSV;
  17.                 using (WebClient client = new WebClient())
  18.                 {
  19.                     ResultInCSV = await client.DownloadStringTaskAsync(ServiceURL).ConfigureAwait(false);
  20.                 }
  21.                 var FirstLine = ResultInCSV.Split(‘\n’)[0];
  22.                 var Price = FirstLine.Split(‘,’)[1];
  23.                 if (Price != null && Price.Length >= 0)
  24.                 {
  25.                     double result;
  26.                     if (double.TryParse(Price, out result))
  27.                     {
  28.                         return result;
  29.                     }
  30.                 }
  31.                 return null;
  32.             }
  33.             catch (WebException ex)
  34.             {
  35.                 //handle your exception here
  36.                 throw ex;
  37.             }
  38.         }
  39.     }
  40. }

    Through this code, one can perceive a function that is GetStockRateAsync that uses a StockSymbol as a parameter. An individual is calling Google Finance API, to which they will pass that parameter and that will feedback a CSV file of stock bazaar rate, this is followed by splitting the CSV File by a comma since a CSV File means a Comma Unglued Value. So, they are excruciating by a comma (,) and getting the existing value of that stock. Then they are translating it into double since the stock rate will take a double-digit format and feedback the current price.

Step 3: In the Messages Controller, one should create a class that will call the above function., for instance, create a GetStock function in My MessageController class.

The code is as follows;

  1. private async Task<string> GetStock(string StockSymbol)
  2. {
  3.     double? dblStockValue = await GoogleBot.GetStockRateAsync(StockSymbol);
  4.     if(dblStockValue==null)
  5.     {
  6.         return string.Format(“This \”{0}\” is not an valid stock symbol”,StockSymbol);
  7.     }
  8.     else
  9.     {
  10.         return string.Format(“Stock : {0}\n Price : {1}”,StockSymbol,dblStockValue);
  11.     }
  12. }

The code shows that an individual is calling his/her GetStockRateAsync function that is meant to feedback a nullable double. He/she is checking whether the stock value is null or not.

According to stock value, the individual is returning appropriate string

Step 4: it involves calling the GetStock function from Post action of MessagesController.

The post action code is as follows;

  1. public async Task<Message> Post([FromBody]Message message)
  2. {
  3.     if (message.Type == “Message”)
  4.     {
  5.         string StockRateString = await GetStock(message.Text);
  6.         // return our reply to the user
  7.         return message.CreateReplyMessage(StockRateString);
  8.     }
  9.     else
  10.     {
  11.         return HandleSystemMessage(message);
  12.     }
  13. }

This code will see the user send a message that is nothing but a symbol, the GetStock function will be called and will feed back an appropriate message.

Step 5: Run the project and simulate in Bot Framework Simulator

After running the code, the google stock will be displayed as follows.

(Sourabh, 2016).

Deploying custom bots from Visual studio

Step 1: Get the Bot Builder SDK samples

Copy the Bot Builder SDK Github repo, by opening a command prompt. You should choose a location of your choice (e.g. c:\code), and type the following code:

git clone https://github.com/Microsoft/BotBuilder/

Step 2: Open the hello-AzureWebApp sample, install the missing npm packages, then configure the temporary appId and appSecret

Open the hello-AzureWebApp.sln solution in Visual Studio, right click on the npm folder, then click on “Install missing npm packages”.


Ater finishing, open the web.config, then edit it as follows:

<appSettings>

<add key=”BOTFRAMEWORK_APPID” value=”appid” />

<add key=”BOTFRAMEWORK_APPSECRET” value=”appsecret” />

</appSettings>

Note: You can change these values after registering the bot with the Bot Framework Developer Portal.

Step 3: Publish to Azure

  • Right click on the hello-AzureWebApp project in solution explorer, then click on publish
  • Provide the Azure credentials, and then create a new Web App
  • Follow the publishing wizard, and click on Publish.

Step 4: Test the connection to your bot

Test your bot with the Bot Framework Emulator

(Microsoft, 2016).

Deploying using one’s local git

Step 1: Install the Azure CL

Open the command prompt, cd into the bot folder, then run the following code:

npm install azure-cli -g

Step 2: Create an Azure site, and configure it for Node.js/git

Log into the Azure account by typing the following in the command prompt:

azure login

After logging into the Azure account, create a new site, then configure it for Node.js and git using the following command:

azure site create –git <appname>

where <appname> is the name of the site to be created. This will result in a url like appname.azurewebsites.net.

Step 3: Commit your changes to git, and push to your Azure site

Type the following in the command prompt:

git add .

git commit -m “<your commit message>”

git push azure master

At this stage, there is an obligation to provide the credentials for deployment.

N/B if you do not have the credentials, follow the following steps:

  1. Visit the Azure Portal
  2. Click on the site you’ve just created, and open the all settings edge
  3. In the Publishing section, click on Deployment credentials, enter a username and password, and save


  4. Go back to your command prompt, and enter the deployment credentials.
  5. Your bot will be deployed to your Azure site

Step 4: Test the connection to your bot

Test your bot with the Bot Framework Emulator.

(Microsoft, 2016).

References

Sourabh, S. (2016). Real Time Bot Project Using Microsoft Bot Framework. Retrieved December 20, 2016, from http://www.c-sharpcorner.com/article/real-time-bot-project-using-microsoft-bot-framework/.

Microsoft (2016). Deploying to Azure. Retrieved December 20, 2016, from https://docs.botframework.com/en-us/node/builder/guides/deploying-to-azure/


Curious about what Bots are or the Microsoft Bot Framework.  Take my Udemy course “Bot Building Basics” where you will build an actual chatbot using no code. Click here to get the course for only $25 http://bit.ly/jstreetviews

Leave a Reply

Your email address will not be published. Required fields are marked *