The document discusses Microsoft technologies that can be used to build conversational bots, including the Microsoft Bot Framework, Cognitive Services, and Bot Distribution Channels. It provides an overview of how bots work and examples of code for creating a basic flashcard studying bot using the Bot Framework, including handling prompts and responses from the user. The document also briefly mentions using LUIS for more advanced, AI-based bots and includes a demo of a bot created with these Microsoft technologies.
4. Microsoft Knowledge Cloud
Tap into vast information, facts & actions on people, places and things from the web or your circle
Microsoft Bot Framework
Build your own conversational agents, and connect them wherever your users are talking
Microsoft Cognitive Services
Give 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
5. 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
23. 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])
}]
)
…...........
);
24. 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
25. 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')
}]
);
26. 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");
27. 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')
}]
);
39. Sarah Sexton
Technical Evangelist
US 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
Editor's Notes
For those of you who don't know me, I'm Sarah Sexton, Microsoft Technical Evangelist, Indie Game Developer, blogger, and co-founder of the Voxelles: Chicago’s Women in Game Development. I also work extensively with Azure | Xamarin | Microsoft Bot Framework | HoloLens | UWP | Unity
Bots can do a lot.
You can think of bots or chat bots as conversational interfaces that are programmed to interact with humans in a life-like manner.
Bots also have a human-like online presence as they are assigned their own name and profile.
Bots reside in messaging applications and interact with the user to answer questions, give relevant results, fetch information from different sources and even entertain.
For many users, the human-like responses that bots give is the number one reason that they prefer bots over apps nowadays.
The Hackathon Story
We want to #empower every developer to spice up any hackathon with the Microsoft Bot Framework. Add a conversational platform to any application you are building to take your project to the next level. They can be built for almost anything to help automate and create a more natural human interaction for everyday tasks. Join me in learning how to code a chat bot that helps you rock it at hackathons!
My coworkers Kevin and Gabby created a flashcards bot using something called the Quizlet API! Th idea behind that bot was, if you are on the go, but would still like to study up on something, you could use this bot to study your Quizlet flashcards any time, any where.
Prerequisites
1. You are going to need an Azure account. 2. Node.js
3. Quizlet Developer Account
Once you have created your Azure account, it is time to create a web application for the Chat Bot to run on. This is where the endpoints for communication with your bot are created.
Once your Web App is created and available in the 'All Resources' menu, go to your Web Apps Overview section and find the URL. Save that URL somewhere because it will come in handy later.
After your web app has been created, you will need to register your bot on the bot framework site.
Generate your Microsoft App Id and Password by pressing the 'Create Microsoft App ID and password.'
Your App ID will automatically populate and you need to save your App password somewhere separately, because it will be hidden, until you regenerate a new one.
Lastly, you will need to add your APP ID and APP PASSWORD to your Azure settings. Go back to your web app overview, and in the task panel, go down to Application Settings.
Scroll down to the Application Settings section and fill in your APP ID and APP PASSWORD. The Key column should state MICROSOFT_APP_ID and the value is the App ID you got from Bot registration. For the App Password, the Key is MICROSOFT_APP_PASSWORD and the value is the App Password you got from Bot registration.
First, create a new directory! In the working directory, you will need to initialize it as a Node project with “npm init”, then download the proper node modules with “npm install”.
Create an app.js file in your directory, as seen here. You will also want to create another .js file that will communicate with the Quizlet API. (In this repository, the file is called api.js)In your app.js file you will need the following required code just to properly set up your bot: [slide] This is just the bare bones of the bot.
Dialogs are used to manage the bot’s conversation with a user. They are called upon the same way a website calls on a webpage, via routing. '/' is the root dialog -- which is the first thing the bot will say when the user calls upon it. '/test' is a dialog named test. Let’s break down some components of this dialog.
So what if you want to know how the user responds to a question, but you don’t need access to the answer data? There are Intents! The IntentDialog class lets you listen for the user to say a specific keyword or phrase. Once a user sends a response, you can see if their response "matches" certain words/phrases:
Looking at this code, you see that the dialog starts with the root function; simply asking the user if they would actually run to the program. In every dialog, you see a parameter named session. The session object is passed to your dialog handlers anytime your bot receives a message from the user. The session object is the primary mechanism you’ll use to manage messages received from and sent to the user.
In the '/subject' dialog, the user is prompted for what flashcard set they would like to study. Once they choose, GetTerms is called based on their decision and then the bot will go to the '/study' dialog. In the '/study' dialog, the act of looking at terms, "flipping" the card for the definition, moving to the next card and possibly exiting early is possible. Waterfalls are seen in several of the dialogs seen above. Waterfalls are used to let you collect input from the user using a sequence of steps.
In the '/subject' dialog, the user is prompted for what flashcard set they would like to study. Once they choose, GetTerms is called based on their decision and then the bot will go to the '/study' dialog. In the '/study' dialog, the act of looking at terms, "flipping" the card for the definition, moving to the next card and possibly exiting early is possible. Waterfalls are seen in several of the dialogs seen above. Waterfalls are used to let you collect input from the user using a sequence of steps.
Many dialogs will have several functions inside of them in which one function will be called after the other. Most waterfalls work by prompting the user for information in one function, passing the answer to the next function, then manipulating the answer received. All your parentheses, curly braces, and brackets have to properly enclose each route and their functions.
THERE ARE TWO WAYS THAT BOTS WORK UNDER THE HOOD
They either use ARTIFICIAL INTELLIGENCE, PRIMARILY NATURAL LANGUAGE PROCESSING to function and RULE-BASED BOTS.
First let’s go through how RULE-BASED BOTS work.
Rule based bots work by offering you multiple choice options. The answers are categorized in the bot and depending on that it helps you.
They do not understand language and get stuck if you give an answer that is not part of their repository.
NOW LET’S TALK ABOUT AI-BASED BOTS.
AI BASED BOTS ARE SMARTER AND MORE INTELLIGENT THAN RULE BASED BOTS. THEY UNDERSTAND THE CONTEXT AND INTENT OF USER.
The artificial intelligence bots in the market today actually use a subset of AI, called natural language processing (NLP).
But they get involved in the conversation and pick up keywords and phrases from the user’s requirement instead of searching for specific answers. Results are provided according to the mapping methods taught to these bots.
AN AI-BASED BOT WOULD NOT GET STUCK IF THE USER RESPONDED WITH ‘YA’ INSTEAD OF ‘YES,’ UNLIKE A RULE-BASED BOT.
If you want to learn more about the chat bots we’ve talked about here today, clone my GitHub repository at the URL above!