[go: nahoru, domu]

Google Apps Script lets you automate and extend Google Apps. Using Apps Script, businesses can build efficient solutions to meet their requirements such as:
Join us on August 18th, 2011 for the Google Apps Script Hackathon. If your organization uses Google Apps and you want to explore how you can use Google Apps Script to create custom functions or automate repetitive tasks, then this hackathon is a perfect opportunity to learn. Google engineers will be available to answer your questions and help you learn Apps Script throughout the day’s agenda. We’ll provide food, refreshments, and experts to help you learn to use Apps Script and write your own scripts. Just bring your laptop, ideas, and enthusiasm to complete the mix. We hope to see you there!

What: Apps Script Hackathon
Date: Thursday, August 18th, 2011
Time: 2pm to 7pm EDT
Where: 76 9th Avenue, New York, NY
Register: Space is limited, register here.

For those who cannot attend in person, we invite you to try out a number of self-paced tutorials on the Apps Script documentation site.



Saurabh Gupta profile | twitter | blog

Saurabh is a Developer Programs Engineer at Google. He works closely with Google Apps Script developers to help them extend Google Apps. Over the last 10 years, he has worked in the financial services industry in different roles. His current mission is to bring automation and collaboration to Google Apps users.


What can you do with a little bit of Apps Script?

At Google, we all use email very heavily-- for communicating with other Googlers, for task management, and to mail around funny pictures of kittens. Because of the volume of email we all deal with (the internet is full of kittens), a lot of Googlers subscribe to the “inbox zero” philosophy. In inbox zero you try to keep your inbox empty of all but the emails you currently need to deal with.

What is Gmail Snooze?

In managing our inboxes, one feature that we really wanted was for Gmail to let you “snooze” an email. To snooze an email means to archive it for now, but to have it automatically reappear in the inbox at some specified time in the future. With Apps Script you can extend Gmail yourself to add this functionality and a lot more.



The Solution

Here is the Apps Script code for a “Gmail Snooze” extension. First some configuration details. Setting these variables determines whether “unsnoozed” mail gets marked as unread, and whether it gets its own special label.
var MARK_UNREAD = false;

var ADD_UNSNOOZED_LABEL = false;

Setup

The “setup” function creates a new “Snooze” label in your Gmail, along with 7 sublabels for snoozing for different lengths of time, and potentially an “Unsnoozed” label. Running this function will also prompt you to authorize the script to use Gmail. This function makes use of the “getLabelName” helper function, which will be used by the code below.

Note: After you run the setup() function, the labels will be created in Gmail. However, you may have to refresh your Gmail window to see the labels.

function getLabelName(i) {

return "Snooze/Snooze " + i + " days";
}

function setup() {
// Create the labels we’ll need for snoozing
GmailApp.createLabel("Snooze");
for (var i = 1; i <= 7; ++i) {
GmailApp.createLabel(getLabelName(i));
}
if (ADD_UNSNOOZED_LABEL) {
GmailApp.createLabel("Unsnoozed");
}
}

Moving the Snooze Queue

The “moveSnoozes” function moves messages one day forward in the queue, so that messages snoozed for 6 days are now snoozed for 5 days, etc. Messages in the 1-day label are moved back into the inbox, and potentially marked as unread. To make this work automatically, you’ll need to create a nightly event trigger to run “moveSnoozes”. See the more detailed instructions at the bottom of the post.
function moveSnoozes() {

var oldLabel, newLabel, page;
for (var i = 1; i <= 7; ++i) {
newLabel = oldLabel;
oldLabel = GmailApp.getUserLabelByName(getLabelName(i));
page = null;
// Get threads in "pages" of 100 at a time
while(!page || page.length == 100) {
page = oldLabel.getThreads(0, 100);
if (page.length > 0) {
if (newLabel) {
// Move the threads into "today’s" label
newLabel.addToThreads(page);
} else {
// Unless it’s time to unsnooze it
GmailApp.moveThreadsToInbox(page);
if (MARK_UNREAD) {
GmailApp.markThreadsUnread(page);
}
if (ADD_UNSNOOZED_LABEL) {
GmailApp.getUserLabelByName("Unsnoozed")
.addToThreads(page);
}
}
// Move the threads out of "yesterday’s" label
oldLabel.removeFromThreads(page);
}
}
}
}

Using Snooze Label in Gmail

To "snooze" a thread, use Gmail’s “Move To” button to move the thread into the "Snooze for X days" label and archive it. Every night, threads will move up through one day of the queue, and at the appointed number of days they will reappear in your inbox, unarchived. If you want the messages to reappear as unread, just change “MARK_UNREAD” at the top to be “true”.

Because this is an Apps Script, you can edit the code any way you like. If you’d like different snooze times or for unsnoozed messages to get starred, you can easily change the code. And if you have an even better idea for how to use Apps Script to improve Gmail, you can post it to our Gallery (Script Editor > Share > Publish Project) to share with the world.

If you don't know how to setup a script, it's pretty simple. Create a new Google Spreadsheet, and choose "Script Editor" from the "Tools" menu. Paste in all of the code from above and then click the “Save” button and give it a name. In the dropdown labeled "Select a function to run," choose "setup" and click the blue run arrow to the left of it. This will ask you to authorize the script, and will create the necessary labels in your Gmail. Then go to the "Triggers" menu and choose "current script's triggers." Click the link to set up a new trigger, choosing the "moveSnoozes" function, a "time-driven" event, "day timer," and then "midnight to 1am." Click save and you are done.


Corey Goldfeder profile

Corey is a Google software engineer on the Apps Script Project, based in New York. He has previously worked on Similar Shape search for 3DWarehouse, and as a robotics researcher before joining Google.



Updated: 7/29/2011 to add additional instructions for refreshing the Gmail window after running the setup() function

We’re announcing the availability of the Changes feed in the Documents List API. This feed makes it easier to detect resources that have changed.

Currently, clients needing to sync resources between Google Docs and other systems or device often encounter a number of issues detecting changes to resources via the API. Clients typically query for all resources modified after a given date. This date is denoted by the app:edited field of a resource entry. However, this field is not updated in all cases the client may care about, for instance if a resource is shared. In addition, querying for all resources modified after a given date does not produce entries for resources that have been deleted. This leads to very complex implementations of change detection by clients. These complex implementations usually have race conditions, and require a large volume of data to be exchanged with the API.

The Changes feed simplifies this process by providing resource entries only for changed resources. If a resource occurs in the Changes feed at all, the occurrence indicates a change to the resource. Once all changes are consumed, clients can store an identifier of the last change consumed. This identifier is called a changestamp. Future queries to the Changes feed with a changestamp will only return changes occurring after the given changestamp.

To start using the Changes feed, make an authorized HTTP GET request to the following URI:
https://docs.google.com/feeds/default/private/changes

The response from the API includes a Google Data API feed of resources that have changed:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns:docs="http://schemas.google.com/docs/2007"
xmlns:gd="http://schemas.google.com/g/2005"
gd:etag="W/"DEEMQ3w8eyt7ImA9WhZUGUo."">
<docs:largestChangestamp>5635</docs:largestChangestamp>
<link rel="next" type="application/atom+xml"
href="...?start-index=5636"/>

<entry gd:etag="W/"DUcMRHg5cCt7ImA9WhZUGUo."">
<category scheme="http://schemas.google.com/g/2005#kind"
term="http://schemas.google.com/docs/2007#change"
label="change"/>
<title>Project tasks</title>
...
<docs:changestamp value="5623"/>
</entry>
...
</feed>

Fields shown in this example response are discussed in detail in the updated developer guide. Please use the forum for any questions about using the new feed.

Updates to the Java and Python client libraries are on the way, and will be announced in a separate blog post.



Russ Jorgensen LinkedIn

Russ Jorgensen joined Google in 2010 and is responsible for supporting and enhancing APIs which third-party applications can use to access and manage users' collections of Google Docs. Prior to working at Google, Russ was an embedded software engineer for 22 years at Bell Labs building telecommunications products such as PBXs and wireless communication systems.


Want to weigh in on this topic? Discuss on Buzz

Since the launch of the Google Tasks API many Google Apps domain administrators have asked us how to use the API with 2-legged OAuth 1.0 (2LO) for authorization. The process for using 2LO with the Tasks API is slightly different compared to using it for the Google Calendar API or the Google Contacts APIs, which makes it a little tricky if you are already accustomed to working with those.
  1. Any use of the Tasks API needs to reference a project in the APIs Console, as the Console is used to manage API quotas and other application settings (such as IP filters).
  2. The Tasks API needs to be explicitly enabled for your domain OAuth key and secret.
Note: 2-legged OAuth via the method described in this post and referenced documentation is available for Google Apps for Business and Google Apps for Education administrators, but is not available for administrators of the Free edition.

Referencing an APIs Console Project

The Tasks API needs to know which APIs Console project is sending requests to the API (so quota can be deducted, filters can be checked, etc.). To supply this information, you need to specify the API Key of your project within each request to the Tasks API-- even when using 2LO. This is done by specifying the API Key in a key URL query parameter.

    e.g.: https://www.googleapis.com/tasks/v1/users/username/lists?key=<API_KEY>

The Java client library can do this for you automatically if you specify it after initializing the Tasks service:
// Initializing the Tasks API service
Tasks service = new Tasks("2-LO Tasks Test", httpTransport, jsonFactory);
service.accessKey = API_KEY;

Enabling the Tasks API for your domain OAuth key and secret

Also, before your API requests will be successful, you will need to change a few things in your OAuth Consumer Key and Secret configuration. In the Manage OAuth domain key page available in the Google Apps Control Panel (under advanced tools), you will need to make sure that the option Enable this consumer key is checked and the option saying Allow access to all APIs is unchecked. This may sound counterintuitive, but this option will give you access to a specific set of APIs and is necessary to access the Tasks API.

Setting up the domain OAuth consumer key and secret

Then you will need to specify which APIs you want your domain OAuth key and secret to have access to. You will be able to do this in the Manage third party OAuth Client access page where you will need to list manually all the scopes that your domain key will have access to. For example for your token to have access to the Google Calendar API and the Google Tasks API use:
    e.g.: https://www.google.com/calendar/feeds/, https://www.googleapis.com/auth/tasks

You should then be all set to use 2LO with your Google Apps domain key and secret.

For a more detailed and step-by-step explanation with code samples on how to use 2LO if you are a Google Apps domain admin, I invite you to have a look at the newly published article: Using 2-Legged OAuth with Google Tasks API for Google Apps domain administrators.



Nicolas Garnier profile | twitter | events

Nicolas joined Google’s Developer Relations in 2008. Since then he's worked on commerce oriented products such as Google Checkout and Google Base. Currently, he is working on Google Apps with a focus on the Google Calendar API, the Google Contacts API, and the Tasks API. Before joining Google, Nicolas worked at Airbus and at the French Space Agency where he built web applications for scientific researchers.


Want to weigh in on this topic? Discuss on Buzz

The Google I/O Developer Sandbox is an annual tradition that gives innovative developers a chance to showcase their companies and technologies to others at our developer conference. This year, 24 companies were in the Google Apps Sandbox showing the products and custom solutions they’ve integrated with Google Apps. In case you weren’t able to see the Sandbox firsthand, we want to share a couple videos from these companies to spread their knowledge and excitement with the rest of the ecosystem.

Assistly - Delivering customer service, fully integrated with Gmail

Assistly is a customer support application from small to medium size enterprises, integrated with Google Apps Single Sign-On, Gmail and social networks and available for purchase on the Google Apps Marketplace. Assistly is one of many great business applications which make the vision of 100% Web viable today.

A couple spoilers:
  • 70% of Assistly users leverage Gmail
  • The Google Apps Marketplace is a Top 5 distribution channel for Assistly



Cloud Sherpas - Google Apps reseller, custom app and admin tools developer

Cloud Sherpas is a Google Apps reseller that helps companies migrate to Google Apps and fully utilize the suite of web-based collaboration tools. They’ve also built SherpaTools on Google App Engine, a corporate contact management and IT administration tool for Google Apps available for purchase on the Google Apps Marketplace.

A couple spoilers:
  • Cloud Sherpas has had a 3-fold increase in revenue year over year
  • SherpaTools is servicing domains totalling close to 3.5 million users



We’ve also created video case studies of 17 additional companies who are innovating using other Google technologies, such as App Engine, Chrome/HTML and Android. Check out the full playlist on the GoogleDevelopers YouTube channel.



Ryan Boyd profile | twitter | events

Ryan is a Developer Advocate on the Google Apps Marketplace team, helping businesses build applications integrated into Google Apps. Wearing both engineering and business development hats, you'll find Ryan writing code and helping businesses get to market with integrated features.


Want to weigh in on this topic? Discuss on Buzz

The Google Apps Marketplace team would like to get feedback from the developer community on your experience with the Marketplace and what you think can be done to improve it.

Please fill out the survey below if you have an installable app on the Marketplace (using the Add it Now blue button), are actively building an installable app or previously had an installable app on the Marketplace.

Most questions are optional, so please provide the feedback most important to you even if you don't have time to complete the whole survey.

We'd also like to offer the opportunity to speak 1:1 with the Google team about your Marketplace app. If you're interested, please provide a proposed agenda at the end of the survey.

-Ryan, Scott, Steve and the entire Apps Marketplace team





If you do not see the survey embedded above, please visit the form directly.



Ryan Boyd profile | twitter | events

Ryan is a Developer Advocate on the Google Apps Marketplace team, helping businesses build applications integrated into Google Apps. Wearing both engineering and business development hats, you'll find Ryan writing code and helping businesses get to market with integrated features.

Editors note: This is cross-posted from the Google Enterprise Blog. Guest author John Gale is a developer at Appogee, a Google focused systems integrator in the UK. John helps Appogee customers make the most of the Google platform and is the author of Appogee Bookmarks for Android.

Google Sites offers an incredible way to author and distribute content, and we use it extensively both for ourselves and our clients. Therefore it was not surprising that our customers started requesting a content approval workflow in Google Sites. Now with Google Apps Script, we have been able to develop Appogee Content Approval for Google Sites.

The Solution
Appogee Content Approval for Google Sites (ACA) can be set up for any existing Google Site without having to make any changes to the site. ACA works as follows:
  1. The ACA spreadsheet generates a Content Submission Form and any content submitted is routed to a selected approver.
  2. The approver receives an email notification, which they can authorize or reject.
  3. Once authorized, the ACA spreadsheet writes the new content into the target Site using Apps Script’s Sites services. The new content is then visible to anyone with view permissions in the target site.

Approver receives an email containing the submitted content

The content submission URL can be shared to any group or published directly on the target Google Site, which represents the end goal on the workflow diagram below. Content may only be submitted by users that are logged into your domain and content can only be published with Approver sanction.
ACA Workflow Diagram

Google Apps Script made it easy
We used a number of Apps Script services to develop this application. Apps Script was an easy choice as it builds on pooled knowledge from the Google Web Toolkit (GWT) and uses Javascript syntax. Using Apps Script’s UI Services, we were able build up a working user interface quickly. Google has since introduced a new experimental feature to complement the UI Services, which provides a drag and drop GUI for building screens. We expect this feature to reduce development time required for building future apps, as well as offering a wide range of widgets and controls to improve the user experience. We used a standard Google spreadsheet as a kind of a data store in ACA. It’s worth mentioning that Apps Script’s documentation site has a plethora of tutorials covering everything from simple spreadsheet macros to full help desk applications.

One of Google Apps Scripts’ core features is the ability to seamlessly integrate different services together, in our case this was Google Sites and Spreadsheets, but many other services are accessible, such as Mail and Contacts. It was always the aim to make ACA a powerful tool without unnecessary complexity and thanks to Google Apps Script, we have successfully delivered content approval workflow to Google Sites. ACA represents our third off-the-shelf product to be listed in the Google Apps Marketplace.

Want to weigh in on this topic? Discuss on Buzz