Integrating Machine Learning APIs in Microsoft Bot framework Apps

bot, is a software application that runs automated tasks over the Internet. Typically, bots perform tasks that are both simple and structurally repetitive, at a much higher rate than would be possible for a human alone. The largest use of bots is in searching, in which an automated script fetches, analyzes and files information from web servers at many times the speed of a human.

In this blog we will guide the reader in creating a bot that will enable you to quickly do data analytics. e.g. to begin with steps for doing text based sentiment analysis.

Solution being developed using following Microsoft Technologies:
1. Microsoft Bot Framework
2. Machine Learning APIs for Sentiment analysis

Here are the steps:
Microsoft Bot framework application

1. Add a Bot template in Visual Studio 2015 Community edition as per instructions given from this link

2. Create a bot template based Visual Studio C# solution using the downloaded template. add and update the following code to the template created code to update the messages:

public class MessagesController : ApiController{
/// POST: api/Messages
/// Receive a message from a user and reply to it
public async Task Post([FromBody]Message message) {
if (message.Type == "Message") {
// calculate something for us to return
int length = (message.Text ?? string.Empty).Length;
string sentimentResponse = GetSentimentResponse.GetSentiment(message.Text);
return message.CreateReplyMessage($"Your message {length}. " + sentimentResponse);
else {
return HandleSystemMessage(message);

3. Using bot emulator ensure that bot is responding to messages as per the code. Now that the bot is created we will integrate it in Skype so that we can use an existing application that makes our bot immediately usable Refer to this link for registering the bot with Skype.

Machine Learning APIs for Sentiment analysis

4. Next step is to integrate the Microsoft Machine API’s check this link for details:

5. The user text (e.g. entered in Skype) is used for sentiment analysis as shown in the code below:
public static String GetSentiment(string message) {
try {
string myComment = message.Replace(' ', '+');
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

string key = "AccountKey:" + "";
byte[] creds = System.Text.Encoding.UTF8.GetBytes(key);
client.DefaultRequestHeaders.Add( "Authorization", "Basic "+ System.Text.Encoding.UTF8.GetString(creds));
HttpResponseMessage response = client.GetAsync("" + myComment).Result;
if (response.IsSuccessStatusCode) {
var data = response.Content.ReadAsStringAsync().Result;
var product = JsonConvert.DeserializeObject(data);
return $"Your sentiment is {product.Score}. Have a good time";
else message = response.ReasonPhrase;
catch (Exception ex) {
return message;

6. This code demonstrates how we can integrated Machine Learning API using the Microsoft bot framework

Many More such use case can be integrated similarly e.g. SMS being sent for some specific activity in a Industrial establishment.

Hosting an Industrial Device Online


The Internet of Things (IoT, sometimes Internet of Everything) is the network of physical objects or “things” embedded with electronics, software, sensors, and connectivity to enable objects to exchange data with the manufacturer, operator and/or other connected devices based on the infrastructure of International Telecommunication Union’s Global Standards Initiative.
The Internet of Things allows objects to be sensed and controlled remotely across existing network infrastructure, creating opportunities for more direct integration between the physical world and computer-based systems, and resulting in improved efficiency, accuracy and economic benefit.(Wikipedia)


• Access Dashboard information from anywhere about a device
• Enhanced customer service
• Increased revenue from services and/or products
• Improved use of assets in the field
• More information to feed big data/analytics efforts
• Identifying Areas of development
• Remote asset management and/or asset tracking
• Security (e.g., 4G cameras)
• Energy data management
• Condition-based monitoring
• Fleet management


As shown in the diagram a device can be enabled by first adding a native webserver so relevant its data can be made available in a dashboard and is searchable. This step may require adding a hardware component or native component and then hosting on a local web server. This is possible on embedded Linux OS for all other types of device it needs to be seen how the webserver can be hosted.

Online Device Block Diagram

As shown in the diagram a GSM based mobile device can ensure the connectivity to the internet. The socket communication can be done with the online device server and device once the device is brought online. The online device app will host the web server that will send the request to the socket server.

To prepare the solution we need to have
1. Socket Client – on the device
2. Socket Server – on the web
3. Reverse HTTP Protocol Relay Server – on the web
4. Hosting of the HTTP Server on AWS cloud or any other cloud provider


Source code for above solution is freely available and can be downloaded from:

Increasing online sales reach through referral’s

Dictionary meaning of referral is – an act of referring someone or something for consultation, review, or further action.
– the directing of a patient to a medical specialist by a GP.
– a person whose case has been referred to a specialist doctor or a professional body.
– Referrals is not a new concept and we all know it works with improved relationships, word of mouth etc..

If we look closer into the minds of the customer and see what ticks is the cost-benefit, trust and potential guarantee of improved relationship.

Online sales and offline sales referrals and can be depicted from the diagram below:


Its clear that there is a demand for better service and typically buyer is in need for not only just an advise but also advise that has some credibility hence customer is waiting for the right idea that works! In a offline model its a lot of communications through phone before this is possible.

An online referral comes as a perfect fit for much needed requirement. Even then its not guaranteed that a referral always works but it improves the chances. At the least if a customer is not able to make a decision – the very indecision typically leads to asking or seeking for an advise – and then with correct matched-advise results in a good referral.

To conclude an online application when referred by someone for a requirement can be known much easily and hence can enable better business results. Although it necessary for customer to expresses its requirement online to the seller.

Implementing Six Sigma practices for better Quality

In a typical software development and testing projects – Agile and SDLC (Software Development Life cycle) practices are sufficient although to further improve quality beyond a certain extent advanced techniques are required. In this article the discussion is about how six sigma can be introduced to further improve the quality of the software product development and its delivery. For illustration purpose a software organization can be depicted as consisting the following:

• Business
• Process and
• People


In the above diagram improvements cannot be introduced although its enough to deliver the projects as per customer requirements. Six sigma techniques provides the possibilities for further improvements by adding to activities that can be introduced that will also further the overall organizational capabilities. Hence the purpose of improving the quality is just one aspect of overall capability improvements that are possible and can be depicted in the diagram shown below:


It is also observed that due to reporting to client/customer andt changing customer expectations the basic software testing in the SDLC processes is not enough hence additional data needs to be collected in ensuring reporting and also demonstrating quality as per customer expectations. Thus its imperative to improve by training in teams throughout organization and to be familiar with the additional activities to improve quality. These are categorized as below:

• Each team will have at least one six sigma champion – if not team member manager that can be designated.
• The designated team member will perform checks on the following sub-tasks

    • Continuous improvement
    • Maintaining customer satisfaction / loyalty by asking questions
    • Root cause analysis as a process
    • Identifying the performance metrics and reporting QA and development activities to client and stake holders
    • Voice of customer – understanding and establishing the end user/consumer
    • Trend analysis of requirements, delivery and issue tracking
    • Cause and effect analysis as a process
    • Identifying a process to fulfill a requirement and helping in improving it in discussion with client and within organization
    • Identifying and improving by taking special initiatives on poor quality areas


• In addition its possible to build on following capabilities :

    • ISO 9000
    • Project Management

• Further Each project and product development can customize the development process by introducing the Plan – Do – Check – Act process for development activities

• Continue to strict adherence to Agile and other SDLC practices for software development activities

The result of doing the above tasks will result in overall quality improvement.

Further following metrics can be measured:

• Improved predictability
• Delivering the project on time and as per schedule
• Better resource management
• Improved customer satisfaction

Web.Config Transforms

It is very common for a web applications to have different environments like follows:

  • Development
  • Staging
  • Production

There are different settings, configurations related to the application in web services (backend) or frontend which use a set of configuration defined under “Web.config”.

Web.config plays an important role in storing all the settings and configurations related to the web application. There are multiple instances where web.config defines information that controls module loading, security configuration, session state configuration and application language and compilation settings.

Connection strings are also present in web.config which vary according to the various databases used by development team.

As tracking of various settings and configuration seems (and it indeed isJ) a daunting task, it makes complete sense to have a mechanism which will provide a seamless way to pick the correct configurations according to the environments.

Enter Web.config transforms

Web.config transforms include XML markup that defines how to change web.config when it is deployed. These different changes are derived from project build configurations.

Default build configurations are Debug and Release, while custom build configurations can be created.

Build configurations

When a project is created, “Debug” and “Release” are the pre-existing build configurations.

You can create custom build configurations easily by using “Configuration Manager”.

Creating custom build configuration

In Visual Studio 2012, open a solution, and click on the drop down list for “Solution Configurations”.


Click Configuration Manager..

Configuration Manager dialog will be shown.

In the drop down list for ‘Active solution configuration’ select ‘<New…>’ and provide a name for the new configuration.

If you wish, you can use settings from other build configurations if applicable.

When done, we will need to add the config transforms related to the new configuration created.

Adding Config Transforms

Right click on web.config in the corresponding solution to see the context menu.

Select “Add Config Transforms”.

This will result in creating the transforms for the related build configuration.

For instance, I have created build configurations as – ReleaseStagingPM, ReleaseStaging, and ReleaseProduction, in addition to pre-existing Debug and Release.

The config transforms are created as below:


As shown, with respect to each build configuration, there is one web.config.

So? What it has for me?

With the use of XDT transforms, web.config transforms provide a very simple and efficient way of managing your configuration parameters.

For instance, my original web.config contains following:


<endpoint address=”http://localhost:50047/MyService1.svc&#8221; binding=”basicHttpBinding”   name=”BasicHttpBinding_IMyService1″/>

There is a web service called “MyService1.svc”. For the purpose of development and frequent debugging, I am pointing it to http(colon)//localhost(colon)50047/, which is the development environment.

Now, when I configure my respective “transformed” web.config, I use XDT transform to let web.config transforms know what pointing I am intending to change.

This is achieved by following line of code.



<endpoint address=”; binding=”basicHttpBinding” bindingConfiguration=”BasicHttpBinding_IMyService1″ name=”BasicHttpBinding_IMyService1″ xdt:Transform =”Replace” xdt:Locator =”Match(name)”/>

Now, if you observe the last two parameters, they employ XDT transform “Replace” to replace the line of code, by identifying “name”. It is highlighted in bold black font.

More syntax for XDT transform can be found at:

As a result, when I am building the web application, the “transformed” web.config will have above endpoint instead of my development environment endpoint.

In this way, an efficient use of web.config transform enables quick changes in web.config according to environments. This leads to faster deployments.

How to Enable Devices for Internet of Things?

Definition of Internet of Things

Internet of Things is broad term used for many objects and their virtual representations within the internet architecture. Detailed descriptions can be found in the Wiki link –

In this discussion the scope is limited to devices that is shown in the diagram below:


What is the Problem with the devices?

In internet of things terminology the device of concern is not directly connected to internet or has no access to internet. The level of sharing of information and thus status of various components is not adequate to make decisions. A decision typically require availability of various metrics parameters, some of these are:

  • Productivity
  • Application analytics
  • Feature enhancements and components upgrades
  • New integrations
  • Cost reductions ideas
  • Data Trends

A standalone device is not designed to provide the advanced data on continual basis – one of the many reasons being it’s not connected and is not available on the web. The resources using these devices are also isolated due to the nature of work surrounding the devices. Some of the examples of these devices are in industrial environments of:

  • Oil and Gas Industry
  • Manufacturing Industry
  • Consumer Industry

It is known thing that in these industries it’s neither appropriate nor cost effective at design time to provide the interfaces.

Design and feature tradeoffs of existing designs

When the devices were designed the design was done so that it solves the main problem e.g. a gas sensor is designed to first successfully detect the gas values and provide data to the immediate environment. The design of hardware also and any other visual display is primarily intended only to serve the purpose and not necessarily justify the cost of added benefits. Although the enterprises would benefit better integrated systems not always all legacy devices would have the connectivity when the product is designed.

How do we solve the problem?

There are many ways to solve the above problem some of the methods are:

  • Use industry standard platform e.g. Windows embedded OS and enable web server interfaces
  • Ethernet network enable devices
  • Add Wi-fi enabled device interface
  • Add Bluetooth interface to provide networking support
  • Enable web server access – users should be able to access the device using a URL. The status of device and external interface functionality
  • Enable exporting of data trends in reports
  • Web service API for uploading data for external apps

How to enable the devices for IoT?

  • Enable web server access – users should be able to access the device using a URL. The status of device and external interface functionality
  • Enable exporting of trend reports
  • Remote access to device
  • Web service API for uploading data for external apps
  • etc..

What are the added benefits of connected devices?

Connected devices can be easily integrated into various external systems to better e nablethe overall deployment in enterprises.

In Search of Value in Software Testing

It’s important to value the work done by a Tester. Though a tester will typically create and modify own assets namely the test cases, test execution results these are not necessarily quantifiable in terms of productivity and hence there is need to take help of better metrics. Typically the following are widely used:

• Number of Test Cases
• Test Execution Rate
• Defect Finding Rate

A Testing project consists of Test Deliverables – these include testing and its results. A product is measured in identifying defects in code and is correctly identified by defect rate.

What are the other metrics?
The product quality requires consideration for the other metrics

• Quality of Test Cases
• Quality of Execution
• Quality of Defects

These metrics are a result of what result these produce. Though before we can proceed with the next step it’s important to measure more critical “Quality Metrics”.

To understand the issue let us look at the developer live cycle (SDLC). A Developer spends considerable time in designing the product and identify use cases. The main use case and secondary uses are thoroughly understood and then code logic is developed and implemented. The code is then tested and defects reported. These do cover most of the testing although it cannot be said that all is done. During our testing of small and large test projects it was observed that following additional techniques were required to further improve the testing efforts and add value to testing process. These methods are well known and very useful for identifying the defects and improving overall quality

Root cause analysis using Fishbone Diagram
• Test case documentation standard Checklists
• Verification Checklists
• Preparing the Modular flow (and understanding) of the code.

In the above methods fishbone diagram as shown has shown the maximum benefit:

Fishbone diagram

Fishbone diagram

Having a process oriented approach and applying all of the above techniques the rate for defect finding was found to be improving and quantifiable.

Additional reading can be found here