microsoft bot framework introduction

46
HOW CHATBOTS CAN FEED YOU! Introduction to Microsoft Bot Framework & LUIS.ai

Upload: kevin-leung

Post on 13-Apr-2017

39 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Microsoft Bot Framework Introduction

HOW CHATBOTS CAN FEED YOU!

Introduction to Microsoft Bot Framework & LUIS.ai

Page 2: Microsoft Bot Framework Introduction

Kevin Leung

Microsoft Bot Framework Cognitive Services +

LUIS.ai ASP.NET Core Internet of Things

Microsoft Technical Evangelist

Follow Me: @KSLHacks

Page 3: Microsoft Bot Framework Introduction

Road Map Why Bots Real World Demo Microsoft Bot

Framework Building our own bot Adding Intelligence Deploying!

Page 4: Microsoft Bot Framework Introduction

Why Conversation as a Platform?

“Bots are the new apps,” said Nadella during a nearly three-hour keynote here that sketched a vision for the way humans will interact with machines. “People-to-people conversations, people-to-digital assistants, people-to-bots and even digital assistants-to-bots. That’s the world you’re going to get to see in the years to come.”

- USA TODAY

“Microsoft CEO Satya Nadella says future belongs to bots”

Page 5: Microsoft Bot Framework Introduction

FRIDGEBOT DEMO

Try it yourself: aka.ms/fridgechatbot

Page 6: Microsoft Bot Framework Introduction

Microsoft Bot Framework

■ Supports NodeJS and C# .NET■ Lead users through conversation

– Prompts, Choices, Media, Rich Cards (Displays)■ Bot Emulator provided for local development/testing■ Easy to incorporate Natural Language Processing

(Cognitive Services)■ Easily deploy to Azure Cloud Services

Page 7: Microsoft Bot Framework Introduction

Connectors and Benefits

Your Bot(C# or

Node.js)

■ Connector to Platform Channels– One Bot : Many Channels and endpoints

■ Why restrict yourself to one platform?– Hit them all

■ Half the battle is getting users to download your app.– They already have these installed

Page 8: Microsoft Bot Framework Introduction

OUR FIRST BOTVisual Studio Community

Page 9: Microsoft Bot Framework Introduction

Getting Started

1. Download the Bot Application Template here: http://aka.ms/bf-bc-vstemplate

2. Save zip file to Visual Studio templates directory3. Open Visual Studio4. Create new Visual C# project using the Bot Application Template

Page 10: Microsoft Bot Framework Introduction

Testing out the Template

1. Download the Bot Framework Emulator here: https://emulator.botframework.com/1. More info:

https://docs.botframework.com/en-us/tools/bot-framework-emulator/

2. Run the project in Visual Studio3. Check the localhost in the browser that opens 4. Enter the same local host PORT and press Connect

Page 11: Microsoft Bot Framework Introduction
Page 12: Microsoft Bot Framework Introduction

Adding a new RootDialog

Page 13: Microsoft Bot Framework Introduction

RootDialog.cs

1. Inherit from IDialog<object>2. Implement StartAsync() method

1. Welcome our users3. Create a new method to display a prompt after the greeting message

Page 14: Microsoft Bot Framework Introduction

RootDialog.cs - Prompting Choice

1. Add strings which will become your option choices for the user2. PromptDialog.Choice will present option buttons to the user

Page 15: Microsoft Bot Framework Introduction

RootDialog.cs - OnOptionSelect

■ This method runs when the user selects an option– Arguement result holds the user’s response

Page 16: Microsoft Bot Framework Introduction

RootDialog.cs – PromptDialog.Text()

Page 17: Microsoft Bot Framework Introduction

LUIS.ai

■ Language Understanding Intelligence Service (LUIS)■ Natural Language Processing (NLP)

– Using artificial intelligence to process natural language■ Extract Intents (meaning of the utterance)■ Extract Entities (items in the utterance that are of value)

■ This is a huge problem developers working with AI or human speech encounter– Cognitive Services: LUIS abstracts this into a training model

Page 18: Microsoft Bot Framework Introduction

CREATING INTELLIGENCE!

LUIS.ai

Page 19: Microsoft Bot Framework Introduction

Creating a LUIS model

1. Head over to luis.ai2. Log in with your Microsoft live account3. Create a new model

1. You will need an Azure account to create a ‘Cognitive Service’ service

2. This will provide you with a Key. (free, but need to get it through Azure Portal)

Page 20: Microsoft Bot Framework Introduction

Creating a LUIS model

Page 21: Microsoft Bot Framework Introduction

Add Intent

Page 22: Microsoft Bot Framework Introduction

Train the model

Page 23: Microsoft Bot Framework Introduction

Add new Intent + Entity

1. Created new Intent ‘UpdateTwitter’2. Clicked on the ‘@’ and ‘kslhacks’, entered a new entity name and

press ‘create’

Page 24: Microsoft Bot Framework Introduction

Training Intent and Entity

1. Select all other entities and label them accordingly..2. You can now select from the created entity

Page 25: Microsoft Bot Framework Introduction

Training Intent and Entity

■ Continue creating intents and entities in the portal■ Make sure to add sufficient utterances, label entities and save!■ For this demo we will create ‘Greeting’, ‘UpdateTwitter’, ‘UpdateName’

and ‘None’– None is always created in every model– LUIS passes back ‘None’ intent when it does not match any other

intent– Think of ‘None’ as a fall through– If LUIS doesn’t know how to handle an utterance ‘None’ is

returned

Page 26: Microsoft Bot Framework Introduction

Train model

■ Navigate to ‘Train & Test’ (left menu)– Press ‘Train Application’

■ You can always go back to the intents and train the utterances– This makes your LUIS model smarter!– It should start identifying entities correctly

■ You can test the confidence level under the ‘Test & Train’– Confidence for each intent is shown– Entities are displayed here

Page 27: Microsoft Bot Framework Introduction

Publish model

1. Navigate to ‘Publish App’ (left menu)2. Press ‘Publish’3. Make note of the model ID and model Key from the ‘Endpoint url’

Page 28: Microsoft Bot Framework Introduction

LUIS JSON

■ If we click on the endpoint and add an utterance– Add after ‘&q=‘ at end of url

■ We can see the JSON LUIS returns back to us■ This is what we consume in our bot

Page 29: Microsoft Bot Framework Introduction

ADDING INTELLIGENCE!

LUIS Intent Dialogs C#

Page 30: Microsoft Bot Framework Introduction

Adding LuisDialog

1. Using Microsoft.Bot.Builder.Luis;2. Change IDialog<> to LuisDialog<>3. [LuisModel(“<model ID>”,”<model Key>”]

Page 31: Microsoft Bot Framework Introduction

LUIS models and Intents

1. Create a method for each Intent, passing in IDialogContext, and LuisResult

2. Add [LuisIntent] attribute above each method3. User input will be passed to LUIS endpoint and JSON will be returned4. The bot will handle the LUIS JSON and execute the correct method

base don the intent

Page 32: Microsoft Bot Framework Introduction

LUIS models and Intents

Page 33: Microsoft Bot Framework Introduction

LUIS models and Intents

Page 34: Microsoft Bot Framework Introduction

DEPLOY TO AZURE

Web App Services

Page 35: Microsoft Bot Framework Introduction

Publish Project to Azure

■ Must be signed into your Visual Studio■ Must have activated Azure Cloud on

your account

1. Right click on your project2. Click ‘Publish’ option from the menu3. Click ‘Microsoft Azure App Service’4. Crate new Resource Group to Host

Page 36: Microsoft Bot Framework Introduction

Publish Project to Azure

Page 37: Microsoft Bot Framework Introduction

REGISTER YOUR BOT

Dev.botframework.com

Page 38: Microsoft Bot Framework Introduction

Register Bot

1. Head over to https://dev.botframework.com/bots/new to register your bot2. Add a Name, bot handle and description3. Add the Message endpoint

1. This is the azurewebsites.net endpoint you just made!2. Few things to add.. Mine was demobot.azurewebsites.net3. I will enter: https://demobot.azurewebsites.net/api/messages

4. Click ‘Crate Microsoft App ID and password1. Remember these!

5. Register your bot!

Page 39: Microsoft Bot Framework Introduction

Add your ID and Password

■ Since we have registered our bot’s end point with an ID and Password, we need to add these credentials to our bot.

1. Navigate to Web.config (under Solution Explorer on the right side)2. You should see a empty spot for our “MicrosoftAppID & Password”

values.1. Paste these here!

Page 40: Microsoft Bot Framework Introduction

SETUP CHANNELWeb Chat

Page 41: Microsoft Bot Framework Introduction

Setup Web Chat ChannelOnce you have registered your bot, go to the Channels section of the portal.Click ‘Edit’ for Web Chat

■ You will be brought to a new page.

■ Click ‘Add new site’■ Name your site

(reference only)■ Click ‘Done’

Page 42: Microsoft Bot Framework Introduction

Get your secret key and embed code1. Click ‘Show’, you will need to put this key in the

‘YOUR_SECRET_HERE’ embed code2. Copy the embed code

Page 43: Microsoft Bot Framework Introduction

Add your embed code

■ Under Solution Explorer (on the right), find ‘default.htm’■ Paste the embed code WITH your secret here.

Page 44: Microsoft Bot Framework Introduction

Re-Publish to Azure!

1. Right click your project Publish2. Now we should be able to navigate to our demobot.azurewebsites.net

and see our bot!

Page 45: Microsoft Bot Framework Introduction

Ready for the world to use

Page 46: Microsoft Bot Framework Introduction

Thanks!

■ github.com/KSLHacks/FridgeChatBot■ dev.botframework.com■ luis.ai■ azure.microsoft.com/free ($200 credits)

// Kevin Leung// Microsoft Technical Evangelist// Twitter: @KSLHacks (send questions here)// Github: KSLHacks