The Bot Framework has supported the different type of rich cards and provides a richer interaction experience to the user. In this article, I will share about how to integrate adaptive card UI design in Bot Application. The Adaptive Card can contain any combination of text, speech, images, buttons, and input controls.Adaptive Cards are created using the JSON format specified in Adaptive Cards schema and Microsoft provided Microsoft.AdaptiveCards NuGet package for .Net Developer to building these cards and handles the serialization. 

Getting Started Adaptive Card Design Using Microsoft Bot Framework




Prerequisite: 

Let's create a new bot application using Visual Studio 2017. Open Visual Studio > Select File > Create New Project (Ctrl + Shift +N) > Select Bot application.
Getting Started Adaptive Card Design Using Microsoft Bot Framework

The Bot application template was created with all the components and all required NuGet references installed in the solutions.

Getting Started Adaptive Card Design Using Microsoft Bot Framework

Install AdaptiveCard Nuget package

 The Microsoft.AdaptiveCards library implements classes for building and serializing adaptive card objects and Visual studio intelligent will help us for implement Adaptive card in the bot application.

Right click on Solution > Select Manage NuGet Package for Solution > Search “ Microsoft AdaptiveCards” > select Project and Install the package

Getting Started Adaptive Card Design Using Microsoft Bot Framework

Create New AdaptiveCardDialog Class

Step 1: You can Create new AdaptiveCardDialog class for a show the Adaptive dialog. Right Click on project > Select Add New Item > Create a class that is marked with the [Serializable] attribute (so the dialog can be serialized to state) and implement the IDialog interface.

using System;
using System.Threading.Tasks;
using Microsoft.Bot.Builder.Dialogs;
using Microsoft.Bot.Connector;
using System.IO;
using System.Web;
using System.Collections.Generic;

namespace BotAdaptiveCard.Dialogs
{
[Serializable]

public class AdaptiveCardDialog: IDialog<object>
{


Step 2
 IDialog interface has only StartAsync() method. StartAsync() is called when the dialog becomes active. The method is passed the IDialogContext object, used to manage the conversation.
public async Task StartAsync(IDialogContext context)
{
context.Wait(this.MessageReceivedAsync);
}


Step 3: Create a MessageReceivedAsync method and write following code for the welcome message and show the list of demo options dialog. [Serializable]

public class AdaptiveCardDialog : IDialog<object>
{
public Task StartAsync(IDialogContext context)
{
context.Wait(this.MessageReceivedAsync);
return Task.CompletedTask;
}

private readonly IDictionary<string, string> options = new Dictionary<string, string>
{
{ "1", "1. Show Demo Adaptive Card " },
{ "2", "2. Show Demo for Adaptive Card Design with Column" },
{"3" ,
"3. Input Adaptive card Design" }
};

public async virtual Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
{
var message = await result;
var welcomeMessage = context.MakeMessage();
welcomeMessage.Text = "Welcome to bot Adaptive Card Demo";
await context.PostAsync(welcomeMessage);
this.DisplayOptionsAsync(context);
}


public void DisplayOptionsAsync(IDialogContext context)
{
PromptDialog.Choice<string>(
context,
this.SelectedOptionAsync,
this.options.Keys,
"What Demo / Sample option would you like to see?",
"Please select Valid option 1 to 6",
6,
PromptStyle.PerLine,
this.options.Values);
}

public async Task SelectedOptionAsync(IDialogContext context, IAwaitable<string> argument)
{
var message = await argument;
var replyMessage = context.MakeMessage();
Attachment attachment = null;
switch (message)
{
case "1":
attachment = CreateAdapativecard();
replyMessage.Attachments = new List<Attachment> { attachment };
break;
case "2":
attachment = CreateAdapativecardWithColumn();
replyMessage.Attachments = new List<Attachment> { attachment };
break;
case "3":
replyMessage.Attachments = new List<Attachment> { CreateAdapativecardWithColumn(), CreateAdaptiveCardwithEntry() };
break;
}

await context.PostAsync(replyMessage);
this.DisplayOptionsAsync(context);
}


After user enter the first message, bot will reply welcome message and list of demo option and wait for user input like below

Getting Started Adaptive Card Design Using Microsoft Bot Framework


Step 4: Design Adaptive Card 

The Adaptive Cards are created using JSON, but with the Microsoft.AdaptiveCards NuGet we can create them by composing card objects. We can create AdaptiveCard objects and attach to the attachment and post message to a message
Getting Started Adaptive Card Design Using Microsoft Bot Framework
The following code showing design the welcome message with image, textblock and speech.

public Attachment CreateAdapativecard()
{
AdaptiveCard card = new AdaptiveCard();
// Specify speech for the card.
card.Speak = "Suthahar J is a Technical Lead and C# Corner MVP. He has extensive 10+ years of experience working on different technologies, mostly in Microsoft space. His focus areas are Xamarin Cross Mobile Development ,UWP, SharePoint, Azure,Windows Mobile , Web , AI and Architecture. He writes about technology at his popular blog http://devenvexe.com";
// Body content
card.Body.Add(new Image()
{
Url = "https://i1.social.s-msft.com/profile/u/avatar.jpg?displayname=j%20suthahar&size=extralarge&version=88034ca2-9db8-46cd-b767-95d17658931a",
Size = ImageSize.Small,
Style = ImageStyle.Person,
AltText = "Suthahar Profile"
});

// Add text to the card.
card.Body.Add(new TextBlock()
{
Text = "Technical Lead and C# Corner MVP",
Size = TextSize.Large,
Weight = TextWeight.Bolder
});

// Add text to the card.
card.Body.Add(new TextBlock()
{
Text = "jssutahhar@gmail.com"
});

// Add text to the card.
card.Body.Add(new TextBlock()
{
Text = "97XXXXXX12"
});

// Create the attachment with adapative card.
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
return attachment;
}


The above code will generate adaptive card and reply to the user

Getting Started Adaptive Card Design Using Microsoft Bot Framework

Step 5: Design Adaptive Card with Column 

The Adaptive Cards contain many elements that allow to design UI content in a common and consistent way.
Container - A Container is a CardElement which contains a list of CardElements that are logically grouped.

ColumnSet and Column - The columnSet element adds the ability to have a set of Column objects and align the column object.

FactSet - The FactSet element is displayed row and column like a tabular form.

TextBlock - The TextBlock element allows for the inclusion of text, we can modify font sizes, weight and color.

ImageSet and Image - The ImageSet allows for the inclusion of a collection images like a photo set, and the Image element allows for the inclusion of images.

Getting Started Adaptive Card Design Using Microsoft Bot Framework

The following code showing, adding multiple columns and design the UI Adaptive Card

public Attachment CreateAdapativecardWithColumn()
{
AdaptiveCard card = new AdaptiveCard()
{
Body = new List<CardElement>()
{
// Container
new Container()
{
Speak = "<s>Hello!</s><s>Suthahar J is a Technical Lead and C# Corner MVP. He has extensive 10+ years of experience working on different technologies, mostly in Microsoft space. His focus areas are Xamarin Cross Mobile Development ,UWP, SharePoint, Azure,Windows Mobile , Web , AI and Architecture. He writes about technology at his popular blog http://devenvexe.com</s>",

Items = new List<CardElement>()
{
// first column
new ColumnSet()
{
Columns = new List<Column>()
{
new Column()
{
Size = ColumnSize.Auto,
Items = new List<CardElement>()
{
new Image()
{
Url = "https://i1.social.s-msft.com/profile/u/avatar.jpg?displayname=j%20suthahar&size=extralarge&version=88034ca2-9db8-46cd-b767-95d17658931a",
Size = ImageSize.Small,
Style = ImageStyle.Person
}
}
},
new Column()
{
Size = "300",
Items = new List<CardElement>()
{
new TextBlock()
{
Text = "Suthahar Jegatheesan MCA",
Weight = TextWeight.Bolder,
IsSubtle = true
},
new TextBlock()
{
Text = "jssuthahar@gmail.com",
Weight = TextWeight.Lighter,
IsSubtle = true
},
new TextBlock()
{
Text = "97420XXXX2",
Weight = TextWeight.Lighter,
IsSubtle = true
},
new TextBlock()
{
Text = "http://www.devenvexe.com",
Weight = TextWeight.Lighter,
IsSubtle = true
}
}
}
}
},
// second column
new ColumnSet()
{
Columns = new List<Column>()
{
new Column()
{
Size = ColumnSize.Auto,
Separation =SeparationStyle.Strong,
Items = new List<CardElement>()
{
new TextBlock()
{
Text = "Suthahar J is a Technical Lead and C# Corner MVP. He has extensive 10+ years of experience working on different technologies, mostly in Microsoft space. His focus areas are Xamarin Cross Mobile Development ,UWP, SharePoint, Azure,Windows Mobile , Web , AI and Architecture. He writes about technology at his popular blog http://devenvexe.com",
Wrap = true
}
}
}
}
}
}
}
},
};
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
return attachment;
}
The above code will generate following card design and reply the message


Step 6: Adaptive Card Design with Input Control:

The Adaptive Cards can include input controls for collecting information from the user, it will support following input control is : Text, Date, Time, Number and for selecting options(choiceset) and toggle .

The following sample code included collecting basic information from the users with action button
Input.Text – Collect the text content from the user

Input.Date - Collect a Date from the user

Input.Time - Collect a Time from the user

Input.Number - Collect a Number from the user

Input.ChoiceSet - provide the user a set of choices and have them pick

Input.ToggleChoice - provide the user a single choice between two items and have them pick

public Attachment CreateAdaptiveCardwithEntry()
{
var card = new AdaptiveCard()
{
Body = new List<CardElement>()
{

// Hotels Search form
new TextBlock() { Text = "Please Share your detail for contact:" },
new TextInput()
{
Id = "Your Name",
Speak = "<s>Please Enter Your Name</s>",
Placeholder = "Please Enter Your Name",
Style = TextInputStyle.Text
},
new TextBlock() { Text = "When your Free" },
new DateInput()
{
Id = "Free",
Placeholder ="Your free Date"
},
new TextBlock() { Text = "Your Experence" },
new NumberInput()
{
Id = "No of Year experence",
Min = 1,
Max = 20,
},
new TextBlock() { Text = "Email" },
new TextInput()
{
Id = "Email",
Speak = "<s>Please Enter Your email</s>",
Placeholder = "Please Enter Your email",
Style = TextInputStyle.Text
},
new TextBlock() { Text = "Phone" },
new TextInput()
{
Id = "Phone",
Speak = "<s>Please Enter Your phone</s>",
Placeholder = "Please Enter Your Phone",
Style = TextInputStyle.Text
},
},
Actions = new List<ActionBase>()
{
new SubmitAction()
{
Title = "Contact",
Speak = "<s>Contact</s>",
}
}
};
Attachment attachment = new Attachment()
{
ContentType = AdaptiveCard.ContentType,
Content = card
};
return attachment;
}
The above code will return following adaptive card design


Run Bot Application

The emulator is a desktop application that lets us test and debug our bot on localhost. Now, you can click on "Run the application" in Visual studio and execute in the browser

  • Test Application on Bot Emulator
  • You can follow the below steps to test your bot application.
  • Open Bot Emulator.
  • Copy the above localhost url and paste it in emulator e.g. - http://localHost:3979
  • You can append the /api/messages in the above url; e.g. - http://localHost:3979/api/messages.
  • You won't need to specify Microsoft App ID and Microsoft App Password for localhost testing, so click on "Connect".

Summary

In this article, you learned how to create a Bot application using Visual Studio 2017 and create adaptive design and input from using bot framework. If you have any questions/feedback/ issues, please write in the comment box.
On 2011 at Xamarin announced great and happy news to all c#.net developer, can develop ios application using xamarin . 

On 2016 Microsoft announced that they had acquired Xamarin and all the visual studio developer can develop ios and android application, without pay any extra payment. 

iOS developer they can do for testing in simulator if they want to test in the device, need to buy Apple Developer account, its cost 99$ /year. 

On June 8 2015 at the Apple Worldwide Developers Conference Xcode version 7 was announced and good news is that you can develop and test your apps on your iOS device without a paid Apple Developer account. 

This is great news for all the iOS developer, before upload store we can do testing ios application from device without a paid any payment. 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account

In this article, I am going to share about how to deploy xamarin.ioS application to iOS device using free provisioning file 

Requirements:

  1. XCode 7 or higher 
  2. Go to Mac machine and verify Xcode version is 7 or higher, if it’s not update xcode
  3. iOS 9 or higher 
  4. Create free Apple ID from here( https://appleid.apple.com/account#!&page=create)

You can follow bellows steps for how to setup and deploy xamarin.iOS application into iOS device. 

Step 1: Add Apple Account from Xcode
In mac Machine, Open Xcode , Xcode Menu >Preferences > Click on Account tab > Select + Add Apple ID > login with Apple ID 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account

Click on View Details and create signing identity and click on create button next to iOS development 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account

Step 2: Create XCode project: 

Xcode > create new project > project name as “testapp” > Connect iphone /IPad from mac machine > Select your device and press run button
You will get Code Singing issue 

Issue 1: Xcode 7: Project requires a development team

If your using XCode 7 means, you will get following error 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account
Select your Team as below from Project Options and General tab 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account
Issue 2: Xcode8: Code signing Error in Build Error:
If you are using Xcode 8 or above, the code signing error will appear while build xcode project 


Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account


Solution:

Step 2.1: Go to the ioS project editor
Step 2.2: Select the General Section
Step 2.3: Select Checkbox for Automatically manage signing
Step 2.4: Select the Personal Team you created earlier from the ‘Team’ dropdown in the ‘Signing’ section 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account

Step 3: Trusting the certificate from device
You will get following error could not launch “Your app name “ 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account 

In your iOS device > open the Settings > go to general > Device management (if you’re not getting this option re deploy the application again)
You will see the email address associated with the Apple ID you used to code sign your app. 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account

Tap it, then tap ‘Trust <your_email>’ 

Now go back to xcode and run the application 

Step 4: Update bundle Identifier from Xamarin Project:


In Xamarin.iOS project , Goto Info.Plist file > Change Bundle Identifier (use same xcode project bundle identifier) 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account

And make sure from project options and select IOS bundle signing > Signing identity select your apple account 


Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account


Select your iphone device from xamarin.ios project and click on run the application. 

Deploy Xamarin.iOS App to iOS Device without an Apple Developer Account


I believe this article will helpful for you deploy application to ios device ,if you have question /issue/feedback share into comments box .
.Net Class and API or some features that behave differently on each platform so we need to write some code on platform specific. Below two library for sharing code between multiple platform
  • Shared asset project ( SAP)
  • Portable Class library (PCL)
Share Project (SAP)

You can share code across multiple platform projects. Your Code is compiled as part of each referencing project and can include compiler directives to help incorporate platform-specific functionality into the shared code base.

Xamarin project template have standard for defining Build Symbol with double underscore pre and post – fix

 
 Build Symbol
  Description
__MOBILE__
Support iOS and Android specific code
__IOS__
iOS specific  code
__TVOS__
TV Specific Code
__WATCHOS__
Watch Specific code
__ANDROID__
Android Specific Code
__MAC__
Mac Specify Code
_WINDOWS_PHONE and SILVERLIGHT
Windows Phone Specific code

Visual Studio:

The compiler directives on your platform specific project. Right Click on your Platform Specific Project ➔ Click on property ➔ Select Build Option

Change the Configuration drop downs at the top of the Options to see the symbols for each different build configuration


Xamarin Studio:

Right-click Project > Options > Build > Compiler > Define Symbols.

Change the Configuration drop downs at the top of the Options to see the symbols for each different build configuration



Define symbol like below in shared project and Add reference into all the platform project and assign value into textbox control or others control

using System;

namespace DevXamarinForm.Shared
{
public class Common
{
public Common()
{
}
public string PrintText()
{
string printtext ="No Device Specfic";
#if __MOBILE__
printtext= "iOS or Android specific code";
#endif
#if __IOS__
printtext= "iOS specific code";
#endif
#if __TVOS__
printtext= tv specific stuff";
#endif
#if __ANDROID__
printtext="Android specific code";
#endif
#if _WINDOWS_PHONE
printtext="Android-specific code";
#endif
return printtext;
}
}
}

Portable Class library: [compiler directives do not work in PCLs]

Portable class libraries are platform independent. PCL do not allow to use conditional compilation .This is because PCL should work on all specified platforms which was chosen as a target and Also, availability of features depends on selected targets.

We can use same above way but that is not recommended way. Let we see how we will do same above

Step 1:

Create Class file like above under PCL project

Step 2:

Right Click Specific Platform project ➔ Add ➔ Existing Item ➔Select PCL project ➔ Select Common Class file ➔ select “Add as Link”



It will work same like Shared Project.

Recommended approach to writing platform conditional code in a PCL:

The Device class contains a number of properties and methods to help developers customize layout and functionality on a per-platform basis.

using System;
using Xamarin.Forms;

namespace DevXamarinForm
{
public class Common
{
public Common()
{
}
public string PrintText()
{
string printtext = "No device Specfic Device";
if (Device.OS == TargetPlatform.iOS)
{
printtext = "iOS specific code";
}
else if (Device.OS == TargetPlatform.Android)
{
printtext = "Android specific code";
}
else if (Device.OS == TargetPlatform.Windows)
{
printtext = "Windows specific code";
}
else if (Device.OS == TargetPlatform.WinPhone)
{
printtext = "Winphone specific code";
}
else if (Device.OS == TargetPlatform.Other)
{
printtext = "Other specific code";
}
return printtext;
}
}
}

Output:

Mobile Application planning, development, testing and deployment go well as per the customer estimation but after a while the client was clamoring that the app is getting slower and slower when it was continuously being used up to the point where it will just crash suddenly but most of the developer unaware why it’s like this. In this article, you are going to learn how to use prevent memory leak and profiler in Xamairn Application.


Garbage Collection:

We all know that in the .NET world we have a very good friend called Garbage Collector. Basically, it is responsible on freeing up the used memory. As simple as it sounds, whether you are in a Desktop, Web or especially mobile where there are two worlds one is Managed and the other one is the native part which at times Garbage Collection is not enough to reclaim those used memories the cause of the slowdown Mobile app is due to Memory Leaks.


Beware of common memory leak sources:

You do incorrect memory management wherein an object is stored in memory but cannot be accessed by the running code, it’s always causing a memory leak in mobile application. We all Knows what we can’t do but still we are doing as like below image, Same in Mobile Development also we all knows what can’t do, but still we are doing same mistake.




I suggest to be extra careful when using below C# feature, and proactively check for memory leaks with techniques like the last best practice.

Events, delegates or Messaging Centers in .NET are notorious for causing memory leaks. You can innocently subscribe to an event, causing a damaging memory leak without even suspecting.

Custom control and Unknown Nuget package are event registered, such as Loaded, will not be unloaded until all events are unregistered. Always remember to unregister your events when you don't need them anymore and we are not sure all the objects or disposed.

Images is a classical .net GC-Java GC problem when GC isn't aware of image size and won't release reference unless it is Disposed.

Static variables, collections, and static events in-particular should always look suspicious. Remember that all static variables are GC Roots, so they are never collected by the GC.

Caching functionality in mobile apps is necessary, any type of caching mechanism can easily cause memory leaks. By storing cache information in-memory, eventually, it will fill up and cause an OutOfMemory exception.

Bindings can be dangerous. The rule of thumb is to always bind to a DependencyObject or to a INotifyPropertyChanged object. When you fail to do so, Xamarin will create a strong reference to your binding source (meaning the ViewModel) from a static variable, causing a memory leak

Threads that never terminate – The Live Stack of each of your threads is considered a GC Root. This means that until a thread terminates, any references from its variables on the Stack will not be collected by the GC. This includes Timers as well. If your Timer’s Tick Handler is a method, then the method’s object is considered referenced and will not be collected.
Preventing Memory Leaks:

Enterprise Mobile application knows memory leaks are like overloaded people in a Bus or train. You might not notice when there are few of them, but you always make sure people enter in the bus with very limited and identify bus capacity based on that you need to allow the people into the bus. In Mobile application you should define to developer with strike rule and TODO List and make sure your code review taken care following option for prevent memory leaks

Using Statement:

Xamairn Mobile application constantly uses unmanaged resources. The .NET framework itself relies heavily on unmanaged code for internal operations, optimization. Anytime you use Streams, Graphics, or Files for example, you are probably executing unmanaged code. The using statement transforms the code into a try / finally statement behind the scenes, where the Dispose method is called in the finally clause.

Dispose pattern:

You implement a Dispose method to release unmanaged resources used by your application. The .NET garbage collector does not allocate or release unmanaged memory. The Dispose method performs all object cleanup, so the garbage collector no longer needs to call the objects' Object.Finalize override. Learn more MSDN portal .

public void CreateFile()
{
using (var stream = new FileStream(@"\Document\SomeFile.txt",
FileMode.OpenOrCreate))
{
// do stuff
}// stream.Dispose() will be called even if an exception occurs


Test for memory leaks:

It’s a great practice to proactively test for memory leaks. And it’s not that hard. Here’s a short pattern you can use in the unit testing project.
[Test]
void MemoryLeakTest()
{
var weakRef = new WeakReference(leakyObject)
// Ryn an operation with leakyObject
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
Assert.IsFalse(weakRef.IsAlive);
}


Getting Started Profiling:


Xamarin Profiler is a great tool created by Microsoft wherein it gives developers ways to profile or collect telemetry with your Mobile Applications using Visual Studio. It can also be paired with native profilers, like Xcode Instruments and Android Profiler, to ensure better app behavior and performance. The main function of the profiler is to collect and displays information about the Mobile App wherein the Developer can pinpoint, analyze and optimize areas in their application for a smooth experience by end users. There are different ways the Xamarin Profiler can help us like statistical.




The Xamarin Profiler has many features Allocation, Cycles, Data presented on each screen and Time profiler. It’s a graphical interface for the Mono log profiler, and supports profiling for following platform in Windows and mac machine.

  • Android, iOS, tvOS, and Mac applications on Mac
  • Android, iOS, and tvOS applications on Windows.

In this section, will learn common profiling scenarios and analyze and optimize iOS and Android applications.

Prerequisites:

We need Visual Studio Enterprise subscriber to unlock Profiler feature in either Visual Studio Enterprise on Windows or Visual Studio for Mac on a Mac. Download install following package in your mac or windows machine.





After successful installation, let get satrt use Profiling in Xamarin iOS and android application. Integrate Profiling is very simple steps, you need changes Project Property options in iOS and Android Project.

Create new Xamairn Forms project using Visual Studio and Select iOS and Android platform is supported and follow below two steps for enabling the profiling in iOS and Android Project.
Android:

In Android Project, Right click on project > Select property > Select “Android Options” > Select options “Enable developer instrumentation”.


iOS

In iOS Project, Right click on Project > Select Property > Select “iOS Debug” Options and check the check box “Enable Profiling”.


Start the Xamarin Profiler:

Step 1: Build and run the application in iOS or Android.

Step 2: In Visual Studio menu, Select Analyze or Tools main menu > Select Xamarin Profiler and open the Profiler and make sure before open profiler, the application needs to be built at least once in order to start a profiling session.





The Xamarin Profiler comes with following instruments:
  • All Instruments
  • Allocations.
  • Time Profiler.
Once you have selected a Allocations options and you can also configure some options of how the memory profiling will proceed. You can either customize the frames, frequency or either select from the presets as shown below image.


Once you have clicked the Start Profiling button it will automatically launch your selected application on the selected device and you will be greeted with this window


In that above image denoted number with green marked and detail info below

No 1 - Represents the actual graph of the Memory consumption with respect to time.


No 2 - Represents the different data categorized on your selected tab.


No 3 -Represents the information (Object name, count, size) displayed based on the selected tab.


No 4 - Represent the real time display of information based on the current snapshot.


No 5 - Represents the Selected device and the Application that is currently running.

Snapshots

Snapshots pane displays information about memory snapshots. To generate these while profiling a live application, click the Camera button in the toolbar at each point that you'd like to see what memory is retained and released. You can then click each snapshot to explore what is happening under the hood. Note that snapshots can only be taken when live profiling an app.



Time Profiler

The Time Profiler instrument measures exactly how much time is spent in each method of an application. The application is paused at regular intervals and a stack trace is run on each active thread. And Call Tree options will show amount of time spent in each method.


I hope you enjoyed for learning profiling and prevent memory leak issue. Let me state that Profilers are not only for memory leaks but also can be used in code optimization. Finally moving forward maybe you can also adapt or put in your development routine the profiling of your mobile applications.

Summary

I hope this article gave you some value to you, let we take a new year’s resolution is better memory management while doing C# programing. Please leave your feedback/query using the comments box, and if you like this article, please share it with your friends

Introduction :

Bot Framework enables you to build bots that support different types of interactions with users. You can design conversations in your bot to be free. Your bot can also have more guided interactions where it provides the users with 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.

We are going to create and build Xamarin FAQ Bot using Azure Bot Service and deploy into Webchat .in this article, we are not going to write any coding for implement Xamarin FAQ Bot but be ready with what are the question and answer to train the Bot. I have already created 7000+ more Xamarin Q A as word document, we will use same document for upload and train knowledge base.


Create a QnA Service:

Step 1: 

Navigate to https://qnamaker.ai/ and Sign in using Microsoft Account.

Step 2: 

Click on “Create a knowledge base” from main menu

Step 3:

You can skip “Create a QnA service” step, let we publish QnA service after create knowledge base.


Step 4: 

Provide QnA Knowledge base basic information




Step 5:

 You can extract question and answer pairs from an online FAQ, manuals Entry and upload files with .tsv,.pdf,.doc,.docx,.xls format. If you are trying to enter manual entry skip this step.
Add chit-chat to your bot, to make your bot more conversational and engaging, with low effort. You can easily add chit-chat data sets for 3 pre-defined personalities when creating your KB, and change them at any timer. Chit-chat is supported for 3 predefined personalities

  • The Professional
  • The Friend
  • The Comic

Step 5:

 Click on “Create your KB”


Step 6: 

Wait for a few seconds for load all the knowledge base Q & A to the Online Editor.

Step 7: 

QnA service has loaded our FAQs Editor with two-column knowledge base, without any extra tweaking needed from you. Now you can edit and modify old Q&A and also Select Add new QnA pair to input other greetings and responses.




Step 8: 

The main menu having different option, Edit, Publish, Save, train, test and Settings. While click on Edit the above knowledge base edit screen will open, you can search and filter the question and Edit. After Edit always click on “Save and train” menu option for Save.


Step 9: 

Click on “Publish”. once you publish the knowledge base endpoint available for use in your bot or App

Step 10: 


The Knowledge base will generate following, you can make note. Need to update below details in Azure Hosting.
  • Knowledge base Key
  • Host Address
  • EndPointKey

Create and Publish QnA Bot in Azure:

Step 1: 

Navigate and Login to https://portal.azure.com/.

Step 2: 

Select + Create a resource > Select “AI Machine Learning” > Click on “Web App Bot”





Step 3: 

Let us start create Web App Bot, Provide the Bot Name, resource, location and also follow the step 4, Step 5 for select Bot template and prizing and click on Create.

Step 4: 

You can use the v3 templates, select SDK version of SDK v3 and SDK language of C# or Node.js. Select the Question and Answer template for the Bot template field, then save the template settings by selecting Select.



Step 5: 

You can choose a pricing tier for Bot Search service

 

Step 6: 

Review your settings, then select Create. This creates and deploys the bot service with XamarinQA to Azure .


Step 7: 

Open Xamarin BotQA App Service from All Resource > Application Settings and edit the QnAKnowledgebaseId, QnAAuthKey, and the QnAEndpointHostName fields to contain the values of your QnA Maker knowledge base. Like below


Test and Implement Web Chat App:

In the Azure portal, click on Test in Web Chat to test the bot and Click on Channel > Deploy bot Application to Web Chat and Implement into your Website or Application. 



Summary

In this article, you learned Create, train, and publish your QnA Maker knowledge base. I have created 7000+ Xamarin Q A knowledge base and deployed into my blog (www.devenvexe.com) and Xamarin Q A Facebook Page, you can try out for demo and If you have any questions/feedback/ issues, please write in the comment box.



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