Get to know Apps Script

Add-ons are built using Apps Script, a server-side scripting language that lets you build scripts and applications that interact directly with G Suite products like Gmail, Drive, Docs, Sheets, Slides and more.

If you're an Apps Script pro, this section is old hat. For the rest, here's a quick synopsis.

The platform

Apps Script's code editor is a web app that you launch from within Google Sheets, Docs, Slides, or Forms. The language is based on JavaScript, but executes on Google's servers rather than directly in the user's browser (with the exception of client-side user interfaces, described below). There's literally nothing you need to install to begin development. For a basic rundown of the platform, read the Apps Script overview.

Our APIs, and yours

Apps Script's built-in services offer easy-to-use APIs for 12 popular G Suite applications, including Calendar, Drive, and Gmail—not to mention more than a dozen utility services to cover common scripting needs. Other Google products, like YouTube, are available as advanced services. Because Apps Script can connect to external APIs, it's simple to integrate your company's services with G Suite.

Authorization

Apps Script was built to handle much of the complexity of user authorization for you. When a user installs an add-on or runs an Apps Script project for the first time, Apps Script automatically scans the code to determine which built-in or advanced Google services it uses, then prompts the user to authorize access to their data.

If your add-on uses authenticated third-party APIs—including Google APIs that Apps Script doesn't natively support—we provide a callback URL and state token so that you can set up a secondary authorization flow.

User interfaces

For the G Suite editor applications (Google Docs, Sheets, Slides and Forms) Add-ons can create menu items and open dialogs or sidebars. You can design custom interfaces using the HTML service, which offers client-side HTML, CSS, and JS with a few limitations.

The Docs Translate, Forms Notifications, and Slides Translate quickstarts provide simple examples of add-ons that have dialog and sidebar interfaces built with the HTML service.

Storage

Apps Script offers a few ways to store data. The Properties service is great for simple strings, while the JDBC service lets you connect to an external database—the best choice for robust applications.

Logging

The script editor includes a logger that is useful during development, but not once an add-on is published. To track errors that users encounter in the wild, make use of Apps Script's built-in access to Stackdriver logging. Your add-on's Help menu also lets users submit anonymous bug reports.

Triggers

Triggers let your add-on execute specific code when a specific condition is met. Add-ons can use simple triggers like the special function onOpen(e) (which fires when a user opens a document), installable triggers like a Google Forms submit, and time-driven triggers that execute code at a particular time or on a recurring interval, as frequently as every hour or as infrequently as once per month.

Note that installable triggers behave a little differently in add-ons than in the rest of Apps Script, so be sure to read the documentation.

Develop locally

Most developers create Apps Script projects using the Apps Script editor in a browser tab. You can also use the Apps Script command line tool clasp to develop and manage Apps Script projects locally. The clasp tool handles the details of downloading, uploading, and deploying project files for you, so you can work on your project using your favorite code editor.