Power Your Apps with Gmail, Google Drive, Calendar, Sheets, Slides, and More! (Cloud Next '18)

Power Your Apps with Gmail, Google Drive, Calendar, Sheets, Slides, and More! (Cloud Next '18)

Show Video

Great. Hi, everyone I'm Wesley Chun I'm a developer I have a kit and I'm gonna talk to you a little bit about well, you read the title you think that, can make it longer. Alright. There's. Some meaning behind that and we're gonna go over that so a little bit about myself my, job is to make sure that developers everywhere, like like you all are, going to be successful using, G suite and other Google developer tools and ap is I'm. Also the host of the G suite dev show on YouTube so if. You like learning off of videos every single video is between 5 and 10 minutes long pretty short and the, whole point is to show you one actionable, one learner below that, you can pick up and use right away in your code, you. Can also find, me on the blogs whether it's the general Google developers, blog or the G suite developers blog and then there's some Twitter's as well my. Background is I've been an engineer for 20 plus years if, some. Of you were around at 20, years ago or having the 20th. Anniversary. Of when Yahoo Mail launched in October, of 2000, and a. 1998. Oh my god, another, decade has passed I'm, getting older anyway, I was one of the nine or ten engineers that built that originally. In. A programming language called Python, since then I've written a couple of Python books outside. Of work I teach, Python. To, companies, that would have me and I'm. Also a member of the Python Software Foundation. But this talk isn't about me is about all of you I'm, very happy to be here today whether it's at i/o at, a Google developer day or a cloud next I'm, really excited to see the confluence, of all the developers that are coming in worldwide to learn about what. We have to offer learning. How to use these skills build. On them and become successful so, really this talk is all about you and it's also for you so.

What's The agenda for today so I'm going to give you a quick high-level. Introduction as to why you're here this, talk is a it's a high-level introduction to G suite developer tools and api's that is meant for both developers, as well as IT decision-makers. So whether, you're a technical manager, or CIO, CTO. You. Know all of this content is for you so after, the quick intro I'll go into our breast api's. Then I'll talk about our server list platforms, Apps Script and app maker and. Then do some miscellaneous and wrap up but the main takeaway, is I, want to expose you to all the different ways. That you can use G suite ap is a lot, of people don't know we have API so first of all I need to make that clear that we have AP is for you so, I kind of all I want you to be able to decide which environment you want your applications, to run in whether, it be in your environment where you use your programming, language you run it on your stack, in your data, centers, or in, your cloud. Vendor. So. We have REST API is available for that however. We also have our environment, which you can use as well and that would be Apps Script and AppMakr these are higher-level developer. Platforms, that give you more convenience, at the exchange, of a little bit less flexibility, you. Get to choose a customized. JavaScript, environment which is Apps Script or a low, coding platform, where you can drag and drop apps. You. Know from a pallet and then connect that to a data source and that's. App maker and both, app script, and app maker are following the current trend of service, application, hosting platforms, where you're, only concerned about writing, the application and not worrying, about you, know spinning, up vm's. And, servers, and managing, resources and, scaling, all that stuff is taken, care of for you. Alright. So. Why. You, are here. Hopefully. Your boss didn't force you to come to this talk all, right but the main idea is we're. All familiar with G suite or. Google Apps as it used to be known we, have a lot of tools to help you create, collaborate. Communicate. Alright. Manage and control all. Right so we're all familiar with these applications. From a user perspective. Ok, the, ng suite is used at a lot of companies worldwide probably. Yours it's, also used in a lot of schools as well. Now. From, a bird's eye view what is Google Cloud as a whole well it's actually made up of the Google cloud platform on, one side and g-suit on the other so. GCP is responsible, for the, infrastructure. And platform as a service, levels, of cloud computing and then, G suite is responsible, for the SAS level ok but while most people, see gcp for developers, and, G. Suite is for user productivity apps, I'm here. To ensure that, you guys are all aware that. The. Developer, site of GCE doesn't remain out of sight of minds and tech professionals because. If you are all using these apps and that's all you're thinking about, well I'm here to fix that okay, so this talk is called power your apps with and then I list all these different apps that you guys see up here why. Because, you can okay. You can definitely do something like that for example, you're, investigating a massive, amount of data you're probably using, GCP, to, do some analysis, on that data, whether. It be our machine learning tools. Bigquery, for analysis you. Know and you're able to come up with insights and ideas but. At the end of the day you, still have to take these insights, and present them to management, right. Okay, so the thing is if you've already built the code that, does the first part why. Not build the code that does the last part because. With G speed AP is you can use Google sheets to look at the data more easily to, generate. Charts to make things more visual and, to. Auto generate a slide deck, create. A Google Calendar invite for. Management and then, use Gmail to, notify them to come listen to you give that presentation, right. But, previously we didn't think about these things before because, we were purely thinking about you, know gcpd, developer tools and things like that but we didn't know that we could code. Gmail. Calendar, drive Docs sheets and slides so. I'm here to show you that you can do that, okay. So instead of making an app and putting an app store and hoping it goes viral all right well you can put it in the G suite marketplace so when a company adopts your app instead. Of like hoping you like you really go viral with a like a mobile app if. Companies, install your app you. Could instantly have a hundred users a thousand, users a hundred thousand users and I don't if you can see the numbers here but. Smartsheet. Is one of the one, of the add-ons that you can install. From the G suite marketplace, and they're there, already over eight million, users, so this slide, even though I took.

This Screen shot not too long ago they've. Really had a large. Increase in the number of users so you can actually expose, your code elsewhere. Alright by the way all these, things are public but, you can also make apps that are only available internally. For your corporate users all, right you don't have to make them public like this ok. And also we're gonna have an upcoming feature where admins can choose which kind of apps can, be run from within your G suite domain. Okay. All right but how does one get started using our API s some, developers, have told us that it's not always, easy to learn maybe, there's not enough documentation, or not enough working examples. Ok. So my job is to blow away these barriers to entry so you'll feel more like this, all. Right you ready to get started ok. Awesome. We're. Gonna jump right into the lowest level which are the HTTP, based REST API s. Now. These. Standard. API, request. Response. Workflow, goes something like this, your application makes, a request to an API, alright. You have to make sure you get all the right, authorization. You. Have to manage your keys all. Right then, when you have a valid, access token, you can talk to our API s make. A service request and then, get a response from that API, ok. So you know typical, client-server, stuff a little bit of security in-between right everybody's, familiar with this ok, so, this is exactly. The same as how G suite ap has work, all. Right so. While you can manage your own keys, you, can manage you know getting, the access token storing, that using it until it expires then, you have to manage, the. Refresh token, and having to go and request a new access token once it expires you could, do all that stuff but you know you're adding more code to your application, that has nothing to do with the functionality, that you're building right so, it's better to use one of our client libraries alright so in the, examples. That I'm. Going to show you today we're. Gonna have the source code in Python but that doesn't mean it's the only language you can use obviously. A, lot, of companies use different languages. So we want to make sure that, we have a client library that's available for your development environment so. We have Java. Supported, JavaScript. On the client side we. Call that browser there's. JavaScript, on the server side, for node there's, dotnet, and C sharp objective-c, Swift, for iOS, PHP. Dart go, Ruby. So, hopefully that covers, what. Everybody's, developing, in otherwise you can still use C++. As well too you can in fact just talk HTTP, directly, to the API so you don't have to use a client library alright so. Just be aware of that okay, so what. I'm gonna do now is I'm gonna present each of the G sweet API s and maybe a couple of others what, you're gonna see as bullet points, are just. Sort of like some of the more recent updates, that have come in from the product teams over the last couple of years some. Of them are fairly new some of them you know have been around for a while but the main point is to show you that the teams are continuing, to innovate and add more features that developers are asking for so, as a developer advocate even, though I'm advocating our technologies, to you all I expect. You guys to come talk to me so, that I can advocate, on your behalf to the product teams especially if there's a feature, that's missing in an API or. If. There's something that's not quite working you know I have a direct line to the product managers and the engineers on the teams so I can communicate on your behalf so it's a two-way street ok. So we're gonna start with Google Drive, I'm. Probably not gonna go over the bullet points because we're a little bit short on time the main idea is to go through each working, code sample so you can see how it works and how not so difficult, it is to get going okay so why, would you want to use the drive API there's lots of different reasons one. Of them is a, use, case where you're trying to back, up all your file archives, maybe they're all zip files and they're all compressed you, can't really look at them when they're in compressed mode what, you can do is you can write an application to. Take these archive. Files upload them to Google Drive which, then automatically.

Deflate, Them so they're installed you know in full glory that you can see from, your Drive previewer. But the folder. Name is the name of your your archive, so that you know where those files come from so, that's one example and. You. Can talk to me later we actually have that as an open source example, so you can go, and take a look at that code on github another. Thing that you can do is well first let me ask a question how many of you out there have, a very large multi, terabyte, hard drive that, you just empty your camera out when you get back home for vacation, are. Those pictures, organized. In, any way they're, just there so you know they're there it's safe but. They're not in a presentable, format, okay, if so one, of the things that you can get, from the drive, API is you have access to the image file metadata, same. Thing goes for video I think you get more metadata from images, than from videos but for images, you get you know date and time stamps, you get the geolocation, so. You, can actually automate building. Of photos based, on you. Know date, and time, vacation. As well as using the geolocation to, figure out where you are so. Summer vacation, in France, winter. Skiing trip to Lake Tahoe or Whistler or something like that or you can auto generate collages, okay, so these are just some, hints. As to what you would want to consider doing with the drive API so. Let's look at our first code sample, okay so I'm gonna walk through a little bit the authorization. Code first, just. To, do. Some boilerplate because you have to you. Have to do this anyway right, so there. Are two different ways of accessing Google API s if, it's, public, data like, searching, for YouTube, videos which are public or, public. Google+. Posts, which are also public, or asking. The cloud natural language API to do some sentiment, analysis on an English, sentence, all those, things are public. Data so you would be using an API key and they're. Really simple you just go into your developer console you create the API key you put. It in your code or put it in a secure place that your code can access and then you're done but. When you're accessing something, that. Is private information such, as your, first, 100. Files and folders on Google, Drive well that's protected, information so, that requires you to use OAuth, because. The user has to give, authorization, to your application. To actually access, their. Data on their, behalf ok. Everybody understand that between, API key simple access, simple, API access and then authorize access for more secure data okay, so we're going to walk through the sample, code here that goes over, what this security, looks, like so, aside, from the imports, at the top, we, have something called the scopes so, a scope, is basically, a permission, that your app is asking your users, for. Okay. How many people when they install an app there's. A little window that says this app needs to access your, phone number your camera your, your. Your firstborn, children you, know or whatever right doesn't, make you a little uncomfortable to, install that app because it's asking for all these permissions, and you're going why does it need all those permissions, okay. So now, as developers, we're on the other side of the fence which, is now we're going to be asking our users, to opt, in and give.

The Permissions, for our app to execute, so the, best practice that we recommend, is you, use the minimal, amount of scopes that you need so that your app functions, that, way your users are more comfortable installing. Your app okay. Giving, an app access, to your Google Drive that already, sounds kind of scary right, but. It doesn't have to be if you give if you ask for a different type of scope for example all I want to do is list the files folders. And types. I don't, need to access, the, data in their, Drive I don't need to modify, their data I'm not going to add files, to their Drive I'm not going to make any modifications whatsoever. So. One, I can just use a drive read-only scope which, is much more benign than a readwrite scope right and then the other thing is I don't even need to look at the files I just, want the file name and the type so that's file metadata, so. I can ask for. You know drives. Read-only. Scope. And metadata. Only top. Of that okay. So, that is the probably. The most minimal, and scope, that you can ask for in order to have this simple, app work obviously, for your applications, gonna be a little bit different all, right so anyway so the next line of code is storage Jason, when you create a project, in the developer. Console it will prompt to you as soon as you create your own, information. To, download, your client secret in your ID so that you can use them in your application, alright, and so here we're just saying we're all the access tokens and the Refresh tokens in this storage, Jason file you can call it whatever you want, okay. But then we try to get the credentials out of that file and if, I don't have any career or, somehow they got invalidated. Because either, they were revoked, or they expired okay, then we have to go through the process of bringing up the little window that OAuth window. Where. You know it's gonna say I need to view your drive, file metadata, okay. And it only, save you it will not, say anything like create or modify or anything like that because it's really so. The permissions, that you see in the OAuth window basically, get converted. To that English, text, from these scopes which, are just long URLs, okay. And. So we need to build that flow so that's what this client, flow from Secrets comes from so you pass in the client, secret file that you downloaded with your API project you, merge that with the permissions, that you're asking for and then it builds this ooofff flow, and then, of course the next step is you have to run this flow so that the user actually sees that, Olav box pop up in you, know on their desktop or on their mobile device okay. And so that's where the Run flow call, comes in now, as soon as the user hits accept. Then everything continues and then we get to actually, the meet of our app so in this particular case the authorization. Code takes more lines of code than, the actual application, itself okay, that's probably not gonna be the case for your code but you know just wanted, to give you a heads up that there is a lot of off code but, the, fact, is that because.

The Client library is taking care of a lot of stuff behind the scenes for you this is a lot less code than you would have to do if you implemented your own client, library or wanted to use HTTP, raw. HTTP, to talk to the API okay. If. The user clicked, cancel because they didn't want to give you permission then, an exception, will be thrown at, run flow, and then it will not continue down. Okay, so anyways. And now we'll get to our application, so now that we have valid credentials what do we do we want to build a service, endpoint to the drive API, okay. So discovery, duck-billed drive, and then we're currently on version 3 there's also a version 2 both of those are still you know alive so you can use either v3. Is a little bit faster and there's. A little less confusion, because, we cancel a lot of duplicate names and things like that but, it performs a little bit better so. We recommend you start with v3. And then the next step is we need to create an HTTP, client to talk to the API so we do that by instantiating, it and then, we pass that to your. To authorize that with your credentials so what happens is all of your communication. To the API is signed, with your credentials and everything is encrypted over the wire alright, so once we have a service, endpoint or the drive API then. We call drive dot files that list out execute and what, we get back is a set of files so we save files in case nothing comes back we'll save an empty array, okay. And then all we do is just for. Loop lists you know go through each one and print out the file name in mime type is, that. Really hard to understand, right. Ignore that forget about the off code but. The application, itself is it is it that hard, alright, it isn't that hard at all you, know you do have to chase, down the documentation. To you know find the exact feature that you're looking for, and you, know if there isn't anything there you can file a feature request otherwise. Should. Be enough, documentation to, get you going so that you know what calls you can make what the parameters, are and get the results and process them right away okay, and, by. The way so I, mentioned, earlier that I do a I do, a video show and for. Every time you see like a little blue box up there with a short link that's usually a link to a video where I actually walk through this. The, sample that you see here on screen so in case you just completely fall asleep because the lunch was so good. You can always dial in to the video and in review what we covered okay all. Right so okay okay with Drive all, right let's move on to the Google slides API this. One is kind of unique because we. Previewed, this API at, Google i/o in 2016. And we actually launched the very first API, for Google slides, that November, so, it's been around for less than two years and. Already people are doing crazy cool stuff with it okay, so. What, is a reason, why you would use the, Google slides API, well, you might have a lot of useful information in a spreadsheet you may have created a chart or two but. That's still not as presentable, as you, know a slide deck you probably have to present something to management so why not use a slides API to extract, the relevant data from the spreadsheet and then create a slide. Presentation with, that data okay. That's, one use case. Another use case is. Let's. Say you're. You're in sales and you've, got a, hundred, clients that you need to visit this month and, you've.

Built One master, slide deck but you want to have each slide deck customized, for every customer that you visit right, well. What you can do is you make you can make one master template get everything in there put, variables, in okay. Variables, in four like the company name or their. Corporate, logo and then you can auto generate, all these, slide, decks based on the master but customize for each individual, customer for you okay, so that's another use case and, I'd. Like to highlight one cool, example, that we have as a medium-size, application. It's a nodejs, app that, lets you write an entire slide presentation, in markdown format. And then it will auto generate, a Google slides presentation, for you so, it's got a lot of stars on it so you should take a look at it take it apart it's a pretty fun fun. One and I've been honest not this particular presentation, but I've been sort of like using it to build my own presentations. Internally, so it's a pretty cool tool alright let's look at some code. So. Just like what I said the second example where you have a master, template, and you, want to visit a hundred customers and you want to customize a special, slide deck just for them well. In this particular case I have title. As perhaps, the company name in this case is just a test so I I'm. Gonna replace all instances of, curly, curly title which is my template variable with hello world and perhaps. You. Know a corporate, logo where I have the URL here, and I, replace all, these logo variables, with whatever that product logo is or the corporate logo for for the customer and want to visit, and. Then what you don't see is you, know if you remember, the code for, Google Drive you did all that o auth code well guess what it's identical, the. Only difference is the Scopes gonna dip be different because you're gonna be asking for a Google slide scope, and then, down at the bottom when you create the service endpoint instead of drive equals, you will have slides, equals, discovery. Dead build slides. API, version, one okay. And, then once you have that well then you can just do slides that presentations, dot batch update so now I have two commands here that replace alt text command and they replace all images all, shapes with image command so I'm sending two commands with the API batching, them up and then shipping them off to that. Particular slide, deck ID and I. Just set fields to like nothing to mean I don't I don't care about getting anything back I just want it done I don't care about return values okay. And then, there's a video for this one as well - all. Right so, how about Google sheets, this. We launched a new API in v4. At i/o 2016. And this was a big deal so I'll point this out in a little bit but the most recently we launched a macro recording, feature in. April, and. That. Automatically. Generates Apps Script code so we will get to Apps Script momentarily, but that's the latest new hot, feature, so. Why the sheets API well, kind, of similar to slides maybe I have a lot of data in a database, can't. Really show that to managers they, don't want you know they're not gonna be able to do select, star from you, know unless you're you're, the an executive, of a very small company in which case you probably know how to do that but. What you can do is you can use this the, sheets API sorry it says slides I don't know why it says slides it should be sheets. So. Sheets API can automatically, take that data out of a database and, put it into a spreadsheet for you and once it's in the spreadsheet then. You can generate images. And charts and anything else that you can do in Google sheets. Another. Thing. I wanted to point out which I mentioned earlier is v4. Is much, more, powerful, than any previous, API so, if you're still using the XML, v3. And older and using feeds and stuff like that that is way pass a in fact, the only things you could do with, api's. Earlier, than v4, are the things that are not bolded so create new sheets within existing, spreadsheets, and add data to sheets and obviously read, data from sheets okay, which I don't have listed there because I have an API if you can't read from a spreadsheet right but. With v4, you can do all these other new things that you couldn't you. Couldn't do before and, the. The team's, goal, is even more even. More powerful, and that is they want you to be able to do anything, you, know basically anything you can do sitting down in front of Google sheets with the user interface you should be able to do with the API so, that is their goal they. Feature. For feature parity, as much as possible so the API is very very powerful okay.

All. Right so let's look at that first example I want to migrate a bunch of sequel data to to a sheet okay, so we have a bunch of fields representing. A you know a fictitious, toy order, manufacturer. Alright, and customer orders okay you can see the the columns up at the top there. There. Is a see polite, database that I'm just going to select all the current orders and, then. I'm going to insert all the column, names because I want that to be at the top of my spreadsheet so I insert, that into you know row zero of the array, alright so that's what the rows dot insert call is for then, I create a spreadsheet using, oh by the way sheets, equals. Discovery. That build sheets. API v4, are you guys getting the hang of this okay there's, a pattern here I'm not, showing any of that off code because it's identical for all these use cases alright. So. I'm gonna create the spreadsheet using this metadata here the name of the spreadsheet is called customer orders I'm, going to execute that and then get the spreadsheet ID okay. That's easy then, the next step is to take all that data and just flush. That into, the spreadsheet so, spreadsheets. That values that update, what ID the spreadsheet was starting, at cell a1. The. Data and then. Raw input, and then go and it does it okay. By, the way there's another input option, instead of raw as an alternative, called user entered so if you already had some pre formatted fields, like some fields were bolded some fields or formatted. For finance, and things, like that you can, use instead of raw you can use user entered because, what that will do is they'll they'll insert, the data as if you sat in front of a spreadsheet and typed it in manually, okay, so your two choices are raw or user entered. What. Else can you do well maybe we want to freeze. That first row you know the the headers we, want to freeze that so when you keep on scrolling up row. One stays there and perhaps, you want to bold it as well too because I want to kind of make it stand out all, right so we have two commands here one is frozen. Rows are a sheet property, so I'm going to update sheet properties, by setting the frozen Road count to one and then. I want to bold the first row so that requires, updating the, use, hundred format text format that bold flag to true and, then. Similar, to slides, I call the, batch update command, send, the requests, over, passing. The spreadsheet, ID and then I don't care about any return, values in an execute okay. Pretty. Straightforward right everybody. With me so far all right again, you, can do this in any. Programming. Language that supported, by our client libraries so it doesn't have to be Python it's just in this this, Python data structure looks very similar to adjacent data structure okay. All. Right let's talk about Gmail. Gmail. API, why. Did we invent the Gmail API the, reason is because you may be familiar with well-known.

Internet, Protocols, like SMTP, pop, IMAP in all those right those are. Long-lived. Internet. Protocols, that have been there for a long long time the, problem is they haven't kept up to date with Pete the way people, use email today they, don't understand, the concept of folders, and labels, they don't understand, vacation, responders, emails signatures. Those, things are beyond, what, those protocols. Are able to understand. And so, that's why we ended up building the, Gmail, API back. I think in 2014. So. Here's. An example of using the Gmail API so. Pretend, I have an email address that I use just for mailing lists okay, and I'm only interested in. Threads. That people are talking about rigorously. So, threads. That have more than 10 responses, okay so in. The first couple lines of code oh by the way Gmail, equals. Discovery. Build. Gmail. V1. Right, okay. Then I can go Gmail users threads me, all. Right I want to get the threads and then. Once I have all the threads I'm gonna go through and look and see how many messages are in each thread so. If I don't have any messages, so it's possible, okay so Gmail does allow you to delete message, individual, messages from a thread you, can delete them all and have nothing so I have this if statement to check for that if I don't have any messages I don't care I'm just gonna skip to the next one but. If I have more than ten messages that means 11 or more then. I'm going to go through the first message, and scan for the subject line so what I do is I get all the headers I look through look. Through the headers for the subject line as soon as I find when I save it and if, the subject line is not blank then I'm gonna display how many messages are in that thread and show the subject line okay. It's not a mission-critical. App but. It's meant to give you an idea of what you can do with the Gmail API and, I think I have a couple of videos and that this is one of them but there's a I think there's another one. Okay. So. That's Gmail let's talk about Google Calendar. So. One, of the reasons why you would do calendar so let me step back a bit why. Would you want to build, something with a calendar API so pretend you're writing the next generation, travel, app and. You're. Making bookings, for people whether, it be booking their airline the hotel or whatnot and. You. Want to be able to prevent. Your users from having to wait, for your email response, go through get all the details copy the dates copy the times and then, write them into their calendar why can't you do that for them would. That be a better user experience. Right. And, some. People often say hey doesn't gmail have this feature where you. Know if it finds one of these confirmations. That automatically, adds an event to your calendar I, go yes, but that's only a one-way street what. If I change my reservation, well. Now my calendar. Is gonna have two events. In it where one of them is completely wrong. Okay. So as the application, developer, you have full control once, you create an event, using the calendar API I don't I don't save it here but you can actually save the event ID, again. Once you have an event ID if that user does change, their you, know their reservations, you could actually auto adjust, their calendar entry so they don't have to do it manually, this gives users a really, really good experience okay. So, in this case I'm just setting up dinner with friends when. Do I start when do I and who my friends are and then, I just do okay, oops sorry Google Calendar equals, discovery. Debt build calendar. API v3. Alright, and then. I have G Cal down events insert, into my primary calendar or any secondary. Calendar, you just have to have a calendar ID right there, alright the metadata from the event, send. Notifications, to my friends, so that they know they got invited for dinner nothing. Returned and then execute, okay. Hopefully you guys are trying to get bored with this because. You're seeing the same pattern over and over again I'm just trying to give you inspiration as, to what, kind of things you would do with what api's. Okay. So let's uh let's change, gears a little bit because we're running out of time and talk. About serverless platforms, so we have Apps Script we had two great talks on Apps Script today and. You can go through and watch the videos when you get back home unfortunately. We don't have any more of the major ones.

But. Apps Script, is a service, environment, that gives you access to all the G suite services you're familiar with but it gives you more than that okay, so your hello world looks something like this. It's, this this particular piece of code is connected, to a spreadsheet so if you're in a spreadsheet and you. Bring up the the code editor you can do something like spreadsheet. App get, active spreadsheet get me to cell a1 and then set this text, string in that cell, a1, so this is a one-line JavaScript, piece, of code that I've broken, up into four lines so you could read it easier all, right but what that does is that will do. That once. You just get that one line code working you. Know then your imagination, is gonna run wild what you can do with it right but, this is a very powerful thing because as a human you did not type hello world into that spreadsheet cell you, had code do that for you and that's very empowering. You'll. Feel, you'll. Feel like you know you know the, champagne. Picture, you saw earlier okay, you're gonna feel like that once, you get something working okay. So there's your intro video for that what. Else can you do so, here's here's, another spreadsheet only has a couple of things in it right we have an address header then we have an actual address happens. To be address of Google's New York office but. What can you do with that. Well. What, you can do is you can also get the act of spreadsheet I can also get cell a1 but now instead of setting the value to hello world I'm pulling, out the value okay, in this case actually it should be a2 because, my spreadsheet, has address, as the header so, mentally, change that to a two then. I can say hey Google Maps all right now Google Maps is entering the picture not part of G suite but it is a Google service and it's available to you from Apps Script you can say Google Maps make me a new map and put a pin on that address okay. Just like that. Even. Better I could say hey Gmail email. That map to my friend, so. That I can fight them to come over for lunch. Okay. And when you send that with a map subject, line they will get an email with a map subject line and they now they have a link of, course you can make this even more complicated you, can actually you, know Google Maps has driving directions you could actually send that to your friend all, right so they don't even have to look it up in an app alright, and then. This is actually the sample that's used in our code lab so if you guys want, to do hands-on, alright. Sign up for a Friday bootcamp we still have a few more seats left then, you'll be building this app it's only four lines of code but what's really cool is that it touches three different Google products, right, Google, sheets Google Maps and Gmail all, right it's four lines of code and it does something almost useful. Right. But. You can just imagine where you can take this though maybe. You do maybe you, are a salesperson, you do have to visit all of your customers, in New York why. Can't you put them all on a map so that you can kind of plan what your route is maybe. You have, a book club that you're part of or maybe you belong to a user group right. You can send the map to everybody in the user, group or the book club to tell them where to meet this month, ok, so you can actually make real uses, out of this so my goal is to sort of inspire you to make you kind of think outside the box doubt what else can you do ok, with that code sample, that seemed like it could be useful but now, you can actually think about what you can really do to make it useful ok.

Apps Script also powers add-ons so if you've heard of add-ons Doc's add-on Sheets add-ons slides. Gmail, add-ons ok. Apps Script is behind all of those and if you are gonna write an add-on you will write them in Apps Script so, the, original add-ons, were Docs and sheets they, came out in mid 2004. And then Google, Forms, add-ons came out towards the end of sorry. To say 2004, 2014, and forms. Came out at the end of 2014 and then more recently, Google. Slides add-ons came, out at 3rd quarter of 2017, and then towards the end of the year Gmail add-ons came out as well too so now you can actually do these. So, what do they look like here, is an add-on that I built with, slides where I have a whole bunch of images online, and. It could also be images, in a drive folder it could be images on a folder. On your local, computer. Alright, doesn't matter the the sample was this easier to write if they were all online and we had URLs so that's what I did you, can take all those images and generate a slide that looks just, like that okay, here's the code that does that. Alright, so let's start with main so here are my four images okay. You know when you create a new slide deck the thing that you always get is page one which is the title slide so let's fill in the title and the subtitle, so, the title is listed above my favorite images and then the subtitle, I put down here. Okay. And, then I have a for loop so the for loop is gonna loop through each of the four images and for every image I'm going to call add image slide which is this function that, appends, a blank slide to the end of the existing presentation, and then inserts an image based. On that link that's. It it's pretty basic you can, watch the video to kind, of like get a little bit more details there's a little bit more to it than what I've shown here just a tiny bit more, but. This is a good start right so that's a slides add on a Gmail. Add-on so so we kind of understand, a Docs add on a sheets add on the slides out on because those three are editors right, well what about Gmail, it can't be tied to a particular document, right when would you use an add-on for Gmail well. One. Of the use cases that we came up with or at least my summer intern came up with, last. Summer is that, if you're traveling I'm always thinking of travel probably cuz I'm on the road giving talks a lot, you're. Gonna have an airline receipt you're gonna have a hotel receipt you're gonna have some ride share receipt and they're all coming through your Gmail problem. Is now you have to go through and cut and paste from each of these individual, messages and put them in some spreadsheet, that you can send as. Part of your expense report to accounts payable why. Do that when.

You Can automate, it directly from Gmail without, leaving Gmail and pasting. It into a different app in a different tab, okay. So we can create an expense. Report that. Runs, side by side within Gmail you don't have to leave Gmail you, can get a form, that is smart enough to go and extract using regular expressions the, content, of the seat such as the. Date the, amount incurred, the, vendor all, you have to do is enter a spreadsheet URL, click, Submit ok, the expense, is logged and then, what you'll have is a spreadsheet. That has all of your expenses you never had to leave Gmail as you're flipping. Through these really quickly, ok. So a. Little, bit of the code this this app is a little bit larger because we had to build the UI for it ok. And I'll show you a little bit about. What the UI is gonna look like towards the end of the talk so, anyway. This, this, part of the code just creates, the form that you see so you can kind of get an idea that you, know here's the part where I enter the spreadsheet information. And. Then what, happens is you build the, the widget, chunk. By chunk and, then at the very end you just add them all together and then you return a card so it's it's a it's a JSON tree structure basically it's a like a document, ok, so. That's that, Alright. Changing. Gears a tiny bit more you still were still in the land of Apps Script and that is hangouts chat so, hangouts chat launched, very recently, about four. Or five months ago well. Mostly, four months ago because it was at the very last day of February when we launched. Hangouts. Chat is our next generation, chat system, it's available for Jay suite customers, so unfortunately, you can't access it from your Gmail accounts yet, and. The. Main point is that this platform is not just for conversations, you can actually write BOTS or what. You know you should think of as micro service utility, apps that can do stuff for you so with the bot framework and API you can build chat BOTS that would, automate, workflows that you would have to use to do manually, you, can query for information. And do other heavy lifting okay, so a little bit of motivation for, all you technical, leaders out there was. Written by the Motorola, Solutions, corporate. VP and CIO and he, published this blog post six. Days after, we launched six days and he wasn't even a test, partner okay. He, was able to do something quite amazing so what he did was okay, so here's the first quote that that comes from this blog post this nut might not seem game-changing. At first, glance. And then he goes on in this blog post describe, how he built an ERP, bot that takes an order number and returns. What warranties. Apply, for all the products in that order because. He joined multiple, ERP systems, together to, collate the information, in return that just from a chat, inquiry. Okay. And then the second thing he did was build a bot that can query and hit their enterprise, data warehouse or for any given, calendar day so you enter, the calendar day it. Can summarize, the total number of shipments in. US dollars and show, what the top 10 biggest shipments, were for that particular day by, connecting, different systems, to get it using this bot service, you can chat with the bot to ask it for this information, the. Bot does all the work and it just sends back a chat message to you as if it was talking to you so you can make agents, that work on your behalf okay, so that's the power of writing. Hangouts, chat BOTS so, let's look at something simple something, much more simple like asking. Your co-workers who wants to go to lunch today okay, so this is a vote bot alright. Where, you, know people, can, click for setting, up a new vote or they can click plus one or minus one for whether they want to go to, lunch and the, code looks something like this we can actually see if it's if they click new vote then create a brand new vote card and notice, there's a card there so it's very similar it uses the same technology as the Gmail add-ons we just saw all right, and depending on what they clicked on whether it's an upvote or downvote you can see plus plus and minus minus and then. Render. That message okay, so what, does the code to render the card look like it's a little bit there's a little bit more so it's Jason, it's Jason markup or so you can see you're building, the card step by step I'll, tell you you know who was, the last person that voted the, number of votes so far you.

Know Plus one four up vote minus one for down vote and then the new button starts, a new vote okay. Any pending on what they do whether. If it's a new vote then it creates a new message but if it's a plus or minus and it updates the existing, message so these cards, are interactive. In other words when somebody votes you don't have to create a new card and clutter up the chat window it modifies, the card you can actually see the vote count and the last vote by get updated up there. Or it, tells you that it, changes, you can see the vote count go up right so, interactive, cards, so that's hangouts chat bots and then a video goes with that too all. Right app maker just, launched last. Month so, obviously there's a lot of a lot, of hype. Behind it and it. It. Looks, as it is as good as it looks all, right so we, had two talks on app maker one, talk on app maker today and then another one you should go to on Thursday, which, is more for developers, today today's talk which has happened an hour ago was, for, you know higher level executives, and also, to kind of like motivate people to, describe like what, were the reasons behind this and also show some use cases from existing customers that, were part of our early access program they built a, pretty interesting apps and app maker but, Thursday's, talk is more for developers, so I invite you guys to go and see that but the main idea is that app maker is a low code assisted development. Environment, where you can go from an idea to an app in minutes because you're, dragging and dropping you're using built in templates using point-and-click, data modeling, it makes it much easier however, under the covers it auto generates, app script code so, if you know app script then, you can further customize your, app maker app more than someone who doesn't know app script okay, so knowing app script is a good idea all. Right so. Let's wrap up so. A few other things that I didn't, get a chance to talk about they don't they don't get a lot of limelight but I do want to mention that, for all the admins out there you know if you are a G suite user you'll, have lots of users and it's, not fun if you have a hundred new employees, and you have to manually create everybody's. Drive Gmail, and calendar one at a time you really want to automate this stuff so we have it admin SDK to let you do that and you can do stuff in both with a both REST API s as was the, with, Apps Script. And. It's not just users it's also managing groups it's also creating reports, to give your.

Administrators. An idea of the. Type of activity, that people are doing in their domains whether. They're using mobile, apps versus. The web apps more. It also lets resellers, manage, licenses and things like that so it's that's, why it's called the SDK, because it's multiple, api's in one there's, a management API there's directory API or reports API license. API reseller API so all those things put together a constant, to the admin SDK, there's. Also the Google classroom API, so. If. You are working in an educational, institution or if you offer you, know corporate training within your organization's. You, can use Google classroom. Also. Like I said it has an API you can do different things with it related, to coursework, students, teachers. Guardians, things like that. There's. Also a Google vault which, is available only for G Suite customers, so this, is where you. Need to manage ediscovery. And compliance, as well as, legal matters and holds so this, API launched, just about a year ago. That's. New and. Then. I want to mention the other side of the Google, cloud which is GCP. I. Think. The important thing I want to tell you here is that you can use G see PAP as just like GG sweeeeet api's okay. Because they're also Google API is - alright for example you know bigquery. Right everyone's. Heard of bigquery it's a big it's. A data analysis, tool that lets you perform. A queries across multiple, terabytes of data and get back results in seconds instead of like hours or days or anything like that but. You can similarly do, bigquery, equals discovery. Dot build, bigquery. API v2. Ok, and you can actually do, you know provide. Your query and your code and you can say bigquery that query one. Other thing that makes GCP, ApS. A little bit different is that sometimes, you have to add the project ID so in this case I pass on the project ID along with my query and then I get my results and, it'll, dump out so this just looks for the 10 most common Shakespeare, words this is there's, a query that's been around for a long time I'm sure you sure some of you have already seen it before but you get your output and of course bigquery also has a user interface as well the. Main idea is that if you actually work really hard in the user interface and you develop the exact query that you want you can just cut and paste that into your code and instantly, you can have it automated ok, so, using. GCP, api is it's gonna be very similar to G suite API so that's that takeaway, I, just want to see so one word on non-authorized. Data so I remember I mentioned earlier that simple API access just, requires an, API key because you're looking for public data like, Google+ posts, or using, the natural language 8 I to do sent him in on a language and of course here's the searching, for a public YouTube video since. I do Python, I'm often looking for Python videos but for some reason they all have snakes I just. Don't know why I want to see code so I have to give a query a Python, - snake in order to get the, videos that I want to see ok, it's strange who knows right. Anyway. The, other question that people often ask is well that's great that you should as each of these examples of api's what if I want, to do something, like, the, the, sales thing. That you talked about earlier what if I had a copy. Of a master, template, is, a slide, deck in my Google Drive can, I you know can I copy that how do I copy that well guess what copying, a file uses, the drive API, so, you can use a drive API to copy the slide template file and then you're gonna get the customers, information from the Google sheet so every customer will have a customer.

Name A client, contact, name and then a URL for their corporate logo it's all in the spreadsheet right then, you're gonna read that data from the sheets and then you're gonna auto generate those slides out of so this is actually the beginning of that particular app I have, been written yet but I'm hoping one of you one, of you all will write it tonight or before. Dinnertime, because. You can do it that fast, ok. All. Right so where do we go next, I mentioned, that we have a couple of blogs you can follow us on we, have a bunch of Twitter's as well if you. Want to get hands-on, the. Drive, example, with the first 100 files and folders that is available as a code lab and then, Apps Script introduction, if you're new to it there's a that's also available as a code lab like I said before we still have a room in the Friday bootcamp so if you haven't left yet or your developers aren't leaving until after, Friday you can take our bootcamp it's Friday at 1:30 to six four and a half hours of hands-on, you will actually leave with those sample, apps running, ok. With you all, right and. There's, also some intermediate, code labs - under, under. Others there. Are some videos I have no private life so feel free to watch my videos and get you top and do you get tired of my voice all. Right and then for reading and doing you can also read our documentation, jeez. Fee for the API s and then Apps Script for Apps Script and then of course slash app maker for AppMakr and, then we also have a monthly newsletter that you can also read to keep up to date all. Right. Other sessions, that you may be interested in besides the bootcamp on Friday there. Is a talk, on the. Sheet. Slides and, Doc's called. CP 301 it's building on the docs editor so anytime you see the word editors it's doc sheet slides okay and then. Automating, Apps Script has happened earlier today so I have to watch the video for this is the talk that's given by the Apps Script team where they had real users, real. User use cases described. As well, as a road map of future features that are coming to Apps Script I'm, giving a talk tomorrow on how, you can do more of this inner operation. Or interoperability. Between G sweet and GCP we're, gonna write a GCP, app that, analyzes. G sweet data and then on the other side I have a G sweet app that uses GCP. Technologies, so, that, the whole premise. Of that talk is to show you how to use both sides of the house and then we also have an app maker talk as well and. The. Main idea is what why am i giving this talk to you guys so that you so, that brings, G suite APs and developer tools to your front of mine so you know they exist and show what you can do ultimately, we want you to be both successful, and if you're a customer a happy, one all right thank you for coming. You.

2018-07-28 21:32

Show Video


"Y'all", no not really and "folks" is equally ridiculous. There are no "Y'all folks" in the audience they're burning books at the Trump rally.


The Google link shown at around timestamp 17 minutes takes you through to this video "Listing your files in Google Drive" https://youtu.be/Z5G0luBohCg

Other news