Breaking into Bots

Post on 23-Jan-2018

427 views 0 download

Transcript of Breaking into Bots

Introduction

To Bots

What Can Bots Do?

@Saelia

Microsoft Knowledge CloudTap into vast information, facts & actions on people, places and things from the web or your circle

Microsoft Bot FrameworkBuild your own conversational agents, and connect them wherever your users are talking

Microsoft Cognitive ServicesGive smarts to your experiences with cutting-edge technologies for speech, vision, language and knowledge understanding

Build and deploy your web service with Azure’s industry-leading Platform-as-a-Service (PaaS) cloud infrastructure.

Microsoft Bot Distribution Channels (Bing, Skype, Cortana/Win10, and third party clients like Slack, Kik, and Messenger)

Conversations as a Platform Technologies

Microsoft Azure

Chat bots

Bots / Chat bots are

conversational

interfaces

They have a human-like

online presence

A bot resides in a

messaging application as

a contact

The StoryMHacks

@Saelia

@Saelia

The SolutionHackathon Bot

@Saelia

http://portal.azure.com

@Saelia

1. Find your endpoint

URL on Azure

2. Register Your Bot

3. Save App ID and

App Password

@Saelia

s /api/messages

Web App Settings:

2. MICROSOFT_APP_PASSWORD

Let’s get coding!#BotFramework

@Saelia

@Saelia

var restify = require('restify');

var builder = require('botbuilder');

//=========================================================

// Bot Setup

//=========================================================

// Setup Restify Server

var server = restify.createServer();

server.listen(process.env.port || process.env.PORT || 3978, function () {

console.log('%s listening to %s', server.name, server.url);

});

// Create chat bot

var connector = new builder.ChatConnector({

appId: <Your App ID>

appPassword: <Your App Secret>

});

var bot = new builder.UniversalBot(connector);

server.post('/api/messages', connector.listen());

bot.dialog('/', function (session) {

session.send("Hello World");

});

The IntentDialog class lets you listen for the user to say a specific keyword or phrase.

bot.dialog('/study', new builder.IntentDialog()

.matches(/^ready/i, [

function (session) {

session.send(quiz.Terms[index])

}])

.matches(/^flip/i, [

function(session) {

session. send(quiz.Def[index])

}]

)

…...........

);

Session object is passed to your dialog handlers any time your bot receives a message from the user.

The session object is the primary mechanism used to manage messages received from and sent to the user.

bot.dialog('/', function (session) {

session.send("Hello! Welcome to the MHacks Quiz Bot. Would you like to study today?")

session.beginDialog('/user');

});

@Saelia

bot.dialog('/subject', [

function (session) {

setTimeout(function(){

builder.Prompts.text(session, "What study set would you like today?" + quiz.Sets);

}, 2000)

},

function (session, results) {

quiz.GetTerms(results.response);

session.send("Ok! I got your flashcards! Send 'ready' to begin. Send 'flip' for definition. Send 'next'

for the next card. Send 'exit' when you are done")

session.beginDialog('/study')

}]

);

Different return types of prompts available:

builder.Prompts.text(session, "What's your name?");

builder.Prompts.number(session, "How many do you want?");

builder.Prompts.time(session, "When is your appointment?");

builder.Prompts.choice(session, "Which color?", "red|green|blue");

bot.dialog('/subject', [

function (session) {

setTimeout(function(){

builder.Prompts.text(session, "What study set would you like today?" + quiz.Sets);

}, 2000)

},

function (session, results) {

quiz.GetTerms(results.response);

session.send("Ok! I got your flashcards! Send 'ready' to begin. Send 'flip' for definition. Send 'next'

for the next card. Send 'exit' when you are done")

session.beginDialog('/study')

}]

);

@Saelia

Smarter Not Harder!Using LUIS

@Saelia

https://www.luis.ai/

Microsoft Cognitive Services

@Saelia

Types of

Bots

Rule-Based Bots

AI-Based Bots (uses NLP)

{“entities”: [

{“entity”: “flight_delays”,“type”: “Topic”

}],“intents”: [

{“intent”: “FindNews”,“score”: 0.99853384

},{

“intent”: “None”,“score”: 0.07289317

},{

“intent”: “ReadNews”,“score”: 0.0167122427

},{

“intent”: “ShareNews”,“score”: 1.0919299E-06

}]

}

I want to use Microsoft technology to hack and win a Surface Pro 4

sponsor action prize

@Saelia

Demo Time

@Saelia

Sarah Sexton

Technical EvangelistUS DX Audience | Microsoft, Chicago@Saelia

• Steps: http://aka.ms/MHacksChatBot

• Demo: MicrosoftCareerBot.azurewebsites.net

• GitHub.com/jennifermarsman/MicrosoftCareerBot

• Slides: http://aka.ms/BreakingIntoBots

• Docs: http://dev.botframework.com