Back to Blog

How to Build a ChatBot With DialogFlow And Google Cloud Platform

Tellephant

In this video, the Google Cloud Team will be building their own chatbot with Dialogflow and Google Cloud Platform. Priyanka will deep dive into the workings of Dialogflow, how it works, and how you can build your own chatbot to respond to support tickets.

What's important to note is that Tellephant and Aiyo Labs are part of the Google Cloud for StartUps program and can help your business get on Google Business Messages live and running in no time integrated with your own personalized chatbot.

A full transcript of the video is below. Enjoy!

How To Build a ChatBot With DialogFlow And Google Cloud Platform

JONATHAN CHAM: All right, welcome to GCP Online Meetup Number 32 I'm Jonathan Cham. I'm your host today. Today, we have a very special guest, Priyanka Vergadia. How are you? 

PRIYANKA VERGADIA: I'm good, thank you. 

JONATHAN CHAM: And one thing I just found out, you've only been here for, what? 

PRIYANKA VERGADIA: Three months. 

JONATHAN CHAM: Wow, and now you're the expert at chatbots? That deserves a fist bump right here. 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: That's good. 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: That's really impressive. So yeah, Priyanka's been around, you know, for only a couple of months, but she's been telling us all about chatbots, and how chatbots have been improving and automating a lot of the activities for her customers, so tell us a little more. 

PRIYANKA VERGADIA: Yeah, sure, so I am Customer Engineer here at Google. So just a little introduction about myself, I do have some background in IVRs and technologies like Interactive Voice Response. And that's why chatbots have a special place in my heart. 

JONATHAN CHAM: There you go. 

PRIYANKA VERGADIA: So as soon as I joined Google, I realized that we acquired this company called API.AI, which we have renamed to DialogFlow now. And I got my hands around it. And my customers were talking about how we can improve their experience, so I just got hands down working on some customer-use cases. And I realized, this could be very helpful to do as a live session for some of our online folks as well. So that's where-- that's why we are doing this today. Please, do send us questions so we can answer them as they come in. 

JONATHAN CHAM: Yup, so we'll be answering your questions. And just one thing that Priyanka mentioned is about the user experience. I've actually worked with a lot of customers who say, I mean, they want to, you know, attend to customer needs very quickly. I think we're living in a digital age where we expect answers right away, like, hey, what's my shipping confirmation, what's my flight status. They want it right now. And chatbots will be able to give you that, kind of, immediate, and the sense of urgency that customers desire and want. 

PRIYANKA VERGADIA: And also to extend to that point, a lot of my customers, like, how does everybody and every customer can relate to them, because everyone has a help desk. And everyone gets those calls around how to-- how do I reset my password or how do I submit a ticket? And they don't want to talk to anybody. So from the user perspective, they don't want to talk to anybody. And from the company's perspective, they don't want to waste money on handling those types of monotonous calls, so I think, for those reasons as well, chatbot is very good. 

JONATHAN CHAM: Yeah, if someone had talked to me about resetting passwords every time-- 

PRIYANKA VERGADIA: Exactly-- 

JONATHAN CHAM: --they would-- 

PRIYANKA VERGADIA: Right? 

JONATHAN CHAM: --hate me. Yeah, well that's a good segue into what you're doing, which is a ticketing system. 

PRIYANKA VERGADIA: Yep. All right, so let's just dive right in. I don't have a lot of slides. All I have is to show you a demo and then how that demo actually works behind the scenes, so that's all that is on the agenda. And then you're obviously always welcome to pose questions. We'll handle them as they come in and also towards the end. So without further ado, let's get into the demo. 

JONATHAN CHAM: I like it. 

PRIYANKA VERGADIA: So this is that helpdesk demo that I was talking about. You could actually integrate it with your web chat interface or your mobile website interface, put it in there. You could also put it in Google Home as an app-- as an action. And then you can also use the same chatbot that you built in DialogFlow and put it into your assistant as well. So it's like one time effort, but you can broadly distribute it into all the different channels. You could use Facebook as well for-- if you interface with your customers over Facebook. 

JONATHAN CHAM: So just for some of the viewers, so that they don't feel intimidated, I mean, you don't actually have to do any machine learning. I mean, you're not doing any mathematical algorithms and things like that to do this. 

PRIYANKA VERGADIA: I'm glad you asked that question. No, you're not. And I'm going to show you in DialogFlow, it automatically learns, so all you're doing is basically providing it a couple of different utterances of what a user can say. And then the machine-- the software will basically learn on its own over time as to what requests it gets. And then it modifies itself over time. 

JONATHAN CHAM: Go it. 

PRIYANKA VERGADIA: There is also a training component to it, so you can train it with the request and response that you could get. 

JONATHAN CHAM: Great, I guess we'll walk through that in a little bit. 

PRIYANKA VERGADIA: Yep. All right, so let's try to test this thing. I would like to submit a ticket. And then it should respond back saying, all right, give me your name so I can put your ticket in. And then I can say, all right, my name is-- I'm just making up some name. And then it will say, OK, thank you John-- so it's smart enough to understand that this was John-- and then now describe the ticket for me. And then I can say, all right, my phone screen is broken. [INAUDIBLE] And then it should respond back saying, I have logged your ticket in. This is the ticket number. And someone will contact you in 24 hours. And that's all you pretty much need in most cases.

Like, a person on the phone would also just call in and submit a ticket for you. And they won't be personally handling the ticket, right? Somebody else in the queue will be handling the ticket, so the chatbot just did that in, like, five seconds for the customer.

Now you take that. Now you can see what happens behind the scenes. So I have a data store behind the scenes, which is a database, NoSQL database. And it's basically sending that data into the database and saving it. So my phone screen is broken. This is John. This was the ticket number. 

JONATHAN CHAM: What is it using to send it to the data store? 

PRIYANKA VERGADIA: So it uses Cloud Functions to send it to the data store. And in Cloud Functions-- and I have it up here-- it's really not a big code that you write. 

JONATHAN CHAM: Right, it's very simple. 

PRIYANKA VERGADIA: All you're doing is just interfacing with data store and calling the API for the data store. So right here, I'm parsing out that email, phone number. We are not caching the email in this case, because the user didn't give it to us. If they did, we would cache that as well. Well, you would take that, put it in the data store, and then respond back saying I successfully logged your ticket with the ticket, so it's a very simple function that you're writing.

And the reason I'm using Cloud Function here is also because you don't have to set up servers or install them and do all that jazz. All you're doing is you just need a function that can talk to an API, so that-- the Cloud Functions is best for doing that. So all right, we did that in the chat. You could do the same with Google Home or Actions.

Let me just give you a little glimpse of how you would do that with Google Home. I'm using the simulator, which you would use to test out, like, in say, talk to help desk support.

SPEAKER 1: Let's get the test version of Help Desk Support. Hi. How can I help you?

PRIYANKA VERGADIA: Help me reset my password.

SPEAKER 1: No problem. Give me your username and I will send the link to reset your password.

PRIYANKA VERGADIA: All right, so that was what I wanted to show you. Like, you could do the same thing that you were doing from the interface, from chat, also within Google Home.

Now, how was all this built? So let's get into DialogFlow a little bit to understand how this was all built, because I'm sure you want to know that as well. So I'm going to talk about intents and entities in a little bit more detail. I have a slide in there, but it's basically-- in short, intent is basically whatever the user can say, and then what do you do after the user says that, so like, what action do you take and what response do you provide the user? That's an intent.

So I'm going to open one of the intents here so that you can see. You saw that we submitted a ticket. So that's the intent, where a user can say, I want to submit a ticket, I have a problem, I have an issue. They can see all sorts of things to submit a ticket, so now you're capturing them in a bucket that these are all the things that a user can say. And then you're taking an action on it. So in this case, I don't have an entity, because all I want is to capture those things that the user is saying, the problem, the incident, the ticket, and then just give them a static response, which is, OK, sure, I can help you with that. Give me your name. So there's no action that I need to take other than just giving them a static response, so that's why this one's a little bit simple.

When we go into this one, which is the description-- so remember when I asked for the description from the user, like, what is your-- what is the problem that you're facing? They said, my phone screen is broken, my laptop's frozen, or something like that. I am parsing out what type of a problem it is. And that is just by nothing but defining an entity. And that entity, in this case, is an incident type, which I am parsing out and putting in my data store, and saying, OK, these are all the tickets that came for phone problems. And so now I can say, this is my entity, which is incident type. And now it's my variable that I can take an action on. And then I'm not responding to anything here, but i'm asking it to go to a web hook, which is where Cloud Function is written. So when I go into my fulfillment, which is where my web book is defined, this is the URL for the Cloud Function that we saw right here. If I close that, you can see that that's the link to the Cloud Function. And that's what you define in your fulfillment.

You could actually also write the same Cloud Function within the editor. And we just released this two weeks ago, so that's a really cool feature. Now you don't even have to go out of DialogFlow to write a Cloud Function, you can just do it right here in the editor. 

JONATHAN CHAM: Yeah, that's really nice. 

PRIYANKA VERGADIA: So yeah, that's how this was all built. Do you have any more questions? 

JONATHAN CHAM: Yeah, I mean, I think one thing to keep in mind is that you put in a lot of different intents, right? But you don't actually have to put every single combination or permutation of questions that the user is going to ask, right? 

PRIYANKA VERGADIA: Yes. 

JONATHAN CHAM: I mean, that's the whole point of training, so can you talk a little bit about the whole training process? I don't know, you've collected maybe some questions that you get. And at some point maybe, the chatbot didn't understand. And at that point you need to throw that in there and say, hey, this is this. You know, the intent is the same, which is what you're trying to do, but they asked it in a different way. 

PRIYANKA VERGADIA: Yeah, exactly, so I'm really glad you ask that. This is the part-- feature within DialogFlow that's in beta right now, which is training. So the first thing you would do for any machine learning models, is you would try to give it as much training data as possible. So that's what we are trying to do with all the requests, utterances that we put in the intent, but there will be things that you may not be able to catch in there, but those are the things that you can catch in here.

On this screen, I have the training portion of the bot here, where if I click on one of these, I can see that help me reset my password was correctly matched to an intent password reset. I could have found something that did not match my intent. So we could say something, and I can't think of an example, but this could probably-- imagine that this was attached to a different or a wrong intent. Then we could change that right here and say, OK, now attach it to contact us, because that's where it should fall. And then say that I approve that. And then approve it.

And then once you do that, now every time a user says something related to reset or something related to help me reset, it would automatically fall into that contact us. So that's how you would continue to-- like, somebody who's managing this chatbot would continue to go in and try to see if things are falling off, and then continue to maintain it and manage it by improving the training. 

JONATHAN CHAM: So the chatbot captures all the history. And then can you show how you actually do training? Is it, you have all this training data. And then you push the train button? 

PRIYANKA VERGADIA: Yeah, let me do this. So let's see, so I have-- say I say this one. And I change that. And I change it to-- I'm going to keep it the same, and just stay approved, and then say approve. And then once it does that, now see, the training has started. It's starting to train. And you can see the gear icon moving here. 

JONATHAN CHAM: Got it. 

PRIYANKA VERGADIA: And then once it's done, it's going to say the model is trained. And now it's going to start. And you can test it right here as well. You can test the same phrase here. And it will start to take it again. 

JONATHAN CHAM: Very nice, very nice. And then he talked a little bit about the different integrations that we have? I feel like Dialogflow, one of the benefits is there are a lot of different integrations. 

PRIYANKA VERGADIA: Yeah, so there is. So the point that I made earlier about I have the demo version, and then I also have the assistant that's enabled. So you're basically building it once, but you can now deploy it by just toggling this switch and say I want to deploy this on Facebook Messenger as well. And all you do is that. And then you verify your token for access to Facebook. And off you go. And it's enabled for Facebook as well. And then similarly, for Slack, Twilio, if you use Skype, we have some really cool integrations done with Skype as well. I think one of our customers has used this for, like, controlling their refrigerators. 

JONATHAN CHAM: Oh wow. 

PRIYANKA VERGADIA: Yeah, it's a very cool use case. And so yeah, you can-- these are all the options that you can connect it to, and just write the code once, so that's a cool part. 

JONATHAN CHAM: Right, so, yeah, that seems like it's part of the fulfillment process. You know, you covered intent, and maybe at a high level, intent is what are you trying to do, right? Like, what's the goal? Maybe you want to reset a password. Maybe you want to order something. Maybe you want to contact support. Talk a little bit about those entities. Like, how do entities fall into the intent? Are they entities or just things that you want DialogFlow to capture from the sentence, right? 

PRIYANKA VERGADIA: Right, so entities are things-- so let me actually give you a simpler example so it makes a little more sense. So in this particular example, I have a weather forecasting application, so this is much easier to understand. You say, weather forecast in San Francisco tomorrow. So the user is interested in San Francisco city, and tomorrow is the time frame, so those are my two entities. Entity is anything that you want to take an action on. So I want to take action on the city, so I can take the city and plug it into my API, and get a response for it. And then the same for tomorrow. I could get a request for today. And then I would take that, parse it into a date, and then give it to my API. And that would respond back, so anything you want to take an action on.

The one thing I would also touch here that you didn't ask, Jonathan, is context. A context is very important as well. So this is actually the biggest differentiator for DialogFlow in general. So in this case, I can say-- a user can say, weather forecast in San Francisco tomorrow. And then it would respond back with that weather. And then following up, I can say, oh, how about today? And then it would know that I'm still talking about San Francisco. So you can set that context. And the way you do that is, again, going back into DialogFlow.

And then I can show you one of the intents that has context. So when I'm doing a description, remember, it is-- it remembers the name, email, and phone number from my previous intent. And all you do is just connect them together and it would remember the context.

So that was, in short, how you would do it. 

JONATHAN CHAM: That's really good, so it seems like you can make some very complex conversations. It's not just question, answer, question, answer. It's more like question, answer, follow-up question, answer, follow-up, even more follow-ups. 

PRIYANKA VERGADIA: Yeah 

JONATHAN CHAM: And that's where context comes in. 

PRIYANKA VERGADIA: Exactly, and that's where the whole natural language processing within the engine and the machine learning also comes into picture as well, and is learning over time. 

JONATHAN CHAM: Yeah, no, that's really interesting. So let's see, we have a couple of questions. Let's talk about-- all right, what are some drawbacks of-- you know, I think, you know, this is a meetup, so we try to talk about the great things about DialogFlow. What are some drawbacks with DialogFlow? 

PRIYANKA VERGADIA: I would say it's a product that's obviously constantly evolving, as we say in machine learning, is constantly, obviously, evolving. So that's one thing that I would say. We are very open to feedback, and learning from-- and it's also a space that's evolving itself, in itself, like, chatbots in general. So we are learning through the experiences.

Then some of the other drawbacks, I would say, are really just around languages. We are constantly working on supporting more and more languages. I think we have about 12 to 14 today, but, like we have in the other Speech APIs, and we-- I think we have around 180 languages in there, right? So around that range, we are constantly trying to catch up with that. So that, I would say, is a little bit of a drawback. But other than that, it's an evolving product. 

JONATHAN CHAM: Yeah, I mean, I think, so, customers, obviously they love the fact that it's out-of-the-box. I mean, I'll throw out some buzzwords out there, machine learning, right? Like LSTMs, recurrent neural networks, I mean these are all mathematical algorithms and models used to build chatbots. If you're not interested in doing that, right, this is, kind of, an out-of-box solution. If you need more control, maybe, like, let's say you're doing something fun, like generating Game of Thrones text or some random language. And that's where you're not going to get that type of control with this, right? This is, you know, we're training the model for you. We've built it out for you. And we've made it really simple. But if you need-- kind of, very specific use cases, you know, this is probably not the best tool. 

PRIYANKA VERGADIA: Yeah, I would also add, like, you know, if you're looking for trying to find ways to start using machine learning in some way within your organization, this would probably be your good entry point into like exposure to machine learning, because it's like that easy way where you don't have to worry about training the model, but still understand how the model would be trained if you do it with some other application. So I think it's like a low barrier to entry into machine learning in a very safe place, because you have the model being trained by the platform itself, but you're just learning through it. 

JONATHAN CHAM: Right, right. 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: Actually, another interesting use case that I've been working with a customer on is they see it as a phase approach, right? Machine learning is a very-- it can encompass many things, where, hey, we want to automate everything we do. But I think realistically, it's just taking it step by step. So the first step is really let's just try to have a chatbot, right? And this is, like, a really easy first step. Like, hey, let's just start figuring out what customers are asking. Now that they've collected all this information, they might realize, oh, this is exactly what we need, or it's not. 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: And so-- yeah. 

PRIYANKA VERGADIA: And then it's like an easy step back as well. Like, if it's not, then let's just step back, start again. And you didn't lose anything. 

JONATHAN CHAM: Yeah, you're still collecting all that data from your customers to build your own model. I mean, we have customers building chatbots, our Cloud ML technology, and using TensorFlow. So it's a-- I mean, there's many ways to kind of-- 

PRIYANKA VERGADIA: To do the same thing, but yeah. It's a platform to make things simple.

JONATHAN CHAM: All right, so another question-- is it free? I love that question. Everyone wants to know if it's free. 

PRIYANKA VERGADIA: It is absolutely free at this time. So you can go ahead, start building things, and start using them. The integrations that you do with your web hooks and stuff, they could probably cost you something if you're hosting them, say in cloud functions, or somewhere else.

JONATHAN CHAM: Right, actually, that's where you might get charged, like, Cloud Functions, you pay. 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: It's a small price for something-- data store you would pay. 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: But right now, I think Dialogflow is actually free itself. 

PRIYANKA VERGADIA: DialogFlow itself is free. 

JONATHAN CHAM: OK. 

PRIYANKA VERGADIA: Yes.

JONATHAN CHAM: That makes sense. No, that's good. And then why did Google rename API.AI? I mean, like, when I first heard of API.AI? I was like I don't know what it is. 

PRIYANKA VERGADIA: Exactly. 

JONATHAN CHAM: I think most people thought that, right? Like, what API.AI? Is it a website? OK, is that a chatbot? OK, it says chatbot. Is that all it does? Because API.AI is such a broad name, right? 

PRIYANKA VERGADIA: Great question, yeah. And you pretty much, kind of, answered it yourself. It's basically, it was hard to understand what it was just by name. And it is APIs. It is AI. But again, in normal language, it's-- what is it really doing? It's really helping you have smart and intelligent conversations, which is very much aligned with the DialogFlow name, so that's why we took a step back and we made it a more commonly-usable word than API.AI, which is hard to comprehend as to what it does. 

JONATHAN CHAM: I think the funny thing about names is no one's ever going to agree on a name. 

PRIYANKA VERGADIA: Exactly. 

JONATHAN CHAM: Like, I mean, DialogFlow, you can argue, yeah, it's not the best name, but it's not the worst, right? 

PRIYANKA VERGADIA: Exactly. 

JONATHAN CHAM: And I think for any name it's always going to be tough-- an argument point. 

PRIYANKA VERGADIA: There will be some in support and some against it, so yeah. 

JONATHAN CHAM: It's, like, just like politics. So all right, no, that's good. And then I think-- so another question, link to DialogFlow dots and intro? I haven't heard of it before. Yeah, so Alex, we'll definitely send a link to-- actually, if you just do a quick Google search, hopefully Google is good at finding Dialog-- I think I did a quick search yesterday. 

PRIYANKA VERGADIA: The first link-- 

JONATHAN CHAM: The first thing that comes up-- 

PRIYANKA VERGADIA: Yeah. 

JONATHAN CHAM: OK, and then Ashok asked the question, how to name an agent for different integrations? Or is it the same for Google Home and Alexa? 

PRIYANKA VERGADIA: It's the same for everything, so all the integrations you have, you will name the agent the same. So there's only going to be one agent. And then the integration, you just enable the integration to be available for all the different platforms, but you're only writing the agent once.

JONATHAN CHAM: Right, so, yeah, it would be very complex if you had to create a different agent for different integrations. So yeah, basically, one agent encompasses all the different-- 

PRIYANKA VERGADIA: All the different integration-- 

JONATHAN CHAM: --touch points. 

PRIYANKA VERGADIA: --points.

JONATHAN CHAM: OK, yeah, great, and then, let's see here. All right, well look, I don't see any more-- I mean, that was a lot of questions, so I think that's it. You know, definitely subscribe to the channel. If you have any topics you'd like to discuss, throw it in the comments. You know, Priyanka, thank you so much for your time. That was fascinating. I mean, I'm going to the chatbot just to talk to me, because I don't have many friends. 

PRIYANKA VERGADIA: You should do that then, but I can talk to you.

JONATHAN CHAM: All right, that's true, that's true. Anyway, thank you so much. Tune in next time. I think our next topic in two days, actually, on Terraform, which is super cool as well, you know, automating deployments with Terraform on Google Cloud Platform. And, yeah, all right, thank you very much.

PRIYANKA VERGADIA: Thank you for having me. Thank you everyone. 

JONATHAN CHAM: Yes, Of course. 

PRIYANKA VERGADIA: Bye.

Share on social media: 

Like it?
Get started today, with a free 21 day trial!

Create an account
Get Started!

More from the Blog

Integrate Slack with WhatsApp

Integrate Slack with WhatsApp

Our latest offering allows you to integrate Slack with WhatsApp, effectively letting you integrate your Slack workspace with your WhatsApp Business account. If you’ve already got your team and workspaces set up on Slack, integrating with WhatsApp means you’ll be able to stay up to date with your WhatsApp account on a platform your team is already on.

Read Story
Integrate WhatsApp with Paypal

Integrate WhatsApp with Paypal

Integrating PayPal with WhatsApp gives your customers the ability to make payments directly on WhatsApp. It helps you provide a better experience for your customers, by not having to go through a range of third party platforms just to complete an order. 

Read Story
Digitally Transform Your Business With Our DocuSign WhatsApp Integration

Digitally Transform Your Business With Our DocuSign WhatsApp Integration

Integrating your WhatsApp Business API with DocuSign gives you the security, mobility, reliability, and ease-of-use you need to help you digitally transform your business. 

Read Story