How to build a user interactive bot with Microsoft Bot Framework

Published 03-21-2019 09:23 AM 1,434 Views
Microsoft
First published on MSDN on Oct 28, 2017

Guest blog by Shu Ishida Microsoft Student Partner at Oxford University

About me

My name is Shu Ishida, and I am a third year engineering student at the University of Oxford. I am into web development and design, and my ambition is to help break down educational, cultural and social barriers by technological innovation. My current interest is in applications of Artificial Intelligence to e-Learning. I also have passion towards outreach and teaching, and have mentoring experiences in summer schools as an Oxford engineering student ambassador.

LinkedIn: https://www.linkedin.com/in/shu-ishida

Introduction

I would like to give an overview on how to build a user interactive bot with Microsoft Bot Framework. For those of you who are not familiar with bots, bots are applications that can assist your daily needs like a virtual robot. They can perform semi-automated tasks, such as setting an alarm, searching online, making an order, and posting on social media. The beauty of modern bots is that it can understand and operate on instructions that are given through text and voice dialog.

Today we are going to make a bot that is both usable and user friendly. We’ll use Microsoft Bot Framework – a comprehensive framework that can be used by anyone from beginners to developers. We’ll first discuss how to build a bot, and later on, talk more about why user experience is important and how we can design conversation flow.

Registering to Microsoft Azure

To get started, let’s create an Azure account – registration and trial is free.

https://azure.microsoft.com/

If you are new to Azure, Azure is a comprehensive set of cloud services to build, deploy and manage applications. Today we are going to focus on Bot Service, but there are other fantastic features such as Azure Machine Learning where you can train your online machine learning model which require minimal amount of programming.

Creating your first bot

Once you are registered, go to your dashboard at https://portal.azure.com/ and click ‘New’ with the green plus icon. From the options, select ‘Data + Analytics’ > ‘Bot Service’.

Alternatively, you can go to https://dev.botframework.com/ and click ‘Create a bot’ button on the ‘My bots’ page. This site also has useful documentation for Bot Framework.

Fill in the app name and the location, and press ‘Create’. Here I named my bot ‘superbott’.

There are five templates available to get your development going. You can choose your template according to what sort of bot you are going to make. For now, let’s try building a bot which can understand dialogs using the Cognitive Services LUIS (Language Understanding Intelligent Service) API. [Read Documentation]

A screen appears, prompting you to get an App ID and password. After pressing ‘Create Bot’, a window will open to ask you to connect Azure Bot Service to LUIS:

How to use LUIS

A LUIS app takes a user utterance and extracts intents and entities that correspond to activities in the client application’s logic. In a nutshell, this means that LUIS can identify the type of action that the user is requesting, such as flight booking, reminder, food order, etc. together with the information of quantity, specific location or name of the item of interest. LUIS gives a response in JSON format, denoting the confidence in its recognition. We can pass this response to the bot which can then take appropriate action based on the user intentions. [Read Documentation]

Let me explain more about the three concepts – utterance, intents and entitles. Utterance is the user’s input, usually by text or voice. Intents are actions that the bot is requested to take (the intention of the user), usually corresponding to the verb within the uttered sentence. Entitles are information associated to the action, such as location, date and noun in the utterance (name of an app, item, etc.). The task of LUIS is to identify the intents and entitles within an utterance. Intent options are defined by the developer (you), so in order to get the bot working, we have to first decide on what kind of tasks we are expecting our bot to do.

Here are some good tutorials on how to use LUIS to create a bot.

https://channel9.msdn.com/Blogs/MVP-Azure/build-a-chatbot-with-azure-bot-service

http://www.codeshare.co.uk/blog/how-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft...

Make the bot respond to you

Let’s start by creating a very simple bot. The default page should look like this. You can either edit the code on an online editor, or download the code and work from a local IDE / editor. The ‘Channels’ tab shows you apps that you can connect with. From ‘Settings’ you can change your bot icon. By clicking the blue ‘Test’ button, a bot emulator appears.

At the moment the bot is being highly unsociable. That is because we haven’t programmed anything yet so the bot doesn’t know what to do. We can manually programme the bot so that it can recognise utterances starting with ‘hey’ as an intent. You can make the bot respond with “Hello. How can I help you?” or maybe you can be more creative…

Ooops, we’ve made the bot angry! In this example, I’ve just added this extra line of code so that it can detect ‘hey’ at the start of the utterance.

^ denotes the start of a sentence, and ‘i' indicates that the search should be case-insensitive. These are called regular expressions , often used in text search and text replacement. The bot replies to you using session.message.text which contains your utterance.

We can continue manually coding conditions for the bot, but that makes the code convoluted. This is where LUIS becomes useful. Go to https://www.luis.ai/applications and click on the app connected to your bot. You should be able to ‘Create an intent’. Let’s call it ‘Greeting’.

We can add many examples of utterances to train the bot. Once you have finished training the bot, go to ‘Publish App’ at the bottom left navigation. Going back to the code, replace /^hey/i with ‘Greeting’ as shown below. Now your bot should be able to pick up different greetings.

Making your first Twitter bot

Now your bot will start responding to various user inputs. However, it is not exactly useful yet. To make it do something useful, let’s change it into a twitter bot. I am going to walk you through how to set it up, but if you need further details, here is a good article on how to set up your twitter and connect it to your bot.

https://medium.freecodecamp.org/how-to-build-and-deploy-a-multifunctional-twitter-bot-49e941bb3...

Alternatively, this is a good YouTube tutorial that walks you through how to create a twitter bot.

First, we want to register our bot to our twitter account so that the bot can have access using the access token and key. I strongly recommend you get a new Twitter account for development, so that if anything goes wrong, you won’t lose your Twitter account or your followers. Once you’ve logged into your new account, go to https://apps.twitter.com/app/new and fill in the details of your bot. A website URL is not essential for this.

Once you register your application, you can get details for the Consumer Key (API Key), Consumer Secret (API Secret), Access Token and Access Token Secret. Now we will return to the code on Azure and create an .env file with these details as shown below.

Separating out your API key information from the main code and storing it in .env is good practice. Otherwise, your account will be at risk if you are working on a collaborative project or sharing your code on GitHub. NEVER share your key online, even in a tutorial video or screenshot. There are crawler bots out there that tries to steal your account / API keys and if you are unlucky you can be charged for incredibly expensive bills. In case you want to upload your code to GitHub in the future, add .env to .gitignore file so that it wouldn’t be uploaded.

We have two more steps – first to read in the key information from .env into Node.js, and then connect to twitter using that account information. We can do these by installing node modules called dotenv and twit. Open the console and type

Now that we have dotenv, we can import the key information from .env to config.js.

Finally, in the app.js file, set up twitbot (a Twit object that carries out the tweeting operations) configuring with the key information. Make sure you don’t call this just ‘bot’ – it will overlap with the ‘bot’ variable defined already.

Below is the part where twitbot posts a tweet. We can determine the content in ‘status’, which I set to ‘hello world!’.

Let’s append this to the response to ‘Greeting’ for the time being as shown below.

Now everything is set up. Go to your online bot emulator and type in some greeting. After the bot responds, check your twitter account and, lo and behold! You have your first tweet!

Making the bot tweet what you want

Cool stuff! So now we can add some flexibility to the bot and make it tweet whatever we want. To get started, let’s add another intent ‘Tweet’ to LUIS so that it can distinguish between greetings and tweet tasks. Create an intent and add utterances. Remember to re-publish your changes once you’ve finished.

Now you can go ahead and handle the case where the intent matches ‘Tweet’.

The major changes I have made in the code is this bit where I have added a dialog that is called by beginDialog(‘/tweet’). This sort of dialog structure is called waterfalls implementation [Read Documentation] . In the dialog, the bot asks what the user wants to tweet and directly goes ahead posting it. This looks straight forward, but might raise an issue if we want to quit midway - we should handle this case in the next section.

Finally our bot is up and running, and can change what it tweets according to the user’s order. Notice that the initial conversation starter has been altered to indicate what the bot is about.

Go on to your twitter account and make sure it’s working! If you are having problems with your tweet, maybe it is because you are posting the same sentence over and over again. Twitter doesn’t seem to allow multiple identical tweets.

The problem with quitting

So far so good. But what if we change our mind half-way through the action? Consider this situation below:

In this case we want the bot to be clever enough to detect that the user has changed their mind and wants to quit. Although we can try creating an additional intent for cancellation, there is a straightforward way of handling user action, and moreover, call out a predefined function to cancel an action. Here we are going to use cancelAction, but other actions such as triggerAction and reload Action could be also handy. [Read Documentation]

As it could be seen, this interface provides the opportunity for users to quit, and moreover, cancel the quit operation and go back to where the bot was interrupted. Determining every possible flow of conversation that can occur, and handling cases that doesn’t follow the designed conversation pattern is crucial in bot building, since it doesn’t have a navigation system of back and forward unlike web browsers. This documentation can give you further insight into this topic.

Tweet from Facebook

Finally, let’s learn about how to use channels. By going to the ‘Channels’ tab, you can see many options where you can use your bot. Slack is quite a common place to use bots, but today let’s have our bot working on Facebook messenger. To get started with, click the Facebook messenger icon. The documentation walks you through step by step. [Read Documentation]

Since the bot is associated to a Facebook page rather than a user account and is intended to be used as an autoreply bot for an organisation, we’ll first have to create a new Facebook page and connect the bot to it.

1. Create a new Facebook page from https://www.facebook.com/bookmarks/pages .

2. Create a new Facebook App from https://developers.facebook.com/quickstarts .

3. Select Messenger as your product and generate a Page Access Token.

4. Copy and paste your credentials from all the above into the Bot Framework Portal.

5. Click ‘Set up Webhooks’ on the Messenger setup page.

6. Copy and paste the webhook callback URL and verify token from the portal into the webhook form.

7. Save details.

Now let’s go back to the Facebook page we have created and send a message, and lo and behold! The Facebook page gives automated replies!

For obvious reasons, you don’t want all the Facebook users in the world to be able to tweet on your Twitter account, so make sure you delete the newly created Facebook App once you’re done with it. Although a Twitter bot was probably not the best example of bots that can be embedded on Facebook messenger, it demonstrates how bots can be implemented and be useful when you are dealing with a ton of customers. Now, you can start to visualise these bots actually interacting with humans, and more importantly, perceived as human operators across the screen. Therefore it is highly important that the bots can provide essential services with a well-designed communication flow and without the intervention of humans.

Build your own bot with Microsoft Bot Framework

Now is time for you to create your own bot. If you are not making it public, it could be a personal planner and secretary. If you are developing for your enterprise or an online service, it could be easily made into a receptionist, companion, gaming opponent, media source, image processing service or more. Interface matters because it is automated, but once you get over that barrier, there are many opportunities out there since it could be built in to commonly used services such as Facebook messenger and Skype, so that it would be easy to subscribe.

And with that, we have come to the end of this article. Thank you very much for reading through all the way.

Resources and further information

Microsoft Bot Framework Documentation https://docs.microsoft.com/en-us/bot-framework/

Video tutorial of building a LUIS chat bot

Example of playing hangman on a Microsoft Bot http://www.codeshare.co.uk/blog/how-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft...

Example of building a Twitter bot https://medium.freecodecamp.org/how-to-build-and-deploy-a-multifunctional-twitter-bot-49e941bb3...

YouTube tutorial on how to create a Twitter bot https://www.youtube.com/watch?v=GQC2lJIAyzM&list=PLRqwX-V7Uu6atTSxoRiVnSuOn6JHnq2yV&index=3

%3CLINGO-SUB%20id%3D%22lingo-sub-379839%22%20slang%3D%22en-US%22%3EHow%20to%20build%20a%20user%20interactive%20bot%20with%20Microsoft%20Bot%20Framework%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-379839%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Oct%2028%2C%202017%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CB%3E%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EGuest%20blog%20by%20Shu%20Ishida%20Microsoft%20Student%20Partner%20at%20Oxford%20University%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95306i3DB32D4C6614171B%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CB%3E%20About%20me%20%3C%2FB%3E%3C%2FP%3E%0A%20%20%3CP%3EMy%20name%20is%20Shu%20Ishida%2C%20and%20I%20am%20a%20third%20year%20engineering%20student%20at%20the%20University%20of%20Oxford.%20I%20am%20into%20web%20development%20and%20design%2C%20and%20my%20ambition%20is%20to%20help%20break%20down%20educational%2C%20cultural%20and%20social%20barriers%20by%20technological%20innovation.%20My%20current%20interest%20is%20in%20applications%20of%20Artificial%20Intelligence%20to%20e-Learning.%20I%20also%20have%20passion%20towards%20outreach%20and%20teaching%2C%20and%20have%20mentoring%20experiences%20in%20summer%20schools%20as%20an%20Oxford%20engineering%20student%20ambassador.%3C%2FP%3E%0A%20%20%3CP%3ELinkedIn%3A%20%3CA%20href%3D%22https%3A%2F%2Fwww.linkedin.com%2Fin%2Fshu-ishida%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fwww.linkedin.com%2Fin%2Fshu-ishida%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-1483437352%22%20id%3D%22toc-hId-1483437352%22%3E%3CB%3E%20Introduction%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3EI%20would%20like%20to%20give%20an%20overview%20on%20how%20to%20build%20a%20user%20interactive%20bot%20with%20Microsoft%20Bot%20Framework.%20For%20those%20of%20you%20who%20are%20not%20familiar%20with%20bots%2C%20bots%20are%20applications%20that%20can%20assist%20your%20daily%20needs%20like%20a%20virtual%20robot.%20They%20can%20perform%20semi-automated%20tasks%2C%20such%20as%20setting%20an%20alarm%2C%20searching%20online%2C%20making%20an%20order%2C%20and%20posting%20on%20social%20media.%20The%20beauty%20of%20modern%20bots%20is%20that%20it%20can%20understand%20and%20operate%20on%20instructions%20that%20are%20given%20through%20text%20and%20voice%20dialog.%3C%2FP%3E%0A%20%20%3CP%3EToday%20we%20are%20going%20to%20make%20a%20bot%20that%20is%20both%20usable%20and%20user%20friendly.%20We%E2%80%99ll%20use%20Microsoft%20Bot%20Framework%20%E2%80%93%20a%20comprehensive%20framework%20that%20can%20be%20used%20by%20anyone%20from%20beginners%20to%20developers.%20We%E2%80%99ll%20first%20discuss%20how%20to%20build%20a%20bot%2C%20and%20later%20on%2C%20talk%20more%20about%20why%20user%20experience%20is%20important%20and%20how%20we%20can%20design%20conversation%20flow.%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1068719609%22%20id%3D%22toc-hId--1068719609%22%3E%3CB%3E%20Registering%20to%20Microsoft%20Azure%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3ETo%20get%20started%2C%20let%E2%80%99s%20create%20an%20Azure%20account%20%E2%80%93%20registration%20and%20trial%20is%20free.%3C%2FP%3E%0A%20%20%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fazure.microsoft.com%2F%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3EIf%20you%20are%20new%20to%20Azure%2C%20Azure%20is%20a%20comprehensive%20set%20of%20cloud%20services%20to%20build%2C%20deploy%20and%20manage%20applications.%20Today%20we%20are%20going%20to%20focus%20on%20Bot%20Service%2C%20but%20there%20are%20other%20fantastic%20features%20such%20as%20Azure%20Machine%20Learning%20where%20you%20can%20train%20your%20online%20machine%20learning%20model%20which%20require%20minimal%20amount%20of%20programming.%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-674090726%22%20id%3D%22toc-hId-674090726%22%3E%3CB%3E%20Creating%20your%20first%20bot%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3EOnce%20you%20are%20registered%2C%20go%20to%20your%20dashboard%20at%20%3CA%20href%3D%22https%3A%2F%2Fportal.azure.com%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fportal.azure.com%2F%20%3C%2FA%3Eand%20click%20%E2%80%98New%E2%80%99%20with%20the%20green%20plus%20icon.%20From%20the%20options%2C%20select%20%E2%80%98Data%20%2B%20Analytics%E2%80%99%20%26gt%3B%20%E2%80%98Bot%20Service%E2%80%99.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95307i8B101726BE559D81%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EAlternatively%2C%20you%20can%20go%20to%20%3CA%20href%3D%22https%3A%2F%2Fdev.botframework.com%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdev.botframework.com%2F%20%3C%2FA%3Eand%20click%20%E2%80%98Create%20a%20bot%E2%80%99%20button%20on%20the%20%E2%80%98My%20bots%E2%80%99%20page.%20This%20site%20also%20has%20useful%20documentation%20for%20Bot%20Framework.%3C%2FP%3E%0A%20%20%3CP%3EFill%20in%20the%20app%20name%20and%20the%20location%2C%20and%20press%20%E2%80%98Create%E2%80%99.%20Here%20I%20named%20my%20bot%20%E2%80%98superbott%E2%80%99.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95308iA476D608B2768ED7%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EThere%20are%20five%20templates%20available%20to%20get%20your%20development%20going.%20You%20can%20choose%20your%20template%20according%20to%20what%20sort%20of%20bot%20you%20are%20going%20to%20make.%20For%20now%2C%20let%E2%80%99s%20try%20building%20a%20bot%20which%20can%20understand%20dialogs%20using%20the%20Cognitive%20Services%20LUIS%20(Language%20Understanding%20Intelligent%20Service)%20API.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2Fazure-bot-service-templates%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20%5BRead%20Documentation%5D%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3EA%20screen%20appears%2C%20prompting%20you%20to%20get%20an%20App%20ID%20and%20password.%20After%20pressing%20%E2%80%98Create%20Bot%E2%80%99%2C%20a%20window%20will%20open%20to%20ask%20you%20to%20connect%20Azure%20Bot%20Service%20to%20LUIS%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95309i3093913478820F47%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1878066235%22%20id%3D%22toc-hId--1878066235%22%3E%3CB%3E%20How%20to%20use%20LUIS%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3EA%20LUIS%20app%20takes%20a%20user%20utterance%20and%20extracts%20intents%20and%20entities%20that%20correspond%20to%20activities%20in%20the%20client%20application%E2%80%99s%20logic.%20In%20a%20nutshell%2C%20this%20means%20that%20LUIS%20can%20identify%20the%20type%20of%20action%20that%20the%20user%20is%20requesting%2C%20such%20as%20flight%20booking%2C%20reminder%2C%20food%20order%2C%20etc.%20together%20with%20the%20information%20of%20quantity%2C%20specific%20location%20or%20name%20of%20the%20item%20of%20interest.%20LUIS%20gives%20a%20response%20in%20JSON%20format%2C%20denoting%20the%20confidence%20in%20its%20recognition.%20We%20can%20pass%20this%20response%20to%20the%20bot%20which%20can%20then%20take%20appropriate%20action%20based%20on%20the%20user%20intentions.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcognitive-services%2FLUIS%2FHome%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20%5BRead%20Documentation%5D%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3ELet%20me%20explain%20more%20about%20the%20three%20concepts%20%E2%80%93%20utterance%2C%20intents%20and%20entitles.%20Utterance%20is%20the%20user%E2%80%99s%20input%2C%20usually%20by%20text%20or%20voice.%20Intents%20are%20actions%20that%20the%20bot%20is%20requested%20to%20take%20(the%20intention%20of%20the%20user)%2C%20usually%20corresponding%20to%20the%20verb%20within%20the%20uttered%20sentence.%20Entitles%20are%20information%20associated%20to%20the%20action%2C%20such%20as%20location%2C%20date%20and%20noun%20in%20the%20utterance%20(name%20of%20an%20app%2C%20item%2C%20etc.).%20The%20task%20of%20LUIS%20is%20to%20identify%20the%20intents%20and%20entitles%20within%20an%20utterance.%20Intent%20options%20are%20defined%20by%20the%20developer%20(you)%2C%20so%20in%20order%20to%20get%20the%20bot%20working%2C%20we%20have%20to%20first%20decide%20on%20what%20kind%20of%20tasks%20we%20are%20expecting%20our%20bot%20to%20do.%3C%2FP%3E%0A%20%20%3CP%3EHere%20are%20some%20good%20tutorials%20on%20how%20to%20use%20LUIS%20to%20create%20a%20bot.%3C%2FP%3E%0A%20%20%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fchannel9.msdn.com%2FBlogs%2FMVP-Azure%2Fbuild-a-chatbot-with-azure-bot-service%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20https%3A%2F%2Fchannel9.msdn.com%2FBlogs%2FMVP-Azure%2Fbuild-a-chatbot-with-azure-bot-service%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CA%20href%3D%22http%3A%2F%2Fwww.codeshare.co.uk%2Fblog%2Fhow-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft-bot-framework%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20http%3A%2F%2Fwww.codeshare.co.uk%2Fblog%2Fhow-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft-bot-framework%2F%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--135255900%22%20id%3D%22toc-hId--135255900%22%3E%3CB%3E%20Make%20the%20bot%20respond%20to%20you%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3ELet%E2%80%99s%20start%20by%20creating%20a%20very%20simple%20bot.%20The%20default%20page%20should%20look%20like%20this.%20You%20can%20either%20edit%20the%20code%20on%20an%20online%20editor%2C%20or%20download%20the%20code%20and%20work%20from%20a%20local%20IDE%20%2F%20editor.%20The%20%E2%80%98Channels%E2%80%99%20tab%20shows%20you%20apps%20that%20you%20can%20connect%20with.%20From%20%E2%80%98Settings%E2%80%99%20you%20can%20change%20your%20bot%20icon.%20By%20clicking%20the%20blue%20%E2%80%98Test%E2%80%99%20button%2C%20a%20bot%20emulator%20appears.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95310iFD0BB960876E648F%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EAt%20the%20moment%20the%20bot%20is%20being%20highly%20unsociable.%20That%20is%20because%20we%20haven%E2%80%99t%20programmed%20anything%20yet%20so%20the%20bot%20doesn%E2%80%99t%20know%20what%20to%20do.%20We%20can%20manually%20programme%20the%20bot%20so%20that%20it%20can%20recognise%20utterances%20starting%20with%20%E2%80%98hey%E2%80%99%20as%20an%20intent.%20You%20can%20make%20the%20bot%20respond%20with%20%E2%80%9CHello.%20How%20can%20I%20help%20you%3F%E2%80%9D%20or%20maybe%20you%20can%20be%20more%20creative%E2%80%A6%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95311iB3918859FD5EB620%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EOoops%2C%20we%E2%80%99ve%20made%20the%20bot%20angry!%20In%20this%20example%2C%20I%E2%80%99ve%20just%20added%20this%20extra%20line%20of%20code%20so%20that%20it%20can%20detect%20%E2%80%98hey%E2%80%99%20at%20the%20start%20of%20the%20utterance.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95312i57DA0471EF8F07A7%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%5E%20denotes%20the%20start%20of%20a%20sentence%2C%20and%20%E2%80%98i'%20indicates%20that%20the%20search%20should%20be%20case-insensitive.%20These%20are%20called%20%3CA%20href%3D%22https%3A%2F%2Fwww.w3schools.com%2Fjsref%2Fjsref_obj_regexp.asp%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Eregular%20expressions%20%3C%2FA%3E%2C%20often%20used%20in%20text%20search%20and%20text%20replacement.%20The%20bot%20replies%20to%20you%20using%20session.message.text%20which%20contains%20your%20utterance.%3C%2FP%3E%0A%20%20%3CP%3EWe%20can%20continue%20manually%20coding%20conditions%20for%20the%20bot%2C%20but%20that%20makes%20the%20code%20convoluted.%20This%20is%20where%20LUIS%20becomes%20useful.%20Go%20to%20%3CA%20href%3D%22https%3A%2F%2Fwww.luis.ai%2Fapplications%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.luis.ai%2Fapplications%20%3C%2FA%3Eand%20click%20on%20the%20app%20connected%20to%20your%20bot.%20You%20should%20be%20able%20to%20%E2%80%98Create%20an%20intent%E2%80%99.%20Let%E2%80%99s%20call%20it%20%E2%80%98Greeting%E2%80%99.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95313i8477BADA77162341%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EWe%20can%20add%20many%20examples%20of%20utterances%20to%20train%20the%20bot.%20Once%20you%20have%20finished%20training%20the%20bot%2C%20go%20to%20%E2%80%98Publish%20App%E2%80%99%20at%20the%20bottom%20left%20navigation.%20Going%20back%20to%20the%20code%2C%20replace%20%2F%5Ehey%2Fi%20with%20%E2%80%98Greeting%E2%80%99%20as%20shown%20below.%20Now%20your%20bot%20should%20be%20able%20to%20pick%20up%20different%20greetings.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95314iA62B57A8BBEDC244%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-1607554435%22%20id%3D%22toc-hId-1607554435%22%3E%3CB%3E%20Making%20your%20first%20Twitter%20bot%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3ENow%20your%20bot%20will%20start%20responding%20to%20various%20user%20inputs.%20However%2C%20it%20is%20not%20exactly%20useful%20yet.%20To%20make%20it%20do%20something%20useful%2C%20let%E2%80%99s%20change%20it%20into%20a%20twitter%20bot.%20I%20am%20going%20to%20walk%20you%20through%20how%20to%20set%20it%20up%2C%20but%20if%20you%20need%20further%20details%2C%20here%20is%20a%20good%20article%20on%20how%20to%20set%20up%20your%20twitter%20and%20connect%20it%20to%20your%20bot.%3C%2FP%3E%0A%20%20%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmedium.freecodecamp.org%2Fhow-to-build-and-deploy-a-multifunctional-twitter-bot-49e941bb3092%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20https%3A%2F%2Fmedium.freecodecamp.org%2Fhow-to-build-and-deploy-a-multifunctional-twitter-bot-49e941bb3092%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3EAlternatively%2C%20this%20is%20a%20good%20YouTube%20tutorial%20that%20walks%20you%20through%20how%20to%20create%20a%20twitter%20bot.%3C%2FP%3E%0A%20%20%3CP%3E%3CIFRAME%20frameborder%3D%220%22%20height%3D%22315%22%20src%3D%22https%3A%2F%2Fwww.youtube.com%2Fembed%2FGQC2lJIAyzM%22%20width%3D%22560%22%3E%20%3C%2FIFRAME%3E%3C%2FP%3E%0A%20%20%3CP%3EFirst%2C%20we%20want%20to%20register%20our%20bot%20to%20our%20twitter%20account%20so%20that%20the%20bot%20can%20have%20access%20using%20the%20access%20token%20and%20key.%20I%20strongly%20recommend%20you%20get%20a%20new%20Twitter%20account%20for%20development%2C%20so%20that%20if%20anything%20goes%20wrong%2C%20you%20won%E2%80%99t%20lose%20your%20Twitter%20account%20or%20your%20followers.%20Once%20you%E2%80%99ve%20logged%20into%20your%20new%20account%2C%20go%20to%20%3CA%20href%3D%22https%3A%2F%2Fapps.twitter.com%2Fapp%2Fnew%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fapps.twitter.com%2Fapp%2Fnew%20%3C%2FA%3Eand%20fill%20in%20the%20details%20of%20your%20bot.%20A%20website%20URL%20is%20not%20essential%20for%20this.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95315i58FF75C4630C1483%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EOnce%20you%20register%20your%20application%2C%20you%20can%20get%20details%20for%20the%20Consumer%20Key%20(API%20Key)%2C%20Consumer%20Secret%20(API%20Secret)%2C%20Access%20Token%20and%20Access%20Token%20Secret.%20Now%20we%20will%20return%20to%20the%20code%20on%20Azure%20and%20create%20an%20.env%20file%20with%20these%20details%20as%20shown%20below.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95316i8A20305FB4FB2BE5%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ESeparating%20out%20your%20API%20key%20information%20from%20the%20main%20code%20and%20storing%20it%20in%20.env%20is%20good%20practice.%20Otherwise%2C%20your%20account%20will%20be%20at%20risk%20if%20you%20are%20working%20on%20a%20collaborative%20project%20or%20sharing%20your%20code%20on%20GitHub.%20NEVER%20share%20your%20key%20online%2C%20even%20in%20a%20tutorial%20video%20or%20screenshot.%20There%20are%20crawler%20bots%20out%20there%20that%20tries%20to%20steal%20your%20account%20%2F%20API%20keys%20and%20if%20you%20are%20unlucky%20you%20can%20be%20charged%20for%20incredibly%20expensive%20bills.%20In%20case%20you%20want%20to%20upload%20your%20code%20to%20GitHub%20in%20the%20future%2C%20add%20.env%20to%20.gitignore%20file%20so%20that%20it%20wouldn%E2%80%99t%20be%20uploaded.%3C%2FP%3E%0A%20%20%3CP%3EWe%20have%20two%20more%20steps%20%E2%80%93%20first%20to%20read%20in%20the%20key%20information%20from%20.env%20into%20Node.js%2C%20and%20then%20connect%20to%20twitter%20using%20that%20account%20information.%20We%20can%20do%20these%20by%20installing%20node%20modules%20called%20dotenv%20and%20twit.%20Open%20the%20console%20and%20type%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95317iDB71A87FAED9A364%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95318iC66A9843CA8C3DEB%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ENow%20that%20we%20have%20dotenv%2C%20we%20can%20import%20the%20key%20information%20from%20.env%20to%20config.js.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95319i263CE850DDFF20A0%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95320i1117509D360C9F68%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EFinally%2C%20in%20the%20app.js%20file%2C%20set%20up%20twitbot%20(a%20Twit%20object%20that%20carries%20out%20the%20tweeting%20operations)%20configuring%20with%20the%20key%20information.%20Make%20sure%20you%20don%E2%80%99t%20call%20this%20just%20%E2%80%98bot%E2%80%99%20%E2%80%93%20it%20will%20overlap%20with%20the%20%E2%80%98bot%E2%80%99%20variable%20defined%20already.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95321iC937BD4674A2B115%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EBelow%20is%20the%20part%20where%20twitbot%20posts%20a%20tweet.%20We%20can%20determine%20the%20content%20in%20%E2%80%98status%E2%80%99%2C%20which%20I%20set%20to%20%E2%80%98hello%20world!%E2%80%99.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95322iCD31850B3C1C5815%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ELet%E2%80%99s%20append%20this%20to%20the%20response%20to%20%E2%80%98Greeting%E2%80%99%20for%20the%20time%20being%20as%20shown%20below.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95323iD440D51FB3A10AA9%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ENow%20everything%20is%20set%20up.%20Go%20to%20your%20online%20bot%20emulator%20and%20type%20in%20some%20greeting.%20After%20the%20bot%20responds%2C%20check%20your%20twitter%20account%20and%2C%20lo%20and%20behold!%20You%20have%20your%20first%20tweet!%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95324i586B5D3D50CF1087%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--944602526%22%20id%3D%22toc-hId--944602526%22%3E%3CB%3E%20Making%20the%20bot%20tweet%20what%20you%20want%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3ECool%20stuff!%20So%20now%20we%20can%20add%20some%20flexibility%20to%20the%20bot%20and%20make%20it%20tweet%20whatever%20we%20want.%20To%20get%20started%2C%20let%E2%80%99s%20add%20another%20intent%20%E2%80%98Tweet%E2%80%99%20to%20LUIS%20so%20that%20it%20can%20distinguish%20between%20greetings%20and%20tweet%20tasks.%20Create%20an%20intent%20and%20add%20utterances.%20Remember%20to%20re-publish%20your%20changes%20once%20you%E2%80%99ve%20finished.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95325i3FF271BAC8DB9BA6%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ENow%20you%20can%20go%20ahead%20and%20handle%20the%20case%20where%20the%20intent%20matches%20%E2%80%98Tweet%E2%80%99.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95326iD65E286B3A511953%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3EThe%20major%20changes%20I%20have%20made%20in%20the%20code%20is%20this%20bit%20where%20I%20have%20added%20a%20dialog%20that%20is%20called%20by%20beginDialog(%E2%80%98%2Ftweet%E2%80%99).%20This%20sort%20of%20dialog%20structure%20is%20called%20waterfalls%20implementation%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2Fnodejs%2Fbot-builder-nodejs-dialog-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%5BRead%20Documentation%5D%20%3C%2FA%3E.%20In%20the%20dialog%2C%20the%20bot%20asks%20what%20the%20user%20wants%20to%20tweet%20and%20directly%20goes%20ahead%20posting%20it.%20This%20looks%20straight%20forward%2C%20but%20might%20raise%20an%20issue%20if%20we%20want%20to%20quit%20midway%20-%20we%20should%20handle%20this%20case%20in%20the%20next%20section.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95327iCBAD9A65F04C03A2%22%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95328iE96FF60962AC8AE8%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EFinally%20our%20bot%20is%20up%20and%20running%2C%20and%20can%20change%20what%20it%20tweets%20according%20to%20the%20user%E2%80%99s%20order.%20Notice%20that%20the%20initial%20conversation%20starter%20has%20been%20altered%20to%20indicate%20what%20the%20bot%20is%20about.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95329i92AC16851ED0432D%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EGo%20on%20to%20your%20twitter%20account%20and%20make%20sure%20it%E2%80%99s%20working!%20If%20you%20are%20having%20problems%20with%20your%20tweet%2C%20maybe%20it%20is%20because%20you%20are%20posting%20the%20same%20sentence%20over%20and%20over%20again.%20Twitter%20doesn%E2%80%99t%20seem%20to%20allow%20multiple%20identical%20tweets.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95330i41B99582A22616BF%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-798207809%22%20id%3D%22toc-hId-798207809%22%3E%3CB%3E%20The%20problem%20with%20quitting%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3ESo%20far%20so%20good.%20But%20what%20if%20we%20change%20our%20mind%20half-way%20through%20the%20action%3F%20Consider%20this%20situation%20below%3A%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95331i36BB5B486F044263%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EIn%20this%20case%20we%20want%20the%20bot%20to%20be%20clever%20enough%20to%20detect%20that%20the%20user%20has%20changed%20their%20mind%20and%20wants%20to%20quit.%20Although%20we%20can%20try%20creating%20an%20additional%20intent%20for%20cancellation%2C%20there%20is%20a%20straightforward%20way%20of%20handling%20user%20action%2C%20and%20moreover%2C%20call%20out%20a%20predefined%20function%20to%20cancel%20an%20action.%20Here%20we%20are%20going%20to%20use%20cancelAction%2C%20but%20other%20actions%20such%20as%20triggerAction%20and%20reload%20Action%20could%20be%20also%20handy.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2Fnodejs%2Fbot-builder-nodejs-dialog-actions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20%5BRead%20Documentation%5D%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95332iB04AE9D0FB522E86%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95333i803115E2827B512E%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EAs%20it%20could%20be%20seen%2C%20this%20interface%20provides%20the%20opportunity%20for%20users%20to%20quit%2C%20and%20moreover%2C%20cancel%20the%20quit%20operation%20and%20go%20back%20to%20where%20the%20bot%20was%20interrupted.%20Determining%20every%20possible%20flow%20of%20conversation%20that%20can%20occur%2C%20and%20handling%20cases%20that%20doesn%E2%80%99t%20follow%20the%20designed%20conversation%20pattern%20is%20crucial%20in%20bot%20building%2C%20since%20it%20doesn%E2%80%99t%20have%20a%20navigation%20system%20of%20back%20and%20forward%20unlike%20web%20browsers.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2Fbot-design-navigation%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EThis%20documentation%20%3C%2FA%3Ecan%20give%20you%20further%20insight%20into%20this%20topic.%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--1753949152%22%20id%3D%22toc-hId--1753949152%22%3E%3CB%3E%20Tweet%20from%20Facebook%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3EFinally%2C%20let%E2%80%99s%20learn%20about%20how%20to%20use%20channels.%20By%20going%20to%20the%20%E2%80%98Channels%E2%80%99%20tab%2C%20you%20can%20see%20many%20options%20where%20you%20can%20use%20your%20bot.%20Slack%20is%20quite%20a%20common%20place%20to%20use%20bots%2C%20but%20today%20let%E2%80%99s%20have%20our%20bot%20working%20on%20Facebook%20messenger.%20To%20get%20started%20with%2C%20click%20the%20Facebook%20messenger%20icon.%20The%20documentation%20walks%20you%20through%20step%20by%20step.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2Fchannel-connect-facebook%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20%5BRead%20Documentation%5D%20%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95334iC27597FF97C21226%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ESince%20the%20bot%20is%20associated%20to%20a%20Facebook%20page%20rather%20than%20a%20user%20account%20and%20is%20intended%20to%20be%20used%20as%20an%20autoreply%20bot%20for%20an%20organisation%2C%20we%E2%80%99ll%20first%20have%20to%20create%20a%20new%20Facebook%20page%20and%20connect%20the%20bot%20to%20it.%3C%2FP%3E%0A%20%20%3CP%3E1.%20Create%20a%20new%20Facebook%20page%20from%20%3CA%20href%3D%22https%3A%2F%2Fwww.facebook.com%2Fbookmarks%2Fpages%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.facebook.com%2Fbookmarks%2Fpages%20%3C%2FA%3E.%3C%2FP%3E%0A%20%20%3CP%3E2.%20Create%20a%20new%20Facebook%20App%20from%20%3CA%20href%3D%22https%3A%2F%2Fdevelopers.facebook.com%2Fquickstarts%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdevelopers.facebook.com%2Fquickstarts%20%3C%2FA%3E.%3C%2FP%3E%0A%20%20%3CP%3E3.%20Select%20Messenger%20as%20your%20product%20and%20generate%20a%20Page%20Access%20Token.%3C%2FP%3E%0A%20%20%3CP%3E4.%20Copy%20and%20paste%20your%20credentials%20from%20all%20the%20above%20into%20the%20Bot%20Framework%20Portal.%3C%2FP%3E%0A%20%20%3CP%3E5.%20Click%20%E2%80%98Set%20up%20Webhooks%E2%80%99%20on%20the%20Messenger%20setup%20page.%3C%2FP%3E%0A%20%20%3CP%3E6.%20Copy%20and%20paste%20the%20webhook%20callback%20URL%20and%20verify%20token%20from%20the%20portal%20into%20the%20webhook%20form.%3C%2FP%3E%0A%20%20%3CP%3E7.%20Save%20details.%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95335iD74E18DD2C6D1EC3%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3ENow%20let%E2%80%99s%20go%20back%20to%20the%20Facebook%20page%20we%20have%20created%20and%20send%20a%20message%2C%20and%20lo%20and%20behold!%20The%20Facebook%20page%20gives%20automated%20replies!%3C%2FP%3E%0A%20%20%3CP%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F95336iE91D8D97D463B6A4%22%20%2F%3E%3C%2FP%3E%0A%20%20%3CP%3EFor%20obvious%20reasons%2C%20you%20don%E2%80%99t%20want%20all%20the%20Facebook%20users%20in%20the%20world%20to%20be%20able%20to%20tweet%20on%20your%20Twitter%20account%2C%20so%20make%20sure%20you%20delete%20the%20newly%20created%20Facebook%20App%20once%20you%E2%80%99re%20done%20with%20it.%20Although%20a%20Twitter%20bot%20was%20probably%20not%20the%20best%20example%20of%20bots%20that%20can%20be%20embedded%20on%20Facebook%20messenger%2C%20it%20demonstrates%20how%20bots%20can%20be%20implemented%20and%20be%20useful%20when%20you%20are%20dealing%20with%20a%20ton%20of%20customers.%20Now%2C%20you%20can%20start%20to%20visualise%20these%20bots%20actually%20interacting%20with%20humans%2C%20and%20more%20importantly%2C%20perceived%20as%20human%20operators%20across%20the%20screen.%20Therefore%20it%20is%20highly%20important%20that%20the%20bots%20can%20provide%20essential%20services%20with%20a%20well-designed%20communication%20flow%20and%20without%20the%20intervention%20of%20humans.%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId--11138817%22%20id%3D%22toc-hId--11138817%22%3E%3CB%3E%20Build%20your%20own%20bot%20with%20Microsoft%20Bot%20Framework%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3ENow%20is%20time%20for%20you%20to%20create%20your%20own%20bot.%20If%20you%20are%20not%20making%20it%20public%2C%20it%20could%20be%20a%20personal%20planner%20and%20secretary.%20If%20you%20are%20developing%20for%20your%20enterprise%20or%20an%20online%20service%2C%20it%20could%20be%20easily%20made%20into%20a%20receptionist%2C%20companion%2C%20gaming%20opponent%2C%20media%20source%2C%20image%20processing%20service%20or%20more.%20Interface%20matters%20because%20it%20is%20automated%2C%20but%20once%20you%20get%20over%20that%20barrier%2C%20there%20are%20many%20opportunities%20out%20there%20since%20it%20could%20be%20built%20in%20to%20commonly%20used%20services%20such%20as%20Facebook%20messenger%20and%20Skype%2C%20so%20that%20it%20would%20be%20easy%20to%20subscribe.%3C%2FP%3E%0A%20%20%3CP%3EAnd%20with%20that%2C%20we%20have%20come%20to%20the%20end%20of%20this%20article.%20Thank%20you%20very%20much%20for%20reading%20through%20all%20the%20way.%3C%2FP%3E%0A%20%20%3CH3%20id%3D%22toc-hId-1016510229%22%20id%3D%22toc-hId-1016510229%22%3E%3CB%3E%20Resources%20and%20further%20information%20%3C%2FB%3E%3C%2FH3%3E%0A%20%20%3CP%3EMicrosoft%20Bot%20Framework%20Documentation%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fbot-framework%2F%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3EVideo%20tutorial%20of%20building%20a%20LUIS%20chat%20bot%3C%2FP%3E%0A%20%20%3CP%3E%3CIFRAME%20frameborder%3D%220%22%20height%3D%22540%22%20src%3D%22https%3A%2F%2Fchannel9.msdn.com%2FBlogs%2FMVP-Azure%2Fbuild-a-chatbot-with-azure-bot-service%2Fplayer%22%20width%3D%22960%22%3E%20%3C%2FIFRAME%3E%3C%2FP%3E%0A%20%20%3CP%3EExample%20of%20playing%20hangman%20on%20a%20Microsoft%20Bot%20%3CA%20href%3D%22http%3A%2F%2Fwww.codeshare.co.uk%2Fblog%2Fhow-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft-bot-framework%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttp%3A%2F%2Fwww.codeshare.co.uk%2Fblog%2Fhow-to-create-a-hangman-chat-bot-game-in-nodejs-using-microsoft-bot-framework%2F%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3EExample%20of%20building%20a%20Twitter%20bot%20%3CA%20href%3D%22https%3A%2F%2Fmedium.freecodecamp.org%2Fhow-to-build-and-deploy-a-multifunctional-twitter-bot-49e941bb3092%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmedium.freecodecamp.org%2Fhow-to-build-and-deploy-a-multifunctional-twitter-bot-49e941bb3092%3C%2FA%3E%3C%2FP%3E%0A%20%20%3CP%3EYouTube%20tutorial%20on%20how%20to%20create%20a%20Twitter%20bot%20%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGQC2lJIAyzM%26amp%3Blist%3DPLRqwX-V7Uu6atTSxoRiVnSuOn6JHnq2yV%26amp%3Bindex%3D3%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGQC2lJIAyzM%26amp%3Blist%3DPLRqwX-V7Uu6atTSxoRiVnSuOn6JHnq2yV%26amp%3Bindex%3D3%3C%2FA%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-379839%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Oct%2028%2C%202017%20Guest%20blog%20by%20Shu%20Ishida%20Microsoft%20Student%20Partner%20at%20Oxford%20University%20About%20meMy%20name%20is%20Shu%20Ishida%2C%20and%20I%20am%20a%20third%20year%20engineering%20student%20at%20the%20University%20of%20Oxford.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-379839%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eacademic%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EBot%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EBot%20Framework%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Efaculty%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Emicrosoft%20student%20partner%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Enode%20js%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eoxford%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Esoftware%20engineering%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Estudent%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Estudents%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Mar 21 2019 09:23 AM
Updated by: