Microsoft MVP &
Development Consultant
Black Marble
@jamesemann
Introduction to
Microsoft Bot Framework
@developerday
James Mann
Sponsors
Agenda
What is a chatbot?
Why chatbots?
What is Bot Framework
Building conversations
luis.ai
https://github.com/jamesemann/ddd2017
Code
What is a chatbot?
@jamesemann
Why chatbots?
@jamesemann
Year of the chatbot
Distribution
Over 4 billion global users using
messaging platforms
6 out of the top 10 apps used globally
are messaging apps
There is a messaging ecosystem
And a virtual assistant device ecosystem
Use cases are everywhere
Customer Service Help DeskShopping Experience Employee Support
• FAQ
• Account queries
• Resolve order issues
• Parcel Tracking
• Transport queries (bus,
train)
• Problem
troubleshooting
• New user on-boarding
• Response suggestion
• Recommend product
• Flight, hotel booking
• Improving search
• Find the right product
• Product information
• Data insights
• Find the right expert
• HR – booking holiday,
fault reporting
• Meeting room booking
What is Bot
Framework?
@jamesemann
Bot Framework
Build, host and maintain one chatbot
Target multiple channels
Bot Framework Architecture
Routes messages
Manages state
Bot registration, directory
Session tracking
Services (translation…)
Per-user, per-bot storage
SDK, APIs
Bot Connector
Your Bot logic
Your Bot’s web
service
Your first chatbot
@jamesemann
Register your chatbot
through the
Bot Framework Portal
Register
Build your chatbot using
C# or Node JS
Build
SkypeFacebook & more!
Distribute
Demo
Your first chatbot
@jamesemann
Modelling your conversation
Flexibility
Effort to implement
Dialogs
FormFlow
QnA
Bespoke
Questions and answers (FaQ),
Command and control
Data capture,
“Web forms” scenarios
Multi layered conversations
Roll your own
state management etc
Dialogs
@jamesemann
Conversational banking
Context.Wait()
Wait for a user to send a message in the same Dialog
Context.Call() & Context.Forward()
Call another Dialog, adding it to the top of the stack, with or without
passing a message to the child Dialog.
Context.Done()
Complete the current Dialog, removing it from the stack
Dialog transitions
Demo
Banking Bot using Dialogs
@jamesemann
Form Flow
@jamesemann
Form Flows are suited to data
capture
Similar to a form in a
traditional web page
Very simple to implement
Form Flow
Parking enquiry chatbot
Demo
Form Flow chatbot
@jamesemann
QnA Maker
@jamesemann
Build, train and publish
Q&A bots based on
existing FAQs
https://www.qnamaker.ai
QnA Maker
Demo
qnamaker.ai
@jamesemann
Demo
Banking bot using Dialogs
@jamesemann
Demo
QnA Maker chatbot
@jamesemann
luis.ai
@jamesemann
Utterance (input)
A spoken or written message
Intent (output)
What is the user intending to do?
Entity (output)
What objects are being referred to?
luis.ai terminology
“Set the
temperature in
the kitchen to 21
degrees”
“Set the
temperature in
the kitchen to 21
degrees”
“Set the
temperature in
the kitchen to 21
degrees”
luis.ai intent recognition & entity extraction
Model
(luis.ai API)
Intent
Entities
“Set the
temperature in
the kitchen to 21
degrees”
Set temperature
Room = Kitchen
Value = 21 degrees
“Set the
temperature in
the kitchen to 21
degrees”
“Set the
temperature in
the kitchen to 21
degrees”
luis.ai components
Portal Api
Define
Train
Publish
Consume
Home automation chatbot
A more intelligent chatbot
luis.aiBot ApplicationChannels
Model
API Controller
Luis Dialog
Other
Business
Logic /
Dialogs etc.
Demo
Home automation chatbot
@jamesemann
• Create an account @ dev.botframework.com
• Download the emulator + Node/C# SDK
• Start providing a conversational interface to your
existing apps!
Thank you!
MICROSOFT
Useful links:
Bot samples, tutorials, case studies:
aka.ms/botresources
Bot framework:
• dev.botframework.com
• github.com/microsoft/BotBuilder
• github.com/microsoft/BotBuilder-samples
Cognitive Services:
aka.ms/cognitive
Blogs:
James Mann:
blogs.blackmarble.co.uk/blogs/jmann/
Twitter:
@jamesemann
https://github.com/jamesemann/ddd2017
Resources

DDD12 - Introduction to Microsoft Bot Framework

Editor's Notes

  • #2 Thanks for turning out to this session. It’s good to see that people are interested in this new technology. Just to set your expectations Today we are going to look at creating Bots with Microsoft Bot Framework. Because I am a .NET developer, the examples I will show you today are in C#. But everything you see here can be done with Node JS as well. Maybe do a show of hands .NET / Node / Other
  • #3 Thank them & visit their stands Microsoft – venue Black Marble – organisation/volunteers NDC, Grey Matter, Sonoco Trident, Fiscal Technologies, iO Associates – Platinum Sponsors DevExpress – speaker/volunteer shirts Huddle – Agendas! ByBox - xxx
  • #4 The aim of today is to introduce you to the bot framework Give you everything you need to get started
  • #5 All the code is available in github here. I’ll put this on again when we wrap up
  • #6 Helpful to understand what a chatbot actually is because the term bot is quite overloaded So by way of example you will see that
  • #7 I am calling a bot, a software application that is delivered over messaging applications This may use a conversational interface, or command and control This example is skyscanner, it lets you find out about flights without installing any software It’s a nice natural—in this case conversational– interface That has a really low barrier to entry.
  • #8 But also consider less conventional applications “accessible through email” as bots as well x.ai is a popular scheduling assistant, that can help avoid scheduling ping pong between meeting participants. Microsoft have a similar email scheduling bot calendar.help
  • #9 That was a quick definition of a bot, so lets talk about why they have become popular
  • #10 2016 was called year of the bot, In 2016 you can see Conversational User interface and Virtual Personal Assistants are on the innovation trigger heading up to the peak of inflated expectations. Interestingly, Gartner predict that the hype wont plateau for 5-10 years. So the hype rollercoaster is set to continue for a couple more years at least. Why is it so interesting? Lets take a look Most cited reasons: #1 distribution #2 better experience?? (engage with the chat generation)
  • #11 So the big selling point is distribution. Everyone has a device on them. People are addicted to their phones, and particularly messenger apps. Chatbots take advantage of this by using messenger apps and virtual assistants to reach users where they are already active. Take a look at your phone home screen. Count how many messaging/assistant apps you have on there. Count things like email too because you have seen that chatbots can be delivered across all these channels. It’s a really compelling distribution story and I think it is the number one reason for chatbot hype.
  • #12 So digging into it from a bot framework perspective. There are 12 messaging channels supporting messaging apps and virtual assistants. 3 new channels were announced at //BUILD – Bing search Skype for business cortana
  • #13 And these dedicated virtual assistant devices are becoming mainstream. Everyone has seen the examples GOOD and BAD of amazon alexa. Google home has recently become available in the UK And dedicated cortana devices are on their way.
  • #14 So there are tons of use cases for chatbots. Some are just delivering existing functionality through a new experience, but others, like x.ai are bot first applications, made possible with the distribution and channel capabilities. Not every use case is appropriate though. Bots tend to work very well when the application is precise. Here I’ve highlighted an example of a use case that doesn’t work very well. If you think of how a lot of people shop, they don’t typically have a specific product already in mind. They want to maybe browse a catalogue, and discover and get a wide range of inspiration before narrowing down their product. Chatbots make this difficult because the canvas capabilities require information to be more precise.
  • #15 So, now you understand the what and why, lets look at the tools and services that bot framework gives you to create your own bots.
  • #16 If you were to create chatbots natively, you would have to create an implementation of the same chatbot for each channel you wanted it to run on. Bot framework acts as a chatbot broker, where you write a single chatbot application , and let bot framework provide the plumbing to the channels through configuration. It allows you to focus on your business logic, and be agnostic of how the bot connects to the channels under the hood.
  • #17 In terms of architecture, there are three components, On the left, we have your bot application, which is an ASP.NET web api / node web service Your bot application makes use of the bot connector, which is a logical grouping of SDKs, bot registration and administration Finally the components in the bot connector provide the connectivity to distribute across channels.
  • #18 So, how do we get started? Well, I like to break it down into three simple steps.
  • #19 First you register the Bot. You give your bot a name, an icon, provide an API endpoint that it will talk to.
  • #20 Then build using C# or Node JS
  • #21 Then you distribute. This is all done by turning on the channel in the portal. once you have defined your Bot application and does not require code changes! Here I am exposing my bot over facebook, then skype, I can choose at any time, to distribute to any of the other channels currently supported by Bot framework. And – a key benefit – if channels are added in future – my bot is already future proof!
  • #22 Lets take a look at creating the chatbot and testing using the channel emulator
  • #23 So when you are first starting your conversation, you have a decision to make about which tools you use. This depends on the type of conversation. I’ve tried to show this in the diagram along the bottom is the amount of effort required to implement. Along the side is the amount of flexibility So basically, if you have a simple bot scenario you are going to be looking at the bottom left If you have a complex scenario you are going to be looking at the top right We are going to be focussing on Dialogs, which gives you benefits of state management, persistence etc while giving you a good level of flexibility
  • #24 Dialogs are the core building block, so we will look at them first
  • #25 Talk through an example of a BANKING BOT Can do a couple of simple tasks Check balance (savings or current) And make a payment
  • #26 Talk through an example of a BANKING BOT Can do a couple of simple tasks Check balance (savings or current) And make a payment
  • #38 So how do we deliver this ‘layering’? We use dialog transitions There’s more , but these are the important ones
  • #39 Lets look at this in code
  • #40 Next we can take a look at form flow.
  • #41 Think of form flow as a low resistance way to get simple “form based” applications running as a chat bot. They provide several conveniences. Are very simple to implement, but are limited. So it is very much a tradeoff. You can combine formflow with dialogs, and other techniques, to get the best of both worlds.
  • #42 So I wanted to put together an example here where users can log a parking enquiry – currently through a webform. There are three simple fields, basically a checkbox saying what kind of enquiry the user as, then a field for the location, and another field detailing the product. When the user fills it in they are shown the typical confirmation page. People are often felt like they are left hanging especially if they have a urgent enquiry
  • #43 So lets take a look at how we can implement this using a bot.
  • #44 Now we will talk about the next technique we can use to build simple, FaQ, or command and control type bots
  • #45 Common requirement for chat bots to surface answers to common questions QnA Maker Service trains AI to respond to questions in a natural conversational way Integrates easily with bots built using the Bot Framework – it is just a REST based API Really easy way to get a bot up and running and start seeing the benefits! http://qnamaker.ai ------------------------------------------------------ Brief overview of the QnA maker Sign into qnamaker.ai Create a new service using https://azure.microsoft.com/en-gb/support/faq/ Try "What does it mean if a service is in preview" -> show that we receive the right answer Talk about training Try "How do I raise a support request?" -> We get an answer but not the right one. Let's type "How do I submit a support request?" -> Get the right answer and add "How do I raise a support ticket?" as alternative phrase and re-train Now try "How do I create a ticket with support?" -> get the right answer Publish the service Switch to bot demo in VS and show how we are calling our QnA Maker service and demo the bot Maybe show my QnAMakerDialog available on NuGet??? YES
  • #46 Lets take a look at the UI
  • #48 So we have an api that we can consume with any app, but it makes sense to hook it up to a bot so lets see how easy it is to do that
  • #49 The final topic we will cover briefly deals with layering in natural language processing using luis.ai to recognise users intent.
  • #50  There’s more , but these are the important ones
  • #51 So taking those concepts through a home automation example
  • #52 Portal Used to define intents and entities, and to train the model Api Used to consume the model, i.e. understand the intent of sentences
  • #53 I want to create a chatbot to set the temperature turn on lights etc, but I want it to be natural and work with plain English So I’ve created a model in luis.ai which I am showing you as screenshots for expediency. This is deployed out and available as an API endpoint.
  • #54 So I have a list of ENTITIES as discussed
  • #55 And 6 intents for different commands
  • #56 If I click into the intents I can see example utterances
  • #57 So with that in mind, this is what we want to achieve.
  • #58 Lets take a look at how we can do it Facebook messenger bot
  • #59 There’s more , but these are the important ones
  • #60 Introductions and Agenda (2 Mins) Introduce Simon, Gary, James Set expectations: intro to bot framework. Very quick demo of JUST EAT to show what a bot is What we are going to cover
  • #61 We’ve seen that messaging is a dominant player in communications for both consumers and business and that businesses are expecting this to increase. There are clear benefits for many businesses implementing bots The Bot Framework enables a bot to be built in popular languages and hosted in many places. The bot can operate and appear in many different channels. Cognitive Services bring significant capabilities to bots and LUIS is a key service for determining the intent of the user.