Category Archives: Google Apps Developer Blog

Information for Google Apps Developers

Bring the power of your apps into Gmail with Add-ons



Few things are as satisfying as completing a task. But at work, it’s not always so easy. The days are short and packed with to-dos, like following up on sales leads, logging support tickets or sending invoices. And while great apps exists to tackle these workstreams, most users have to flip between them and their inbox because email is still “central command” for task management.
To solve this problem for users, today we're introducing the developer preview of Gmail Add-ons, a new way for G Suite users to access your app's functionality directly from Gmail in just one tap, no matter the device.
With Gmail Add-ons, developers can write an integration once and deploy it anywhere.

Save your users time

Add-ons provide a way to surface the functionality of your app or service when the context calls for it. They’re built on a powerful framework, which makes it easy for developers to trigger workflows based on email content. Say a Gmail user receives an email from a sales lead, and wants to add that contact to her CRM solution. With Gmail Add-ons, she can enter the contact’s required info and look up their account in that CRM system without leaving Gmail. No more tabbing, copying and pasting or sifting between mobile apps in order to get things done.

Write once, run anywhere 


With Gmail Add-ons, developers only build their integration once, and it runs natively in Gmail on web, Android and iOS right away. Users only install the Add-on once, too, and it shows up in Gmail across their devices. So instead of wasting time writing separate integrations for web and mobile, you can focus on bringing your app’s most powerful features right to your users when they need them most. Gmail Add-ons are built in Apps Script using a newly-designed "Card" system that lets you easily combine different UI components. Developers can create a snappy user experience that feels like it was natively built into Gmail. The result: integrations that are cross-platform from the get-go that save your team time.

See what’s possible by signing up for the developer preview today 

Gmail users will be able to install Add-ons via the G Suite Marketplace later this year, but that hasn’t stopped us from working with select partners to develop some amazing integrations to show what Add-ons are capable of.
No matter the task, Gmail users can easily find the right Add-on for the job. Here's how you could seamlessly use ProsperWorks and Intuit right from Gmail.

  • Intuit QuickBooks: The Intuit Add-on lets Gmail users and QuickBooks small business customers generate and send invoices and even confirm invoice status without ever leaving Gmail. 
  • ProsperWorks: The ProsperWorks Add-on makes it easy for Gmail users to check the contact info of people on email threads against the information stored in their CRM. 
  • Salesforce: The Salesforce Add-on allows Gmail users to look up existing contacts, add new ones, as well as associate email threads with one or more existing opportunities in Salesforce, right from the Gmail app. 

The Salesforce Add-on makes it easy to capture background information from Gmail and tie it to a sales opportunity.
If you’re a developer, you can sign up for our Developer Preview today. We expect to start sending invitations for early developer access soon.

Building #withClassroom: stories of real schools using Classroom integrations


A few years ago, we launched the Classroom API to make it easier for developers to integrate their applications with Classroom, and for administrators to manage classes. Since then, hundreds of applications have integrated with Classroom to help teachers gamify their classes, improve students’ writing skills, build interactive presentations and more.

Using the API, developers can build deep integrations that manage Classroom rosters, assignments and grades. Or they can simply embed the Classroom share button to let users quickly share content. For teachers and students, these integrations create a seamless experience between Classroom and their favorite education apps.

Valuable integrations have been built to support the needs of teachers and students in the classroom that showcase the creative possibilities available through the Classroom API. Today, we take a look at how some schools are using Classroom integrations.

Enriching lessons with rich content from BrainPOP 

In the words of Mike Jones, a teacher at Illinois State University’s K-8 Lab School, “Class time is precious. Why would I want to waste any of it with a process that can easily be automated?”

Improved automation is one of the key reasons we’ve seen education applications integrate with Google Classroom and one of those applications is BrainPOP. BrainPOP offers digital educational content that engages students through animated movies, learning games, quizzes, concept mapping, movie-making, and more.

The team at BrainPOP recognized that manually setting up individual student accounts for My BrainPOP could be a tedious task for teachers. Utilizing the Classroom API, the team at BrainPOP developed an integration that allows teachers to import their classes directly into My BrainPOP, automatically creating single sign-on-ready, student accounts and allowing students to log into BrainPOP through the Google launcher menu. According to Jones, the integration “allows all staff to easily access the benefits of BrainPOP and do what they do best: help children learn.”

Adjusting teaching tactics in real-time with Edulastic 

Egg Harbor Township in New Jersey holds an intensive summer program for its Title I elementary students who aren’t ready to enter the next grade level. During last year’s program, the school had just 12 days to address learning gaps, which meant teachers had to stay laser-focused on deficiencies and adjust teaching tactics quickly to help their students achieve success. Given the tight timeframe, the school turned to Edulastic, an online assessment system that gives teachers instant teaching insights, and Google Classroom.

Edulastic’s Google Classroom sync meant the summer program could be set up quickly with no additional passwords or logins for teachers or students. As a result of the pilot, Egg Harbor Township Title I teachers used this integration beyond their summer program and the entire school subsequently decided to use it for their assessments as well.

Simplifying setup and syncing with Little SIS 


Classroom integrations can also give IT leaders insights and administrative powers in Classroom. For instance, Little SIS for Classroom, an app designed and built by the team at Amplified Labs, is using the Classroom Courses and Guardians APIs to automate the setup and daily sync of Google Classroom classes, rosters, and guardian invites from information in the school’s SIS.
San Francisco Unified School District is piloting a roster-integrated approach to Google Classroom that they hope to scale to their 57,000 students. Executive Director of Technology & Innovation David Malone first approached Amplified Labs with guarded optimism because of the district’s size, but since installation he feels much more confident. “Despite being new to the market, I am really impressed at the maturity and thoughtfulness of the Little SIS app. It loaded our entire district’s G Suite users and 7,500 Classroom classes in just a few minutes, and allowed us to get a great baseline on the current state of adoption.”

We’ve been thrilled to see what developers have created using the Classroom API capabilities and the impact that it's had on teachers, students and administrators. If you’re interested in learning more about the Classroom API, check out developers.google.com/classroom or search for google-classroom on Stack Overflow. You can also join our announcement list to keep up with updates to our API.

Adding text and shapes with the Google Slides API

Posted by Wesley Chun (@wescpy), Developer Advocate, G Suite
When the Google Slidesteam launched their very first API last November, it immediately opened up a whole new class of applications. These applications have the ability to interact with the Slides service, so you can perform operations on presentations programmatically. Since its launch, we've published several videos to help you realize some of those possibilities, showing you how to:
Today, we're releasing the latest Slides API tutorial in our video series. This one goes back to basics a bit: adding text to presentations. But we also discuss shapes—not only adding shapes to slides, but also adding text within shapes. Most importantly, we cover one best practice when using the API: create your own object IDs. By doing this, developers can execute more requests while minimizing API calls.



Developers use insertText requests to tell the API to add text to slides. This is true whether you're adding text to a textbox, a shape or table cell. Similar to the Google Sheets API, all requests are made as JSON payloads sent to the API's batchUpdate() method. Here's the JavaScript for inserting text in some object (objectID) on a slide:
{
"insertText": {
"objectId": objectID,
"text": "Hello World!\n"
}
Adding shapes is a bit more challenging, as you can see from itssample JSON structure:

{
"createShape": {
"shapeType": "SMILEY_FACE",
"elementProperties": {
"pageObjectId": slideID,
"size": {
"height": {
"magnitude": 3000000,
"unit": "EMU"
},
"width": {
"magnitude": 3000000,
"unit": "EMU"
}
},
"transform": {
"unit": "EMU",
"scaleX": 1.3449,
"scaleY": 1.3031,
"translateX": 4671925,
"translateY": 450150
}
}
}
}
Placing or manipulating shapes or images on slides requires more information so the cloud service can properly render these objects. Be aware that it does involve some math, as you can see from the Page Elements page in the docs as well as the Transforms concept guide. In the video, I drop a few hints and good practices so you don't have to start from scratch.

Regardless of how complex your requests are, if you have at least one, say in an array named requests, you'd make an API call with the aforementioned batchUpdate() method, which in Python looks like this (assuming SLIDES is the service endpoint and a presentation ID of deckID):

SLIDES.presentations().batchUpdate(presentationId=deckID,
body=requests).execute()
For a detailed look at the complete code sample featured in the DevByte, check out the deep dive post. As you can see, adding text is fairly straightforward. If you want to learn how to format and style that text, check out the Formatting Text post and video as well as the text concepts guide.
To learn how to perform text search-and-replace, say to replace placeholders in a template deck, check out the Replacing Text & Images post and video as well as the merging data into slides guide. We hope these developer resources help you create that next great app that automates the task of producing presentations for your users!

G Suite Developer Sessions at Google Cloud Next 2017

Posted by Wesley Chun (@wescpy), Developer Advocate, G Suite

There are over 200 sessions happening next month at Google Cloud's Next 2017 conferencein San Francisco... so many choices! Along with content geared towards Google Cloud Platform, this year features the addition of G Suite so all 3 pillars of cloud computing (IaaS, PaaS, SaaS) are represented!


There are already thousands of developers including Independent Software Vendors (ISVs) creating solutions to help schools and enterprises running the G Suite collaboration and productivity suite (formerly Google Apps). If you're thinking about becoming one, consider building applications that extend, enhance, and integrate G Suite apps and data with other mission critical systems to help businesses and educational institutions succeed.


Looking for inspiration? Here's a preview of some of the sessions that current and potential G Suite developers should consider:


The first is intro blog post & video for the latest Google Sheets API as well as the intro blog post & video for the Google Slides API. Part of the talk also covers Google Apps Script, the Javascript-in-the-cloud solution that gives developers programmatic access to authorized G Suite data along with the ability to connect to other Google and external services.


If that's not enough Apps Script for you, or you're new to that technology, swing by to hear its Product Manager give you an introduction in his talk, quick intro video to give you an idea of what you can do with it!


Did you know that Apps Script also powers "add-ons" which extend the functionality of Google Docs, Sheets, and Forms? Then come to "the G Suite Marketplace where administrators or employees can install your add-ons for their organizations.


In addition to Apps Script apps, all your Google Docs, Sheets, and Slides documents live in Google Drive. But did you know that Drive is not just for individual file storage? Hear directly from a Drive Product Manager on how you can, "the Drive API and Team Drives, you can extend what Drive can do for your organization. One example from the most recent Google I/O tells the story of how WhatsApp used the Drive API to back up all your conversations! To get started with your own Drive API integration, check out this blog post and short video. Confused by when you should use Google Drive or Google Cloud Storage? I've got an app, err video, for that too! :-)


Not a software engineer but still code as part of your profession? Want to build a custom app for your department or line of business without having to worry about IT overhead? You may have heard about Google App Maker, our low-code development tool that does exactly that. Curious to learn more about it? Hear directly from its Product Manager lead in his talk entitled, "

All of these talks are just waiting for you at
Next, the best place to get your feet wet developing for G Suite, and of course, the Google Cloud Platform. Start by checking out the session schedule. Next will also offer many opportunities to meet and interact with industry peers along with representatives from all over Google who love the cloud. Register today and see you in San Francisco!




Enhancements to coursework in the Classroom API

Posted by Greg Zecchini, Google Classroom Software Engineer

Hundreds of education developers use the Classroom API to integrate their applications with Google Classroom. Last year, we announcedthe ability for external applications to read and write assignments. We've received a lot of feedback from developers who began integrating assignments with Classroom, and they said that they wanted to do even more.
Today, we're making the coursework endpoints more robust, with additional management capabilities. Applications can now:
  • Create and update questions
  • Modify and delete coursework
  • Add Drive items and YouTube videos to coursework and student submissions
Flat Education, a collaborative music notation app, already integrates with Classroom to let teachers quickly synchronize rosters and assignments, and design music activities accessible to students with just one click from Google Classroom. Flat has been piloting the new API functionality to create a more seamless integration. Flat CTO Vincent Giersch notes, "the support of Google Drive in the Google Classroom API is simply great: all the music scores created with G Suite for Education accounts on Flat being already Drive files, we can now directly add our Drive files in the assignments and students submissions. This will make possible for teachers and students to use Google Classroom with Flat as they would do with Google Docs."


In case you missed it, we've also made other recent updates to managing parents and guardians with the API. Classroom sends daily or weekly email summaries to guardians, and applications using the API to manage guardians can now detect if guardian visibility is enabled for a course, and list all guardians and guardian invitations in a domain.

For more details on what you can build with coursework, review the documentation, the FAQ, and ask questions on Stack Overflow. As always, let us know what you're building using the #withClassroom hashtag on Twitter or Google+. We look forward to working together to make it even easier for teachers and students to use the tools they love with Classroom.

Formatting text with the Google Slides API

Posted by Wesley Chun (@wescpy), Developer Advocate, G Suite

It's common knowledge that presentations utilize a set of images to impart ideas to the audience. As a result, one of the best practices for creating great slide decks is to minimize the overall amount of text. It means that if you do have text in a presentation, the (few) words you use must have higher impact and be visually appealing. This is even more true when the slides are generated by a software application, say using the Google Slides API, rather than being crafted by hand.

The G Suite team recently launched the first Slides API, opening up a whole new category of applications. Since then, we've published several videos to help you realize some of those possibilities, showing you how to replace text and images in slides as well as how to generate slides from spreadsheet data. To round out this trifecta of key API use cases, we're adding text formatting to the conversation.

Developers manipulate text in Google Slides by sending API requests. Similar to the Google Sheets API, these requests come in the form of JSON payloads sent to the API's batchUpdate() method. Here's the JavaScript for inserting text in some shape (shapeID) on a slide:

{
"insertText": {
"objectId": shapeID,
"text": "Hello World!\n"
}

In the video, developers learn that writing text, such as the request above, is less complex than reading or formatting because both the latter require developers to know how text on a slide is structured. Notice for writing that just the copy, and optionally an index, are all that's required. (That index defaults to zero if not provided.)

Assuming "Hello World!" has been successfully inserted in a shape on a slide, a request to bold just the "Hello" looks like this:

{
"updateTextStyle": {
"objectId": shapeID,
"style": {
"bold": true
},
"textRange": {
"type": "FIXED_RANGE",
"startIndex": 0,
"endIndex": 5
},
"fields": "bold"
}
If you've got at least one request, like the ones above, in an array named requests, you'd ask the API to execute them with just one call to the API, which in Python looks like this (assuming SLIDES is your service endpoint and the slide deck ID is deckID):
SLIDES.presentations().batchUpdate(presentationId=deckID,
body=requests).execute()

To better understand text structure & styling in Google Slides, check out the text concepts guidein the documentation. For a detailed look at the complete code sample featured in the DevByte, check out the deep dive post. To see more samples for common API operations, take a look at this page. We hope the videos and all these developer resources help you create that next great app that automates producing highly impactful presentations for your users!

Modifying email signatures with the Gmail API

Posted by Wesley Chun (@wescpy), Developer Advocate, G Suite

The Gmail API team introduced a new settings feature earlier this year, and today, we're going to explore some of that goodness, showing developers how to update Gmail user settings with the API.

Email continues to be a dominant form of communication, personally and professionally, and our email signature serves as both a lightweight introduction and a business card. It's also a way to slip-in a sprinkling of your personality. Wouldn't it be interesting if you could automatically change your signature whenever you wanted without using the Gmail settings interface every time? That is exactly what our latest video is all about.

If your app has already created a Gmail API service endpoint, say in a variable named GMAIL, and you have the YOUR_EMAIL email address whose signature should be changed as well as the text of the new signature, updating it via the API is as pretty straightforward, as illustrated by this Python call to the GMAIL.users().settings().sendAs().patch() method:

signature = {'signature': '"I heart cats."  ~anonymous'}
GMAIL.users().settings().sendAs().patch(userId='me',
sendAsEmail=YOUR_EMAIL, body=signature).execute()

For more details about the code sample used in the requests above as well as in the video, check out the deepdive post. In addition to email signatures, other settings the API can modify include: filters, forwarding (addresses and auto-forwarding), IMAP and POP settings to control external email access, and the vacation responder. Be aware that while API access to most settings are available for any G Suite Gmail account, a few sensitive operations, such as modifying send-as aliases or forwarding, are restricted to users with domain-wide authority.

Developers interested in using the Gmail API to access email threads and messages instead of settings can check out this other video where we show developers how to search for threads with a minimum number of messages, say to look for the most discussed topics from a mailing list. Regardless of your use-case, you can find out more about the Gmail API in the developer documentation. If you're new to the API, we suggest you start with the overview page which can point you in the right direction!

Be sure to subscribe to the Google Developers channel and check out other episodes in the G Suite Dev Show video series.

Generating slides from spreadsheet data

Posted by Wesley Chun (@wescpy), Developer Advocate, G Suite

The G Suite team recently launched the very first Google Slides API, opening up a whole new set of possibilities, including leveraging data already sitting in a spreadsheet or database, and programmatically generating slide decks or slide content based on that data. Why is this a big deal? One of the key advantages of slide decks is that they can take database or spreadsheet data and make it more presentable for human consumption. This is useful when the need arises to communicate the information reflected by that data to management or potential customers.

Walking developers through a short application demonstrating both the Sheets and Slides APIs to make this happen is the topic of today's DevByte video. The sample app starts by reading all the necessary data from the spreadsheet using the Sheets API. The Slides API takes over from there, creating new slides for the data, then populating those slides with the Sheets data.

Developers interact with Slides by sending API requests. Similar to the Google Sheets API, these requests come in the form of JSON payloads. You create an array like in the JavaScript pseudocode below featuring requests to create a cell table on a slide and import a chart from a Sheet:


var requests = [
   {"createTable": {
       "elementProperties":
           {"pageObjectId": slideID},
       "rows": 8,
       "columns": 4
   }},
   {"createSheetsChart": {
       "spreadsheetId": sheetID,
       "chartId": chartID,
       "linkingMode": "LINKED",
       "elementProperties": {
           "pageObjectId": slideID,
           "size": {
               "height": { ... },
               "width": { ... }
           },
           "transform": { ... }
       }
   }}
];
If you've got at least one request, say in a variable named requests (as above), including the Sheet's sheetID and chartID plus the presentation page's slideID. You'd then pass it to the API with just one call to the presentations().batchUpdate() command, which in Python looks like the below if SLIDES is your API service endpoint:
SLIDES.presentations().batchUpdate(presentationId=slideID,
       body=requests).execute()

Creating tables is fairly straightforward. Creating charts has some magical features, one of those being the linkingMode. A value of "LINKED" means that if the Sheet data changes (altering the chart in the Sheet), the same chart in a slide presentation can be refreshed to match the latest image, either by the API or in the Slides user interface! You can also request a plain old static image that doesn't change with the data by selecting a value of "NOT_LINKED_IMAGE" for linkingMode. More on this can be found in the documentationon creating charts, and check out the video where you'll see both those API requests in action.

For a detailed look at the complete code sample featured in the video, check out the deep dive post. We look forward to seeing the interesting integrations you build with the power of both APIs!

Formatting cells with the Google Sheets API

Posted by Wesley Chun (@wescpy), Developer Advocate, G Suite
At Google I/O earlier this year, we launched a new Google Sheets API (click here to watch the entire announcement). The updated API includes many new features that weren't available in previous versions, including access to more functionality found in the Sheets desktop and mobile user interfaces. Formatting cells in Sheets is one example of something that wasn't possible with previous versions of the API and is the subject of today's DevByte video.
In our previous Sheets API video, we demonstrated how to get data into and out of a Google Sheet programmatically, walking through a simple script that reads rows out of a relational database and transferring the data to a new Google Sheet. The Sheet created using the code from that video is where we pick up today.

Formatting spreadsheets is accomplished by creating a set of request commands in the form of JSON payloads, and sending them to the API. Here is a sample JavaScript Object made up of an array of requests (only one this time) to bold the first row of the default Sheet automatically created for you (whose ID is 0):

{"requests": [
{"repeatCell": {
"range": {
"sheetId": 0,
"startRowIndex": 0,
"endRowIndex": 1
},
"cell": {
"userEnteredFormat": {
"textFormat": {
"bold": true
}
}
},
"fields": "userEnteredFormat.textFormat.bold"
}}
]}
With at least one request, say in a variable named requests and the ID of the sheet as SHEET_ID, you send them to the API via an HTTP POST to https://sheets.googleapis.com/v4/spreadsheets/{SHEET_ID}:batchUpdate, which in Python, would be a single call that looks like this:
SHEETS.spreadsheets().batchUpdate(spreadsheetId=SHEET_ID,
body=requests).execute()

For more details on the code in the video, check out the deepdive blog post. As you can probably guess, the key challenge is in constructing the JSON payload to send to API calls—the common operations samples can really help you with this. You can also check out our JavaScript codelab where we guide you through writing a Node.js app that manages customer orders for a toy company, featuring the toy orders data we looked at today but in a relational database. While the resulting equivalent Sheet is featured prominently in today's video, we will revisit it again in an upcoming episode showing you how to generate slides with spreadsheet data using the new Google Slides API, so stay tuned for that!

We hope all these resources help developers enhance their next app using G Suite APIs! Please subscribe to our channel and tell us what topics you would like to see in other episodes of the G Suite Dev Show!

Introducing the Google Slides API

Posted by Wesley Chun, Developer Advocate, G Suite

At Google I/O 2016, we gave developers a preview of the Google Slides API. Since then, the gears have been cranking at full speed, and we've been working with various early-access partners and developers to showcase what you can do with it. Today, we're happy to announce that the Slides API v1 is now generally available and represents the first time that developers have ever been able to programmatically access Slides!

The Slides API breaks new ground, changing the way that presentations are created. No longer do they require manual creation by users on their desktops or mobile devices. Business data on inventory items like retail merchandise, homes/property, hotels/lodging, restaurants/menus, venues/events, and other "cataloged" assets can be instantly turned into presentations based on pre-existing slide templates. Traditionally, the sheer amount of data (and of course time[!]) that went into creating these slide decks made it unwieldy if done by hand. Applications leveraging the API can easily generate presentations like these, customized as desired, and in short order.

Developers use the API by crafting a JSON payload for each request. (We recommend you batch multiple commands together to send to the API.) You can think of these as actions one can perform from the Slides user interface but available programmatically. To give you an idea of how the new API works, here are what some requests look like for several common operations:

// create new slide (title & body layout)
{
"createSlide": {
"slideLayoutReference": {
"predefinedLayout": "TITLE_AND_BODY"
}
}
},
// insert text into textbox
{
"insertText": {
"objectId": titleID,
"text": "Hello World!"
}
},
// add bullets to text paragraphs
{
"createParagraphBullets": {
"objectId": shapeID,
"textRange": {
"type": "ALL"
}
}
},
// replace text "variables" with image
{
"replaceAllShapesWithImage": {
"imageUrl": imageURL,
"replaceMethod": "CENTER_INSIDE",
"containsText": {
"text": "{{COMPANY_LOGO}}"
}
}
}

If you're interested in seeing what developers have already built using the API, take a look at our initial set of partner integrations by Conga, Trello, Lucidchart, Zapier and more, as described in detail in our G Suite blog post.


To help you get started, check out the DevByte above from our new series dedicated to G Suite developers. In the video, we demonstrate how to take "variables" or placeholders in a template deck and use the API to generate new decks replacing those proxies with the desired text or image. Want to dive deeper into its code sample? Check out this blogpost. If you're not a Python developer, it'll be your pseudocode as you can use any language supported by the Google APIs Client Libraries. Regardless of your development environment, you can use similar "scaffolding" to generate many presentations with varying content for your users. Stay tuned for more videos that highlight other Slides API features.

The Slides API is available to projects in your Google Developers console today. Developers can find out more in the official documentation which features an API overview plus Quickstarts, sample code in multiple languages and environments, to bootstrap your next project. We look forward to seeing all the amazing slide deck generating applications you build with our first ever API!