Cloud OnAir Building Chatbots with Dialogflow

Show video

Welcome. To cloud on air live webinars, from Google cloud we're, hosting webinars every, Tuesday, my, name is Whitley Tallmadge and today I will be talking about dialog, flow you, can ask questions anytime, on the platform, and we have Googlers on standby, to answer, them let's, get started. I'm. Whitley. Tallmadge I am a customer engineer, for Google cloud and I, will be talking about how to build conversational. Experiences, with dialog flow using, Google cloud platform today. So. I'll be providing a brief overview of dialogue flow Google's conversation. Engine and a preview of our upcoming Coursera. Course called building conversational. Experiences. With dialog flow I'll, demonstrate some of the basic features of dialogue flow and a few Google cloud platform products. Using the quick labs platform, I'll. Go over the free training offers we have available as part of this session to get you hands-on with dialogue flow and as. I mentioned we'll also be answering the questions that you submit. In. This. Course we take a look at how to build engaging, conversational. Experiences. Using dialogue, flow we. Start off by using dialogue, flows building blocks to create an agent step by step by defining, user intents, extracting. Potential, entities, maintaining. The context, of the conversation, as well, as being able to perform fulfillment. Actions outside of dialogue flow for. Example storing. Data pieces from the conversation, into a database we. Have plenty of demos that walk you through each of these steps and then, have you do the same through a series of hands-on, labs at the end of which you get to test out your chatbot. Next. We discuss a number of themes that are important, when you want to take your chat bot to production like. Being able to add basic, authentication. Customizing. Your chat BOTS UI deploying. Fulfillment, code on scaleable serverless architecture. And leveraging. Existing sources. To automate, parts of the agent building process, towards. The end of the course we also talk about how to integrate, your chat bot into other channels or.

Surfaces, Like, the Google assistant, and we also touch on a few other additional, functionalities. That can make your agents smarter and even more engaging. To. Achieve the learning objectives, discussed, the, building conversational. Experiences, with dialog flow course consists, of these five modules, building. Conversational, experiences, with dialog flow defining. Intents and entities, maintaining. Context, in taking action taking. Your chatbot to production and additional. Functionality. Conversational. Experience, is the descriptive, comprehensive. Name for, a new class of solutions that include chatbots. Conversational. Apps and other similar, terms. Dialog. Flow is a tool that can help you build smart, conversational. Agents dialog. Flow is an end-to-end developer. Platform for building natural, and rich conversational. Experiences. At its, core dialog, flow is a powerful, natural language, understanding engine. To, process, and understand, natural language input, in other. Words it lets you easily achieve, a conversational. User experience, by, handling, the natural language understanding for, you using. Dialogue flow you, can build conversational. Experience, as faster, engage. End users more efficiently, and maximize. Reach across geographies, and platforms. By. Leveraging these capabilities, and what the developer, provides, as input, training, data dialogue, flow creates unique algorithms, for each specific conversational. Agent under the hood which, continuously, learns, and is tweaked for you as more and more users engage, with your agent. Some. Conversational. Agents exist for very specific, very simple, use cases with, few intents, and minimal, dependency, on communicating. With back-end systems, or knowledge bases while. Some have multiple intents, dealing, with more complex, domains, and backends but. Typically the workflow to get your conversational. Agent up and running maps out to these three phases design. What to build develop. How to build and deploy, how, to deliver. Keep. The style guide in mind as you design your agents, responses, for. The best user experience you probably don't want your agent to sound too formal, or robotic, for. Example to, make your agent more REM of, actual human conversation, you might have it say something like does that sound good rather, than something like if you feel you have reached this message, in error.

Creating. Your dialogue flow agent all starts, with intents. Intents. Are the trunk of the dialogue tree they. Connect all of the branches, intents, determine, where a conversation. Will go and what an agent should do in. Communication. Intents, can be thought of as the route verbs in the conversation, such, as one in coffee translating, to acquiring, a beverage. Sometimes. The intents are not explicit, and instead, are inferred, from the, entire composition, of a phrase. You. Want to map your intense to the goal of your application, if you, are a helpdesk application. Then your intents might include opening, and filing a ticket updating. A ticket and closing a ticket but. Your application, may also need to access, and update a user's, account information, branch. Over to a live technician. And even, pass along a quality, assurance survey. Even. Affirmation, answering, yes or no is an intent. Intense, evolved, as your understanding, of the users needs evolves. And you may find yourself doubling, or tripling your intense beyond. Your initial set of intents to. Make. The task of defining intents, easier some rules of thumb can be applied first. Identify. The verbs, in the dialogue people will have with your agent doing. That will allow your agent to have its actions, mapped to, needs from the user, another. Possible, scenario is, to identify where, the application. Should branch logic, here. Are some examples, -. Mocha coffees, please how. Many calories in a slice I want. A pizza or even I really need some caffeine. Once. You have chosen your intents, you, need to train your agent, to recognize, them this, can be done with the use of training, phrases, the. Training phrases for each intent, should be representative, of how users will say the intent it is, always a good idea to, add variations. To the grammatical construction, of a request such. As passive, versus active voices. Or questions, versus statements, this, will help represent the variety, of ways a user might say an intent. When. Creating an intent the more training phrases, you can think of the better later. We will discuss best, practices for, writing your training phrases. Entities. Help you get to the specifics, of an interaction in dialog. The entities, are the nouns or quantifiers, found, through the conversation, such as a person's, name the, food in a review of a crews specific. Numbers, or dates just to name a few. When. You are creating an entity and you identify, that the entity contains attributes, that you need to map to one. Way is to use composite, entities. For. Our ordering pizza example, let's, say that we want to create an intent for ordering pizza a pizza could, be of type regular. Or thin, crust regular. And thin crust in this case both our entries, in an entity called pizza. System. Entities, are pre-built entities, provided, by dialogue flow in order to facilitate handling, the most popular, concepts, use. One of the system entities, to represent, date and time for. Example or others, such as addresses, currency. Units. Numbers, and many others. Contexts. Allow the agent, to keep track of where the user is at in the conversation, in the. Context, of dialogue flow there, are also a means for an application, to store and access variables, mentioned, in the dialog in, this. Example of ordering pizza, if the, senate's actually, make that two hours is set out of context, there is no way that the agent can know that the user is referring, to the pickup time for the pizza order the. Context, in this conversation ensures, that your dialogue flow agent knows, that, this request is related, to the Pizza ordering intent. For. The pizza example, we built our agent step by step starting, with creating, intents, followed. By entities and then contexts, all done within the dialog flow UI. Sometimes. You may already have existing sources. That you can connects tracked entities from for.

Instance A call center playbook, or an, FAQ, document. So we look at ways to leverage this data when building our agent. Sometimes. All you need is a conversation, interface, to, surface answers from the existing, back-end systems, and capabilities and so. We look at deploying your back-end code as a web hook on App Engine we. Also look at how to customize your agents, UI so. That you can have your own branding, this, is where we deploy a custom, front-end on App Engine we. Also want to secure our web hooks so it only makes off entik ated calls to the back-end services. In. Our. Course we, start with a Pizza ordering example, where the backend is meant to store pizza orders so, you're mainly writing, into the database then. We move on to an HR manual example, where the backend is a knowledge base where a query will look up for. Definitions, and send it back to the user so you're mainly reading from the database. So. How do we build this knowledge base in the first place we. Use an employee handbook which. Is an HR manual document, with topic, keywords and definitions, so. All we need to do is leverage that to build our knowledge base in the. Hands-on lab we, use cloud data lab notebooks, to. Quickly run Python scripts, to extract topics, from the sample HR manual then. Push them into a data store entity, using the cloud datastore API. Next. We use Google's, natural, language API to form, synonyms, of these topics and add them to datastore. Finally. We call the dialogue flow API to, then populate, your dialogue, flow agents entity list with these topics from the datastore entity the. Demo that follows will walk you through the steps covered so far. So. I will pull up our demo screen. And I, will maximize, it. So. I've already done some of the setup work for the demo that you would do in the lab so, I've already created a data Lab instance, this is actually a compute, engine VM that hosts, our data lab notebooks, so that's already up and running so, now we can preview, our data, lab notebooks so I'll go to web preview and, change. The port to 80 81. Change. In preview, and. I. Already cloned, the data lab notebooks that we will need to use so. The first one that we're going to look at is process. Handbook so. I'll click that. And. I'll. Do clear all cells to make sure that we have a fresh start and then. I can execute these cells one by one. So. We'll make sure that we have the right version, of cloud.

Datastore. Then. I'm going to make sure that that new version gets. Restarted. And. Now. We can look at our code for processing. The handbook so I'm going to run these cells one by one so. I'm importing the datastore library. And. Then. This is what will actually extract. Our, topics. And their definitions, from this HR manual text, file so, I'll run this block of code and, we, can see that it's extracting. The different, headings which are our topics from that text, file. Now. We're going to do, basically. The same thing with the synonyms, notebook, so this will just generate synonyms. For all of the topics, that we just extracted, so. I'm opening the process, synonyms, notebook. Going. To clear this one and. Do. The same thing so we'll make sure that we have the. Correct version of datastore. And, then, reset the session to make sure that that takes effect. And. Now. We. Will import the NLT kay library, to, generate, our synonyms. And. We'll import datastore, in this notebook as well. So. This is going to look at the data store entities, that we already have named under topic, and it's going to use the in ltk, library to generate synonyms, for those. Entities, so. We'll run this block of code. And. There. It goes, generating, synonyms, for all of our topics, so. This might take a second. And. In, data lab the way that we know that a cell is finished running is this side. Bar will turn from gray to blue so that will let us know that it's completely. Finished with that block of code so. We'll have to wait for that. Looks, like we're getting a lot of synonyms. For. These topics. Should. Be almost done. Towards. The end of the alphabet now. And. Our. Sidebar. There turned to blue so that one's finished. So. Now we will actually call the Google natural, language API to evaluate. The salience, of each of these topic. Keywords. To. Determine how relevant. They are to the overall. Context. So. We'll run each of these cells and. This. Is what will actually push, all of the synonyms that we just generated into, datastore, as well. So, we can see this is going through the different topics, and evaluating. Their salience, in the, overall context. Of the, document and, so that cell is finished so, now we can look at datastore and see how those got pushed, into our datastore. Kinds. So. I can go to datastore, in the GCP. Console, and. I. See we should have two kinds, so, we have topic, this. Is all of the actual. Keywords. That were extracted, from the HR, manual and then, we can switch over to synonym, these. Are all of the synonyms that were generated, from those topics, and also pushed to datastore, so. Those are all set. So. Now I can go to the dialogue flow console, itself, and I've. Already created my agent, and when, I created, it I imported.

An Existing, project so, I imported, this same project, that I have my datastore. Topics. And synonyms in so that they're matched up and connected, and. So. Now that that is set up I can go back to my data lab notebooks and look at this dialogue flow notebook. And. I'm, going to clear this one just to make sure it's fresh, and, we. Will. Run. This cell to. Install, the, correct version of dialogue flow. And. Then. I'm going just for a good measure I'm going to do a restart, to make sure that that gets incorporated, into, this notebook and then we can pick back up here so. This dialogue, flow notebook will actually, take, all of the entities, that we created, in datastore, and import, them into our dialogue flow agent. Okay. So that's done so now I can switch back to the dialogue, flow console, and, I. Can click on entities, and create. One so I'm going to name it topic. I'll. Uncheck define, synonyms, because we did that in our notebook and I'll. Just enter a test value for, now as a placeholder, so. I'll hit save so that it creates that entity. Actually. I may. Need to run that dialogue flow notebook again since, I had created the entity yet so. Let me restart, that. So. We'll do clear and I should, be able to just pick up here. Okay, let's check it now and see if that worked so. When, you refresh, here, and. There. They are so, that dialogue flow notebook actually, took all of these entities that we had in datastore and they're. Synonyms and put them in our matching, topic, entity, and dialogue, flow. So. Now we're going to look at intense, so. I can create a new intent and. I'm. Just going to name this one topic as well. And. I. Need to allow. This. Intent, to be able to be looked up so, I'm going to create an action, under the intent and I'm just going to call it lookup and. I'll. Name the parameter, name topic, and then. I'm going to connect it to that topic, entity that we created so it, shows up there and then. The value, will also be topic, and. For. A fulfillment, I am. Going to go ahead and enable fulfillment. Because. We're going to enable, a webhook call for this intent. So. All of that is set up so I'll save that and, now, I'll. Add a couple, of trading phrases, so, these are what we talked about in the presentation so this, is what we. Can start with just a few so that the. Agent, can kind of know how. This, topic, entity, will be called, from, the topic intent so, we can just give it one or two for now so that it gets, a quick idea so, I'm going to say tell me about annual salary. And. Before. I exit, out of that I'm. Going to highlight the. Term annual, salary, so. I just click and drag there. And. I'm. Going to make sure it knows that this is calling, my topic, entity. So. I'll hit enter and then I'll add one more I'll do what is discipline, discipline, is another term. From. Our HR. Manual and I'll do the same thing with that topic entity, so that should be good to start with so. I can hit save. And. You. Can see this dialogue. Here popping up saying agent training, started, so we'll wait for that to finish. It. Should give us a completed, message when it's done. There. We go agent training completed okay. So now I can switch back to my presentation since, we have all of that groundwork. Set up. Okay. So this is what we just did. So. Now we can talk about App Engine App, Engine, is Google's fully managed, server list platform, as a service product that allows you to build highly scalable, applications, the. Underlying infrastructure, is taken care of for you with. Support for multiple programming, languages, App Engine enables, developers. To focus on developing their applications, without needing, to worry about infrastructure. Concerns. You. Can deploy your web hook to App Engine by running the g-cloud, app deploy, command, App Engine will find your app dot yamo file for, your service, read, any additional, parameters, that you set such, as version number, runtime.

And Service name and deploy, your application, to. Run your app locally before, pushing it to production you can run the dev app server dot, PI command, for example to test your Python, app from cloud shell. So. In our HR, chatbot example, the, web hook is called by the dialog flow agents, fulfillment component, to get answers from datastore once, a topic entity, is matched the. Webhook code uses, information, from the HTTP. POST, request sent. By your agent to look up the keyword and match it with the topic entity in cloud datastore, the. Web hook will then return, a response, back to the user which, contains the definition, of the keyword passed in the request so. We'll go back to the demos and take a quick look at the webhook code. So. I will pull back up my. Demo. Tab. Okay. And, so. Now the notebook, that will run is our. Webhook notebook. So. I can open this one up. And. We'll. Clear it just. To be safe and. Now we can run, these cells one by one. Okay. And, then. This is what we actually need, to create a web hook for, our fulfillment. Component. Of our dialog flow agent so. One way to do this is from. This data lab notebook we can click this drop-down next to notebook and we could do something like convert, to Python, so, that would convert everything, in this data lab notebook into an actual, executable. Python, script, and then, we could deploy that to App Engine so. That's exactly what we did in this. Project. So. If I open a new tab in my cloud show. And. I. Can look. For. That. Python. Script. Okay. So I called it mean dot pie. Actually. I can look at this from the code editor because, that will be. A better way to see. It. So. I'm opening the code editor from, cloud shell and, I. Have my folder I already, created. So. I'll go into webhook, and. We, can look at the main dot pie file so. This is the exact same thing that was in our data, lab notebook we just saw but it's just, created. As a Python script so. This is how we can deploy this Python. App into App Engine. So. Let. Me go to App Engine. So. We can see the dashboard. And. We. Need to initialize, App Engine. Really. Quick, so. We will. Let. Me do select, an existing project. So. I'll choose this one. Confirm. Project. Next. So. We don't need to do this tutorial so I'm going to cancel out of it what that should have initialized, our App, Engine setup so. Now we can actually deploy, that. Webhook. On. To App Engine. So. Let me take a look at the App DMO, this is what will deploy. This service, into App Engine. So. For now I'm going to remove this service name because, our first service. On App Engine needs to be the default so, we will take, out that named service name for now, and. Let me make sure I'm still in the right directory, okay so now I can do g-cloud, app deploy. So. This is going to deploy all of our webhook code we just saw on App Engine. Shouldn't, take too long. So, app engine is automatically. Taking care of a lot of stuff for us like updating. The service, and setting, traffic split for the service automatically, so. Now it has finished deploying so, I'll switch back to the App Engine dashboard. Let. Me click on services. I'll. Do it refresh, and see if that hopes. Okay. So, now we've got it so, at, this point we don't have a UI for our, service, so. When we click this we won't see anything, yet it's. Just going to say not found but we can grab this URL and, we. Can switch back over to the dialog flow console. And. We'll go back to the fulfillment. So. Up here I'm going to enable, web hook and then. I'm going to paste that URL, in. An add, web. Hook at the end and, then.

We Had already set the username, and password for, basic. Off in that web hook code so I will enter that here, and. Then. I can scroll down and hit save. So. Now we should have a, deployed. Web hook, that's. Hosted, on App Engine that our dialogue flow agent is calling, so. Let me try tell, me about annual. Salary, which was one of our training phrases, and, we. See the default response so this is the response that is from, that. HR, manual text, file that, we extracted. All of the topics and definitions, out of into datastore, and then push them into our dialog flow agent and it. Is calling. A hosted, web hook on App Engine that is secured. With basic, auth on the backend. So. That is the idea. Let. Me switch back to our presentation. Okay. So. A quick recap of some things we just did we, added HTTP. Basic authentication, to, our web hooks to prevent unauthorized access and, so this ensures that unauthorized callers. Can't call our web hook and in, the web hook code we, implemented, flasks security, framework for HTTP, basic authentication, so. This requires off method, requires authentication, to, access our app and, we. Had a check off method, which validates the submitted username, and password, so, these, username. And password values in this code snippet are what we used in the dialogue flow console, and, then. The authenticate, method sends, a 401, response, if authentication fails, and so, we also had. To add this requires, a decorator. To our handle, method to ensure that the method validates, those authorization. Credentials. So. Besides, having a customized. Front-end, dialogue flow agents, can also be enabled in multiple, channels and surfaces, from, text to voice to phone so. Beyond the web chat core feature which we saw when we tested it out in the console, you can use the built-in feature for deploying your agent onto any Google assistant enabled device such, as the assistant, mobile app or a Google home device so. You can also easily integrate, your dialogue flow agent into other third-party apps like Facebook Messenger Twitter, and slack and there, are also import, and export capabilities. For easily importing, your dialogue flow agent into Amazon, Alexa, or Microsoft, Cortana compatible, files. So. While dialogue flow gives you several surface, options, from the dialogue flow console, web interface, to Google, assistant to Google home devices these, all rely, on the actions, SDK, for creating. The actions, that form your agent this, allows you to seamlessly move between surfaces. For the same agent no matter which platform or functionality, you need. So. A quick recap of our course and some things that we just previewed. Conversation. Is the new UI and it's very quickly changing, the way that users communicate, with businesses, employers, and other, we, looked at some of the challenges when creating conversational. Agents that can handle natural, language input and discussed how dialogue flow can address some of these concerns and, through, the life of a conversation, we looked at some of the essential, elements that you want your chat bot to have like intense, entities. Context. And fulfillment, you also, learned how to define, intents, and entities using the dialogue flow UI and in. The HR chat bot example, we leveraged an existing, data source to extract entities from your. Dialogue flow agent and we. Learned. That being able to maintain context. Is important, for the agent to be able to control the flow and minimize repetition. And improve overall satisfaction and, with, fulfilment you can add functionality, like connecting, to back-end systems. We. Then saw the coming, together of GCP, products, to productionize, your agent like deploying your webhook on App Engine so it can scale building. A knowledge base in cloud datastore by leveraging the HR manual and using. The natural language API to generate, synonyms, and adding, security and then. Towards the end we, talked about how you can easily integrate your agent into other surfaces, like the Google assistant and, demonstrated. Some of the newer additional, features and. One. Last thing before we go to Q&A, remember. To claim your free month of Google cloud specializations. On Coursera, for any of our specialization. Courses including. Data engineering, architecting. And developing. Applications, and a lot more by, going to this link or, scanning this QR, code and look. For our full-length building, conversational, experiences. With dialog flow course launching, on Coursera, soon, so. We are ready for Q&A, stay. Tuned for live Q&A we'll be back in less than a minute.

You. Okay. So we are back with some questions from the audience for, dialogue, flow and everything, that we just talked about so. Let's look at the first question, we, use dotnet, or any other development. Platform, can, I use dialog flow from our environment so. The answer to that one is yes so. The, example, that I showed and, that we we talked about in the Coursera, course is all using Python, but that is definitely not the only option, there, are a ton, of different dialogue, flow fulfillment. Libraries, that are available and, a lot of them are already, written and ready to use on dialogue, flows github, page so. We, have dotnet. Nodejs. Java. Python. C-sharp. And Ruby. I think those, are the ones I don't believe I've left any out but, the answer is yes definitely, and then of course another option, would also be just to use the REST API calls, to, use. The dialogue flow interface. Okay. So second, question we, have developed, our own specialized. Speech to text or use another third, parties, can, I use it with dialogue flow so. The answer to that one is also yes because, of that rest, API integration. You, can integrate. Your own, speech, to text API with dialogue flow speech to text API so. That would would definitely, work. So. I, guess. We. Didn't get any other questions. So. I will, go ahead and close, us out so, I think that's it for our dialogue flow course, stay. Tuned for the next session, CET V machine, learning 101, the, what why and how of ml thank, you. You. You.

2018-12-21

Show video