Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, June 10, 2017

Getting Started with Building Bots using Visual Studio 2017

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, we can create a bot by using the Visual studio 2017 with Bot template and testing it with the Bot Emulator.
Install Visual Studio 2017:
Download Visual Studio 2017 from the following URL given below.  
  • Download Visual Studio 2017 from https://www.visualstudio.com/downloads/.
  • Refer Visual Studio 2017 system requirement from https://www.visualstudio.com/en-us/productinfo/vs2017-system-requirements-vs.
  • You can build bots for free with Visual Studio 2017 Community.
  • The Bot Builder SDK for .NET currently supports Only on Windows. Visual Studio for Mac is not supported.
Bot Application template:
Download the Bot Application template from the following url http://aka.ms/bf-bc-vstemplate and install the template by saving the .zip file to your Visual Studio 2017 project templates directory.
The Visual Studio 2017 project templates directory is typically located following url
%USERPROFILE%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#\

Create New Project:
Let's start with creating a new Bot application in Visual Studio 2017.
Click on Windows Key > Select Visual Studio 2017.

Now, open VS and create new project with c# project, select the Bot applications template as per below
The Bot application was created with all of the components and installed all required Nuget reference
Update Bot Builder Nuget Package:
Verify your application Microsoft.Bot.Builder nuget package was installed under reference .if not , refer follow below steps
  • Right-click on the Bot project(DevEnvExeBot) and select Manage NuGet Packages.
  • In the Browse tab, type "Microsoft.Bot.Builder" and click on Search
  • Locate the Microsoft.Bot.Builder package in the list of search results, and click the Update button for that package or Uninstall and Install the package .
Update Code:
The Default application added simple conde snipper, no need to change anything. if you want to test your custom message, you can change like below.
You can find messagereceiveAsync method from Dialogs / RootDialog.cs file.
In this method activity.Text will return user text input so you can reply message based input text .
  1. private async Task MessageReceivedAsync(IDialogContext context, IAwaitable result)
  2.        {
  3.            var activity = await result as Activity;

  4.            // calculate something for us to return
  5.            int length = (activity.Text ?? string.Empty).Length;

  6.            // return our reply to the user
  8.            //test
  9.            if (activity.Text.Contains("technology"))
  10.            {
  11.                await context.PostAsync("Refer C# corner website for tecnology http://www.c-sharpcorner.com/");
  12.            }
  13.            else if (activity.Text.Contains("morning"))
  14.            {
  15.                await context.PostAsync("Hello !! Good Morning , Have a nice Day");
  16.            }
  17.            //test
  18.            else if (activity.Text.Contains("night"))
  19.            {
  20.                await context.PostAsync(" Good night and Sweetest Dreams with Bot Application ");
  21.            }
  22.            else if (activity.Text.Contains("date"))
  23.            {
  24.                await context.PostAsync(DateTime.Now.ToString());
  25.            }
  26.            else
  27.            {
  28.                await context.PostAsync($"You sent {activity.Text} which was {length} characters");
  29.            }

  30.            context.Wait(MessageReceivedAsync);
  31.        }
Install bot Emulator:
You will need to download and install the emulator for testing bot application .You can download bot emulator from https://docs.microsoft.com/en-us/bot-framework/debug-bots-emulator .

Run Bot Application:
The emulator is a desktop application that lets you test and debug your bot on localhost or remotely. Now, you can click on run the application in any browser
Test Application on Bot Emulator:
You can follow below steps for test bot application
  1. Open Bot Emulator
  2. Copy above localhost url and past it from emulator eg: http://localHost:3979
  3. You can append the /api/message from above localhost url eg: http://localHost:3979/api/messages.
  4. You won't need to specify Microsoft App ID and Microsoft App Password for localhost testing so click on Connect

You can download the complete source code from MSDN sample. 
This article your learned about how to create Bot application using visual studio 2017.

If you have any questions/ feedback/ issues, please write in the comment box.

Monday, February 27, 2017

Generate Bing map authentication Key for Windows based application

Windows allow us to integrate Bing maps in our application so we need to generate an application key using Bing developer account. This article shows you how to generate Bing map application key from Bing developer account.
Generate Key from Bing Map Portal:
I have shown below steps for register Application key for windows based application using Bing maps developer portal.
Step 1: Navigate to Bing map Developer portal https://www.bingmapsportal.com/ and login using your Microsoft account
Step 2: Create new Bing map account :
Provide the following basic profile information and accept Bing map terms and condition and click Create. If you already registered user, no need to do this step
Step 3: Generate Application Key:
In Bing map Portal, Click on My Account and select My keys
And click on create new application key and provide application name, key type(Basic/Enterprise), application type and click on create or You can chose already created Bing map application key
Step 4: Completed
After successfully created application key, the new key appears below the My keys form. Copy it to a safe place or immediately add it to your app.
I will share bing map implementation in my next article. If you have any question or feedback, please share in the comment box.

Sunday, December 18, 2016

Visual Studio Shortcuts for Different platform

Playing with keyboard shortcuts is very interesting and reduce the head-ache of using mouse again and again while programming with visual studio IDE. Actually, keyboard shortcuts also enhance your productivity and make your programming life easy and convenient. So, Here i am share a list of visual studio keyboard with different platform
Visual Studio For Windows :
Here you can find about Visual studio shortcuts for windows

Reference from : https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
VisualStudio For Mac :
Here you can find about Visualstudio shortcuts for Mac

Reference from : https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
VisualStudio For Linux :

Here you can find about Visualstudio shortcuts for Linux

Reference from : https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf

Saturday, November 12, 2016

MSDN Subscription is Now Visual Studio Subscription

Microsoft changed from MSDN Subscription to Visual Studio Subscription and also changed Url into https://my.visualstudio.com/
Today I have logged into MSDN but its showed like below

New Look MSDN

Friday, August 26, 2016

Difference between Singleton and Static Class

 Static Class
Single means single object across the application
life cycle so it application level
The static does not have any Object pointer, so the scope is at App Domain level.
Singleton is a pattern and not a keyword
Static is key word
A Singleton can implement interfaces and inherit from other classes and allow inheritance.
Static class allows only static methods 
and you cannot pass static class as parameter.
Static class cannot inherit their instance members
Singleton Objects stored on heap memory
Static class stored in stack memory
Singleton Objects can have constructor
Static class will have only static constructor ,so overloading it won’t
Singleton Objects can dispose
We can’t dispose in static class
Singleton Objects can clone
We can’t clone in static class

Saturday, August 20, 2016

Register Identity Provider for new OAuth Application

OAuth is a web authentication protocol and open standard for authorization, Nowadays Internet users to log in to third party websites using following account without exposing user registration.
  1. Google
  2. Facebook
  3. Twitter
  4. Microsoft
  5. LinkedIn
  6. Githup
  7. Flicker
  8. Yahoo
  9. DropBox
You can find below wiki for some more list of notable identity provider
How Oauth will Work:
Third party app /website can access your data stored in another website without registries.
The OAuth flow has three steps
  • Get a Request Token
  • Get the User's Authorization
  • Exchange the Request Token for an Access Token  
Register New OAuth Applications:
Before you can integrate Identity provider sign-in into your apps, you must register your application and get the corresponding client ID and client secret from below steps, which we need to call the Sign-in API
Configure Google OAuth:
Register New OAuth application follow below steps
  1. Navigate to https://console.developers.google.com and login with your google Account credentials when prompted.
  2. Select Credentials tab and Click on Create Project.
  3. Add your App/website name  and click on Create
  1. In the Credentials API Popup, select the create credentials drop-down list, and choose OAuth client ID.

  1. Select Application Type As Web Application or iOS, android and click on configure button  

  1. Fill personal details, privacy details and click on save
  2. Get the package name from your AndroidManifest.xml file then use the following command to get the fingerprint and Click on Create
8. From the resulting OAuth client dialog box, copy the Client ID. The Client ID lets your app access enabled Google APIs.

Configure Facebook OAuth:
               Register New OAuth application follow below steps
  1. Navigate to https://developers.facebook.com and login with your facebook Account credentials when prompted.
  2. Click on “ My Apps” Dropdown  and select “Add a New App”.

  1. Select a App Platform ( iOS,Android,Facebook Canvas,WebSite,etc)
  2. Give Unique App/Website Name
  1. Fill email, select app category and click on “Create APP ID”.
  2. Complete security check and click on Submit
  3. Get the package name from your AndroidManifest.xml file then add package name and class name
  1. Generate development key hash and press on Finish
  2. From the resulting OAuth client dialog box, copy the Client ID. The Client ID lets your app access enabled Facebook APIs.

Configure Twitter OAuth:
Register New OAuth application follow below steps
  1. Navigate to https://dev.twitter.com/apps/new and login with your Twitter Account credentials when prompted.
  2. Enter your Application Name, Description ,your website address and callback URL.
  1. Accept the Developer agrement and clicking the Create your Twitter Application.
  2. Copy the consumer key (API key) and consumer secret from the screenand use into your application
Configure Microsoft OAuth:
  1. Go to https://apps.dev.microsoft.com/, and login with your Microsoft Account (Hotmail, Windows Live, Messenger, Active Directory, Xbox, Skype, and OneDrive) credentials when prompted.
  2. Select My Application and click Add an App
  3. Enter the Application name and click on Create application

  1. Generate application ID and secrets and use into the application

Configure LinkedIn OAuth:
             Register New OAuth application follow below steps
  1. Navigate to http://developer.linkedin.com/ and login with your LinkedIn Account credentials when prompted
  2. Select platform (RESTAPI,Javascript ,Android SDK,iOS SDK)
  3. Click the "Add New Application" link and fill in the required fields(Company Name,Application Name,Description,Application URL,logo,Business website,email and phone) and agree Licience condition
4. Click on Submit. To retrieve your API Key and Secret Key later, click on the link for your Application Name and they will now be listed in the application's details.

Configure Githup OAuth:
             Register New OAuth application follow below steps
  1. Navigate to https://github.com/settings/developers  and login with your Github Account credentials when prompted.
  2. Click the "Register New App" link and fill in the required fields(Application Name,Description, URL and callback url) and click on”Regsiter Application
  1. Copy the Client ID and Client Secret from the screen and use into your application

Configure Dropbox OAuth
  1. Navigate to https://www.dropbox.com/developers and login with your DropBox Account credentials when prompted.
  2. Choose an API Type and Access type
  3. Enter the Application name and click on Create App
  1. Copy the App Key and App Secret from the screen and use into your application

Configure Flicker OAuth:
  1. Navigate to https://developer.yahoo.com/flickr/  and login with your Yahoo Account credentials when prompted.
  2. For getting API Key ,Clcik on “ Create an APP”.
  1. Choose if Non-Commercial or Commercial.
  2. Enter the Application name, description and click on submit

  1. Copy the App Key and App Secret from the screen and use into your application

Configure Yahoo OAuth:
             Register New OAuth application follow below steps
  1. Navigate to https://developer.yahoo.com/apps/  and login with your Yahoo Account credentials when prompted.
  2. Enter the Application name, application type and access  and click on Create App

  1. Copy the Client ID and Client Secret from the screen and use into your application

I will explain about implementation on Next article