Introduction

The Bot Framework enables you to build bots that support different types of interactions with users. You can design conversations in your bot to be freeform. Your bot can also have more guided interactions where it provides the user choices or actions. The conversation can use simple text strings or more complex rich cards that contain text, images, and action buttons. And you can add natural language interactions, which let your users interact with your bots in a natural and expressive way.



In this article, You will get understand deploy a bot application to Azure using visual studio 2019, you can register app in Azure portal and test in Bot Framework Emulator and Webchat Channel.

Setting up the development environment

In order to follow along with this article, you will need the following apps and accounts:
  • Microsoft Account (MSA) – Use your existing account, or click here to create a new account.
  • Visual Studio 2019 IDE – Available for free download here
  • Azure Account – Use your MSA Account to sign-in to the Azure Portal
  • Download the Bot Framework V4 Emulator for your platform from the GitHub releases
  • You can read my previous article for Getting Started with Bots Using Visual Studio 2019 from here

Register Bot Application

After installing and configuring all of the above listed software and accounts, continue to the below steps.

Step 1: 

Create a new bot or register an existing bot with the Azure Bot Service from here


Step 2: 

Click on Sign in button and login with Azure credential

Step 3:

 Click on Create web app Bot

Step 4: 

Start create Web App Bot and click on Create 


Step 5: 

You can provide the following information in Web app bot and create a new Microsoft App Id and password and click on Create



Once its completed, it will generate Application end point url and appID and there are 4 service will create automatically in azure portal as follows 
  • App service
  • APP service plan
  • Web app bot
  • Application insights.
Open your app Service in Azure and copy the Microsoft App Id, Microsoft App Password,LUIS Hostname,Key and AppID values from application settings .


Create Bot Application using Visual Studio 2019.

You can read my previous article for setup Bot development environment in visual studio 2019 and create simple Bot using Visual Studio 2019 from here

Update AppSeting.JSON File

Open appsetting.json file from Visual studio 2019 and past your MicrosoftAppId, apppassword, LUisAppID, LUISApIKey and host name.



Run Bot Application in Local Emulator

Let we start test our bot application in locally using Bot emulator. Open emulator and click configure new Bot and provide local end point URL and Appid and password.



Publish Bot Application into Azure App Service

Once tested your application in locally. Now, we can publish bot application to Azure. Right click on Bot Project > Select on Publish and start publish bot application into azure



Visual Studio Azure publish Wizard

Azure auto created App service while create web app chat, so select on Microsoft Azure App Service > select on Existing and click on publish


Login and Select Service:

Login with Microsoft Azure account and select the app existing app service from your resource group and click on Ok.


Bot Deploy confirmation:

Copy the Destination URL value to the clipboard (you'll need this value later to test the connection to the bot)


The following screen will display web publish activity status and as well as Site Url, once service published, it will redirect and open the browser.



Test Bot Application on Azure Portal

We have completed all the steps for publish the application using VS 2019, You can open your Azure portal and navigate to your web app Chat channel and Click on test in Web App Chat.


Summary

In this article, I hope you well understood about Deploy a bot application to Azure portal using Visual Studio 2019. If you have any questions/ feedback/ issues, please write in the comment box.








Introduction:

Language Understanding service (LUIS) allows our any application to understand what a person wants in their own words. LUIS can integrate to Windows, Web, Bot and mobile application, which can consume Json response to the application. LUIS uses machine learning to allow developers to build applications that can receive user input in natural language and extract meaning from the user input.

Building an app is a free and doesn't require an Azure subscription, in this article, I will show how to build a new app in the LUIS portal.



Once the LUIS app is published, a client application sends utterances (text) to the LUIS natural language processing endpoint API and receives the results as JSON responses. First you create the basic parts of an app, intents, and entities. Then you test the app by providing a sample user utterance in the interactive test panel to get the predicted intent.


Create LUIS App:

Step 1: 

Navigate to LUIS Portal in a browser and sign in. if you are trying to create first time signing in, you need to create free LUIS account.

Step 2: 

Click on “Create New App” from portal menu options.



Step 3: 

Provide name, culture and description in the following information into the new app screen.

Name - provide the relevant to your application and Unique LUIS app name

Culture – Luis will support multiple language, now we will select as English Language

Description - Provide the Description of app and its optional field



Once completed, Click on Done button and Select “Build” menu from main menu.


Create Intents:

Intent is an action the user wants to perform. Natural language is extremely flexible. in fact, different languages and cultures make them less or more flexible. But what is the user’s "intention?" It’s the goal the user is trying to achieve. Maybe they want to turn the lights on. Maybe they want to schedule a calendar appointment. Maybe they want to Send Email. Whatever the intent may be, the user can express themselves in a multitude of ways, but it always translates to one intent. LUIS understands utterances and converts them to one or more intents that you specify in our LUIS application. There are two type intent

New Intent – you can create custom intent-based user needs

Add prebuild domain Intent - you can use prebuilt intents from one of the prebuilt domains.

Select Intents > Click on New intent or Add prebuilt domain intent 


Prebuilt domain intents are parts of prebuilt domains, you can select inbuild category and intents from the list, here, we will select sending email and send email prebuilt domain intents 


Create Entities:

When the user issues a command as an utterance, that utterance is converted into an intent. But hidden inside that utterance is important data that’s needed to complete the action. For example, "turn the lights off" represents an action called "off;" what entity is it working on? It’s working on lights. You need to extract a single entity out of this utterance.

Select Entities > Add the Prebuild domain entity 


LUIS comes with a number of prebuilt domain models with prebuilt entities. Or you can quite easily create a new custom domain model with custom entities. Here we are creating Prebuilt domain entry 


In order to train the model, you’ll see a Train button on the top right-hand corner


Now you can start publish our LUIS application



While publish application, will be available multiple environment, let we start “Production” environment and publish


after publish its available in publicly the end point URL




Here you can view your publish settings, as well as your LUIS App ID and Password. You will need these to access your LUIS app from your client applications. Please note that you can also type in queries directly to your production endpoint, and you’ll get a JSON response from LUIS




When your model is trained and up-to-date, you can then open the test panel and provide some utterances to your LUIS model



You can copy paste the URL highlighted in key Endpoint setting screen and under the endpoint column (note that the app ID and keys are removed for this image) into an internet browser, and type the query – “Please email to Suthahar”. Below is the full JSON response for the query


Summary

In this article, you learned about how to create Natural Language Understanding app with LUIS .If you have any questions/ feedback/ issues, please write them in the comment box.
Artificial Intelligence continues to gain more traction, now that companies such as Google, Microsoft and others, have released a suite of easy to use tools. It now enables us to create smarter apps, and open up a new range of applications. Xamarin doesn’t have any AI or Machine Learning capabilities itself, but does play a part in gathering data and displaying information from AI systems.



Join With us in #Global Azure Bootcamp on April 27, 2019. It is a full day Free Event with new development technologies - Cloud infrastructure, DevOps, ChatBot, Mobile(Xamarin), AI/ML & IT pro at the location point on

''Tech Mahindra'' SDB3, Elcot SEZ, Sholinganallur. Chennai. Find in map




So, don't miss the opportunity to join in our massive set of event celebrations...If you have not yet registered, Register with us : https://lnkd.in/fXnc7d2


#AIForAll #Xamarin #microsoftai #chatbots #Devenvexe #Dotnet #azureai #GlobalAzure #microsoftevents #Azure #AI #Data #Xamarin #GlobalAzureChennai

Introduction:

Visual Studio 2019 publicly available from April 2 2019 and it’s includes many improvements for Xamarin mobile developers in Visual Studio. Microsoft mainly focused on key areas to make more productive when authoring Xamarin apps, including optimizations to build and deployment times as well as improvements to UI authoring experiences.

Let we look today steps by step all the awesome Visual Studio 2019 Xamarin Developer. Visual Studio 2019 and Visual Studio 2019 for Mac are now available so you can start download and start use with awesome VS feature .


Lower disk impact

VS2019 release focuses on the fundamental’s stability and performance. Visual Studio 2017 required minimum 23 GB or more, but visual studio 2019 is now 3.28x smaller in the size, it’s Just 5GB to 7GB and you can do faster installation with lower disk impact, no need to wait very long time for installation.


Solutions creation

Visual studio team improved solutions creation time by up to 2x and solutions load time by 23% on real world profiled solutions.

Android SDK Update:

Managing Android SDKs can be very difficult, especially when working on complex solutions across teams. Some of them not aware, difference between target, compile, and minimum framework version, Visual studio 2017 tried for Android SDK auto update but manually enable from Tool options .

Visual Studio 2019 will automatically analyze our app while project load, determine if you have the necessary Android SDK configuration to build, and offer to install those components for you to resolve any configuration conflicts.


Faster Build and Deployment:

Visual studio 2019 improved Xamarin Build and Deployment, you can check your enterprise application build times are 26.6% faster than Visual studio 2017version and Deployment times are now twice as fast.



Shell Project template

Visual studio 2019 added Shell project template to the Xamairn Form. Shell provides 3 tiers of elements to our application and then gets out of your way to start populating the app with content and features.In Shell template you will get it following 

A simplified way to express the high level of your application architecture in a single file (AppShell.xaml)

A hierarchy of common UI navigation patterns that suite your target mobile platforms: flyout menu, bottoms tabs, top tabs 

A robust navigation service that provides URI-based routing so you can jump directly to any part of your application with ease 

An extensible template-based infrastructure to easily customize elements of your UI



Visual design experiences for iOS and Android

Visual Studio 2019 improved new IntelliSense experience for XAML with matching around the control and property names to ensure you receive the correct suggestion.

The XAML Previewer shows you how your Xamarin.Forms XAML page will look on iOS and Android. When you make changes to your XAML, you'll see them previewed immediately alongside your code. The XAML Previewer is available in Visual Studio and Visual Studio for Mac.

You can now edit common attributes for your Xamarin.Forms controls in the property panel for Visual Studio 2019 on Windows. Open the property panel by going to View → Properties Window. The property panel will show attributes for whatever control is currently in focus in your XAML file.


Summary

In this article, your learned What is new in Xamarin Development in Visual Studio 2019. If you have any questions/ feedback/ issues, please write in the comment box.

Introduction:

Sentiment analysis seeks to understand a subject’s attitude or emotional reaction towards a specific topic or brand. Sentiment analysis does not have to be complicated and technical. It could be something as simple as getting a person in your team to find what is being said about your brand and product on review page and identify how much of it is good and how much of isn’t. There is no need for a big budget and developer into complicated software, the cognitive service text Analytics API is a cloud-based service that provides advanced natural language processing over raw text, and includes four main functions: sentiment analysis, key phrase extraction, language detection, and entity linking.



The most of the companies and brands now use sentiment analysis to find out what people are saying about them on social media. A bad review on social media can destroy a brand’s reputation if ignored or poorly handled. They aren’t simply rating their experience with 1 star or 5 stars. They’re also expressing their thoughts, feeling, expectations in free form text. This can be challenging to handle, especially if your company is getting a lot of feedback. When you have tens or even hundreds of thousands of feedbacks to read and manage, its easy to use cognitive text analytics service API.

The Sentiment Analysis API evaluates text input and returns a sentiment score for each document, ranging from 0 (negative) to 1 (positive). This capability is useful for detecting positive and negative sentiment in social media, customer reviews, and discussion forums. Content is provided by you, models and training data are provided by the service.

Currently, Sentiment Analysis supports English, German, Spanish, and French. Other languages are in preview. In this article, I will show how we can integrate sentiment API from Xamarin Mobile application using visual studio 2019


Text Analytics API Price:

The Text Analytics API can be purchased in units of the S0-S4 tier at a fixed price. Each unit of a tier comes with included quantities of API transactions. If the user exceeds the included quantities, overages are charged at the rate specified in the pricing table below. These overages are prorated and the service is billed on a monthly basis. The included quantities in a tier are reset each month. In the S tier, the service is billed for only the amount of Text Records submitted to the service. You can read more about pricing based on country check out here.


Create Text Analytics API Key:

You need to create an Azure account, generate API key and end point URL based region for implementation to the Xamarin Mobile application.

Step 1: 

Create Free Azure subscription and Login to portal

Step 2: 

Create On “+ Create a resource “> Under Azure Marketplace, select AI + Machine learning and discover the list of available featured. > Select “Text Analytics”


Step 3: 

 On the create page, provide the name, pricing, resource group and click on Create.

Step 4:

Wait for a few seconds. After the Cognitive Services account is successfully deployed, click the notification or tile in the dashboard to view the account information. You can copy the Endpoint URL and Key in the Overview section for API calls in our Xamarin applications.



Build Xamarin Forms Application using Visual Studio 2019:

Let's start with creating a new Xamarin Forms Project using Visual Studio 2019. When accessing Visual Studio 2019 for the first time, you will come across a new interface for opening a creating the projects.

Open Run >> Type “Devenev.Exe” and enter >> Create New Project (Ctrl+Shift+N) or select open recent application.



The available templates will appear on a window like below. Select Xamarin Forms application with different mobile platform.



Provide project name, Location and solution name in the following configure new project screen



Select as Blank apps and select the platform



The Solution will be created with all the platform and PCL projects.



PCL UI Design:

The UI will have a few elements on the screen and overlay content view window. Editor control for providing user input value and overlay window for show the result.

You can add Newtonsoft.JSON to solutions. Right click on Solutions > Manage NuGet Packages > select Newtonsoft.Json from Browse tab > click on Install.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MobileFeedback"
:Class="MobileFeedback.MainPage">
<ContentPage.Content>
<AbsoluteLayout>
<!-- Normal Page Content -->
<StackLayout AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All">
<Image Source="product.gif" VerticalOptions="Start" HorizontalOptions="Start" Margin="0,0,0,0" ></Image>
<Editor x:Name="txtfeedback" WidthRequest="100" HeightRequest="200"></Editor>
<Button Text="Submit" Clicked="Submit_Clicked"></Button>
</StackLayout>
<!-- Overlay -->
<ContentView x:Name="overlay"
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All"
IsVisible="False"
BackgroundColor="#C0808080"
Padding="10, 0">
<StackLayout Orientation="Vertical"
BackgroundColor="White"
HeightRequest="175"
WidthRequest="300"
HorizontalOptions="Center"
VerticalOptions="Start"
Margin="0,20,0,0" >
<Image x:Name="imgstatus" WidthRequest="70" HeightRequest="70"></Image>
<Label Text="" x:Name="lblStatus"></Label>
<StackLayout Orientation="Horizontal" HorizontalOptions="Center">
<Button Text="OK" FontSize="Small"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
Clicked="OnOKButtonClicked" />
</StackLayout>
</StackLayout>
</ContentView>
</AbsoluteLayout>
</ContentPage.Content>
</ContentPage>

Create Document Entity Class:

Create class for Document class, it will deserialize the response and return an object of type TextAnalyticsResponse.The response format defined by the API looks like below document entity
using System;
using System.Collections.Generic;
using System.Text;
namespace MobileFeedback
{
class Document
{
public string Id { get; set; }
public double? Score { get; set; }
}
class TextAnalyticsResponse
{
public List<Document> Documents { get; set; }
}
}

Create SentimentAnalysisHelper Helper Class:

You can replace Text Analytics API service endpoint and subscription key. If you don't already have these go back to the previous steps. Below is the complete class you need to add. we have to appended /sentiment to the end of the ApiUri in order to invoke the sentiment operation.



using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
namespace MobileFeedback
{
static class SentimentAnalysisHelper
{
private const string ApiUri = "<API url>”;
private const string SubscriptionKey = "<your Key>";
private const string Text = "The food was delicious and there were wonderful staff.";
private static readonly HttpClient Client = GetClient();
private static HttpClient GetClient()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", SubscriptionKey);
client.DefaultRequestHeaders.Add("ContentType", "application/json");
client.DefaultRequestHeaders.Add("Accept", "application/json");
return client;
}
private static TextAnalyticsResponse DeserializeTextAnalyticsResponse(string json)
{
return JsonConvert.DeserializeObject<TextAnalyticsResponse>(json);
}
public static TextAnalyticsResponse GetSentiment(string text)
{
var body = JsonConvert.SerializeObject(new
{
Documents = new object[]
{
new
{
Text = text,
Id = Guid.NewGuid()
}
}
});
using (var content = new ByteArrayContent(Encoding.UTF8.GetBytes(body)))
{
var responseMessage = Client.PostAsync(ApiUri, content).Result;
responseMessage.EnsureSuccessStatusCode();
var json = responseMessage.Content.ReadAsStringAsync().Result;
return DeserializeTextAnalyticsResponse(json);
}
}
}
}

You can add following to code behind in the design file. we'll add a method(GetSentiment) to call the Text Analytics API sentiment endpoint. It will deserialize the response and return an object of type TextAnalyticsResponse .The method will take a string text as input, create the request body, and then send it to the Text Analytics API using an HttpClient instance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using System.Net.Http;
using System.Threading;
namespace MobileFeedback
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void Submit_Clicked(object sender, EventArgs e)
{
TextAnalyticsResponse result = SentimentAnalysisHelper.GetSentiment(txtfeedback.Text);
double? score = result.Documents.FirstOrDefault().Score;
if(score < 0.5)
{
imgstatus.Source = "bad.png";
lblStatus.Text = "This is the first time we have heard of this problem. Thank you for pointing it out to us. I assure you we will do our best to prevent it from happening again, We will contact with you regardng the issue";
}
else if(score > 0.5 && score < 0.9)
{
imgstatus.Source = "okay.png";
lblStatus.Text = "We are always eager to get feedback from our customers. Thank you for taking the time to write to us.We will improve our service and our team will contact you";
}
else if(score> 0.9)
{
imgstatus.Source = "happy.png";
lblStatus.Text = "Your valuable feedback will assist us in our continuing effort to provide our users with the best possible support experience.";
}
overlay.IsVisible = true;
}
void OnOKButtonClicked(object sender, EventArgs args)
{
overlay.IsVisible = false;
}
void OnCancelButtonClicked(object sender, EventArgs args)
{
overlay.IsVisible = false;
}
}
}

We have completed the code for consuming TextAnalytics API. Now, we can select the platform and press F5. The output looks like below


Summary

In this article, you learned how to consuming TextAnalytics API and automate customer feedback without using rating. I hope this article will help you. Please leave your feedback/query using the comments box, if you like this article, please share it with your friends.

Featured Post

Improving C# Performance by Using AsSpan and Avoiding Substring

During development and everyday use, Substring is often the go-to choice for string manipulation. However, there are cases where Substring c...

MSDEVBUILD - English Channel

MSDEVBUILD - Tamil Channel

Popular Posts