So you're probably wondering if you're not familiar with Apps Script, what it is and what you can do. So if you do have a Google account and you access the Google suite of products like Sheets, Docs, Slides, Forms, your Google Drive, Calendar, Gmail, Maps, and any one of these Google services, you can do even more with those. And the best of all, it's all cloud-based.
And Google Scripts is basically JavaScript. So it's based around the JavaScript scripting language. If you're familiar with JavaScript and you understand the fundamentals of JavaScript, you can dive right in and start doing some really amazing things by connecting your Google Apps together.
So Google Apps like documents, spreadsheets, emails, when you combine the functionality of these, you can do some really cool things. You can create and customize how they function. It also comes with its own IDE, so the Integrated Development Environment. so you don't need to have an editor. It's all cloud-based, so you can log in anywhere and write your script, update your script, and add that functionality into your applications.
It can also be used as a standalone script. Use it bound within your Google applications. So Google Apps Script is a scripting language.
It's based on JavaScript and lets you do new and cool things with the G Suite of products. And there's amazing support online for Google Apps. So you can go over to developers.google.com forward slash Apps Script.
They've got a bunch of information, some quick start documents. Also guides allow you to explore the API, get an overview. You've got a reference as well as sample and examples of code snippets. And we're going to be showing you more of this as we go through upcoming lessons.
So with Google Apps Script, you can add menus to your Google Docs, Sheets, and Forms. You can add custom functions within your Google Sheets. You can create and publish web apps. And it also saves you a lot of time on these repetitive tasks.
You can use data contained within your suite to do a whole bunch of really amazing things. Also, with Forms, you can use the Sheets as a database, play Impact, a wide variety of services like Docs, Sheets, Gmail, Forms, Maps, Calendars, and so on. And as well as Sites, of course.
You're only limited by your imagination. You can do so much. You can build full-featured, lightweight web applications. Another really neat thing is that it lives on the cloud, so you don't have to have any hosting for your application. It runs directly within Google's cloud services.
In order to get started with Apps Scripts, you're gonna need to have a Google account. So if you already have a Gmail account, you're already there, you're ready to go. Just jump right in and start creating scripts.
All you have to do is log into your Google account, go to script.google.com, and this will take you into building out your first script. And of course, don't forget, JavaScript knowledge is a prerequisite to building app scripts, so you do need to have a foundational understanding of JavaScript in order to write scripts. There's also two types of scripts that we're going to be looking at in the upcoming lessons, so bound or a standalone. So this is an independent script. It's not tied to any G Suite products or documents, but you can link it into those documents within the scripting language, which gives you a lot more flexibility.
So bound and standalone scripts can be published. You can have non-published scripts, so they remain private. You can also set them to be accessible only to the project owners. They can be published as add-ons. They can be published as web apps.
They can be embedded in Google Sites, published... as an API, so an executable API, and any combination of any of these ways of publishing scripts. Go ahead and log into your Google account, and then go over to google.com forward slash script forward slash start, and click start scripting.
This will open up the IDE, and this is going to be the interface that you use in order to write your scripts. So go ahead and give your script a title, so first project. And I'm going to run through in this lesson some of the core functionality and some of the really amazing things you can do with Google scripts. So you notice when you open up your editor, you've got a basic function here, so an empty function called my function. So let's go ahead and write our first script.
And the next lesson, we're going to go through some of the features of the IDE. So go ahead and set up a variable. And this variable, you can call it whatever you want.
I'm going to call it doc because this is going to be my first document. app and I want it to use some of the functionality that's inherent within this class. So I'm going to create a document.
So document app create and new doc. So there we go. So just by doing that one line of code, and I'll show you more about the IDE later on in the upcoming lesson, we'll go through the whole IDE. But I did want to demonstrate some of the power that's available within Google scripts.
So now you just have to hit run. You need to review your permissions. So you've got to make sure that you've got an account that's available. And whenever you're writing into your drive or the script is doing something, you do need to give it permissions in order to run as your Google account. So I've got my Google account here, and I'm just giving it permissions to create an application.
So right now, what it's doing is it's running this one line of code. And what this line of code is actually doing is it's going to create a document. So what now whenever I go into my drive, first of all, I see my Google script is there. So I've got this first project sitting there, as well as the newly created document that I've just created.
And you can also give it a another name, save, and run it again, and go back into your drive. And you're going to see that it's actually going to create another document. So it's just as easy as that to create documents.
So it's amazing. how much functionality you have just in one line of code with Google Docs. So you also probably want to write in something into that document.
So we can grab the body of the document to doc get body. And this will get the body object of the current document that we've just created. So we're going to go ahead and we're going to create a third one. We're going to grab the body of the document.
And we're going to write into that body of the document. So we're going to use, again, a lot of different classes that are available. And you see with the IDE, it drops down and gives you all of these classes that are available. So just append paragraph basically means we're adding a new paragraph.
And within this paragraph, it's requesting a string value. So I'll do hello world. And exactly like JavaScript, except we've got these extra classes. And then that's it.
So let's run that again and see what happens. So going into our drive, and by default, it's going to add documents to your root drive. So now I can open up this document.
And there's our message that we just created. So there we go. Within three lines of code, we can create a document and write content into that document. So let's do one more really cool thing.
And that's going to be sending out an email. So let me get an email address to send to. And there's session variables. And again, more on this as we go through the upcoming lessons of the course.
But we can get this active user. And within the active user, we can get the email. So as long as the user is logged in, which I am, it's going to grab my email address.
So this email address that I'm using to write the script. And also, let's grab the document name. So just do subject.
Remember that doc object that we created? So we're going to get. the name of that document that we've just created and we'll actually create us another one so just do four so that we can distinguish between the other ones that we've made so we've got an email we've got a subject and let's create a body for body email and here we can add in some information so this is the new doc so i'm going to do an equal sign there and then concatenate it together And let's grab the URL so we can do doc.
And this is another method that's available within the Google Apps. So get URL. So it's actually going to get the URL of the doc that we just created.
And it's as easy as that. We can get the name. We can get the URL and so on. So there we go.
And we are ready to perform our last amazing trick for this lesson. And that's going to be to send an email. using the Gmail app. So we're sending an email, and it already fills it out.
So we've got the recipient is going to be this person, so the email address is the recipient. We've already got a subject, and we've got a body of the email. So it looks like we're ready to try out this new function that we've just created.
So look again, it's about seven lines of code there. And let's run the application and see what happens. It's going to ask us permissions again because we're using another app. So we need to review the permissions and make sure that we select an account that we want to run the application from. It always hides the advanced, so you need to go to advanced and then just hit that link there at the bottom.
And this will give you permissions to run the application under your Google account. And so now when you hit or run, we can go to our drive. And it... looks like we've actually created it twice.
So we've created that document. But if I go over to my email, I can see that it's actually emailed me a link to the document, it's attached it in the document. And all of this was just done with just these few lines of code.
So hope you're excited. And in the next lesson, we're going to be going through the IDE, you're welcome to try this out. And we're going to go into this in more detail in the upcoming lessons. But this was just a quick preview of what's to come and the power Google Apps has to create amazing functionality with just a few lines of code.