SlideShare uma empresa Scribd logo
1 de 44
Baixar para ler offline
Automating Google Workspace
(GWS) & more with Apps Script:
Making the most of Gmail, Google Drive, Calendar,
Docs, Sheets, Slides, Forms, Chat & other services
Wesley Chun - @wescpy@
Principal, CyberWeb
3
Principal Consultant, CyberWeb
● Mission: produce accelerated Python
developers, enable developers to be
successful using Google Cloud and
other Google developer tools & APIs
● Focus: Python, Google Cloud (GCP) &
Google Workspace (GWS) APIs; GAE
migrations; Google X-product sol'ns
● Services: technical consulting,
training, engineering, speaking, code
samples, hands-on tutorials, public
technical content (blogs, social, etc.)
About the speaker
Previous experience / background
● Software Engineer & Developer Advocate
○ Google, Sun, HP, Cisco, EMC, Xilinx &
○ Original Yahoo!Mail engineer/SWE
● Technical trainer, teacher, instructor
○ Teaching Math, Linux, Python since '83
○ Adjunct CS Faculty at local SV colleges
● Python community member
○ Popular Core Python series author
○ Python Software Foundation Fellow
● AB (Math/CS) & CMP (Music/Piano), UC
Berkeley and MSCS, UC Santa Barbara
● Adjunct Computer Science Faculty, Foothill
College (Silicon Valley)
GWS Dev Show
goo.gl/JpBQ40
GAE migration
bit.ly/3xk2Swi
Apps Script: why & agenda
● Google provides APIs giving programmatic access to its technologies
○ Its use can be challenging: REST, OAuth2, HTTP, authentication, etc.
● Apps Script: a developer "tool for everyone;" high-level API access
○ "Low code" solution via customized serverless, JavaScript runtime
○ Lets you automate & extend GWS, and ultimately, get the job done
Cloud
computing
review
1
Google
serverless
platforms
2
Introduction to
Apps Script
3
Coding with
Apps Script
4 5
Advanced
topics
7
Wrap-up
6
Inspiration
01
Cloud computing
overview
All you need to know about the cloud
What is cloud computing?
spar
Google Compute Engine, Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
Cloud service levels/"pillars"
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google BigQuery, Cloud SQL, Vertex AI,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Apps Script
Salesforce Platform (formerly force.com)
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google Compute Engine, Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
Outsourcing of apps (SaaS)
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google BigQuery, Cloud SQL, Vertex AI,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Apps Script
Salesforce Platform (formerly force.com)
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google Compute Engine, Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
Outsourcing of hardware (IaaS)
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google BigQuery, Cloud SQL, Vertex AI,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Apps Script
Salesforce Platform (formerly force.com)
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google Compute Engine, Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
Outsourcing of logic-hosting (PaaS)
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google BigQuery, Cloud SQL, Vertex AI,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Apps Script
Salesforce Platform (formerly force.com)
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google BigQuery, Cloud SQL, Vertex AI,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Compute Engine, Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
IaaS/PaaS gray area (DataB/S/P-aaS?)
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google Apps Script
Salesforce Platform (formerly force.com)
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google Compute Engine, Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
SaaS/PaaS gray area
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google BigQuery, Cloud SQL, Vertex AI,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google Apps Script
Salesforce Platform (formerly force.com)
Summary of responsibility
SaaS
Software as a Service
Applications
Data
Runtime
Middleware
OS
Virtualization
Servers
Storage
Networking
Applications
Data
Runtime
Middleware
OS
Virtualization
Servers
Storage
Networking
IaaS
Infrastructure as a Service
Applications
Data
Runtime
Middleware
OS
Virtualization
Servers
Storage
Networking
PaaS
Platform as a Service
Managed by YOU Managed by cloud vendor
Applications
Data
Runtime
Middleware
OS
Virtualization
Servers
Storage
Networking
on-prem
all you, no cloud
02
Google serverless
compute platforms
GCP & GWS
formerly
( )
● GWS developer home: developers.google.com/gsuite
● GWS developer intro: youtu.be/NqumcYgj5LI
● GWS REST APIs: youtu.be/2VpvWhDdXsI
● GWS Apps Script: youtu.be/xDovB0pu4OU
● Comprehensive overview: youtu.be/kkp0aNGlynw
Google Workspace
(formerly G Suite and Google Apps)
(GWS) APIs
Know your serverless compute platforms
● Google App Engine — deploy source-based web applications or
mobile backends to the cloud without concerns of servers or
autoscaling (PaaS—app-hosting in the cloud)
● Cloud Functions — for scenarios where you may not have an entire
app; great for microservices, one-off utilities, or event-driven
functions (FaaS/PaaS—function-hosting in the cloud)
● Cloud Run — serverless containers (any language, library, binary) along
with convenience of serverless; use with Docker or "containerless"
w/Cloud Buildpacks (CaaS—container-hosting in the cloud)
● Google Apps Script — Customized JavaScript runtime for automation,
and extension & integration with Workspace plus other Google &
external services ("restricted" PaaS)
Google Compute Engine, Google Cloud Storage
AWS EC2 & S3; Rackspace; Joyent
SaaS
Software as a Service
PaaS
Platform as a Service
IaaS
Infrastructure as a Service
Google Workspace (was G Suite/Google Apps)
Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365
Google App Engine, Cloud Functions
Heroku, Cloud Foundry, Engine Yard, AWS Lambda
Google BigQuery, Cloud SQL,
Cloud Datastore, NL, Vision, Pub/Sub
AWS Kinesis, RDS; Windows Azure SQL, Docker
Serverless: PaaS-y compute/processing
Google Apps Script
Salesforce Platform (formerly force.com)
03
Introduction to
Google Apps Script
Automate & extend Workspace apps
and other Google & external services
+JavaScript
-API “flavor”
+built-in
“flavor”
-OAuth2 (you)
!=
JS
But it's not your Daddy's JavaScript...
Google Apps Script is a serverless
JavaScript runtime for automation, and
extension & integration with Google
Workspace (formerly G Suite), Google,
or other external services.
What can you do with Apps Script?
Simple, < 10 lines Complex, > 1000 lines
Sheets
function
Web app that sends email,
creates calendar invites, &
sends out customized
docs
Anything in between
For Google services...
… each is a JavaScript class
Workspace, other Google, and external services
Google Workspace
Admin SDK
Calendar
Classroom
Contacts
Docs
Drive
Forms
Gmail
Groups
Sites
Sheets
Tasks
Other Google services
AdSense
Analytics
BigQuery
Data Studio
Doubleclick Campaigns
Maps
Mirror (Glass)
People
Shopping Content
Tag Manager
Translate (Language)
YouTube
External services
UrlFetch
JDBC
… and more…
Types of Apps Scripts
● Standalone scripts
○ script.google.com
○ Drive: +New ⇒ More ⇒ Google Apps Script
● Add-ons and document-bound scripts
○ Extensions ⇒ Apps Script
○ Extensions ⇒ Add-ons ⇒ Get/Manage add-ons
● Simple web apps and classic Sites-bound gadgets
○ More ⇒ Manage Site ⇒ Apps Script ⇒ Add new script
Document-bound scripts
Tied to specific documents, i.e., Google
Docs, Sheets, Slides, and Forms. Calls
unique to doc types:
● getActiveCell() — Sheets
● getCursor() — Docs
● createPresentation() — Slides
Add-ons: specific type of document-
bound scripts. Gmail is special.
Gmail Add-ons not tied to documents
but individual email threads.
Use case categories
Enterprise workflows
Resource management
Automation
Reporting
Third-party integrations
Domain administration
Document approval, purchase orders
Timekeeping, helpdesk, project tracking, billing
Calendaring, mail merge, complex spreadsheets
Dashboards, automated report generation
CRM, accounting, marketing, telephony, HR, social
User management, provisioning, and reset
Teachers’ tools(i.e., GFormIt, Flubaroo, Doctopus)
Automation(i.e., mail merge)
Enterprise workflow(i.e., team OoO calendars)
Productize & distribute
“Our online diagram application
makes it easy to sketch and share
professional flowchart diagrams.
That’s why millions of users choose
Lucidchart.”
● lucidchart.com
● cloud.google.com/blog/products/appli
cation-development/q-behind-scenes
-with-lucidchart
● lucidchart.com/blog/announcing-
lucidchart-diagrams-for-google-slides
Diagram & drawing tool
04
Coding with
Apps Script
Basic scripts & custom
functions
Good spreadsheet software...
… has useful functions
Spreadsheets… any magic functions?
Sure, how about GOOGLEFINANCE()?
Spreadsheets… can you code them?
Sure, if you know where to look...
“Hello World!” in Apps Script
Sheets-bound “Hello World!”
Apps Script intro
goo.gl/1sXeuD
t.co/rqHT2gYN6z
Leverage Google-only functionality
But I want (to write) my own function!
Creating my own ("custom") function!
Bitcoin sample
bit.ly/2kMbH1C
Woo-hoo… using my own function!
What can you do with this?
Accessing maps from
spreadsheets?!?
goo.gl/oAzBN9
This… with help from Google Maps & Gmail
function sendMap() {
var sheet = SpreadsheetApp.getActiveSheet();
var address = sheet.getRange("A2").getValue();
var map = Maps.newStaticMap().addMarker(address);
GmailApp.sendEmail('friend@example.com', 'Map',
'See below.', {attachments:[map]});
}
JS
g.co/codelabs/apps-script-intro
05
Advanced topics
Add-ons, Chat bots/apps,
Advanced services, UrlFetch, etc.
● Extend functionality of GWS apps
● Embed your app within Google's!
● 2014: Google Docs, Sheets, Forms
● 2017: Google Slides, Gmail
● 2018: Google Chat (apps/bots)
● Apps Script also powers Looker/Data
Studio community connectors, and
Google Ads scripts
Apps Script powers add-ons… and more!
Converting bound script to add-on
// When the document is opened...
function onOpen(e) {
DocumentApp.getUi().createAddonMenu()
.addItem('Start', 'showSidebar')
.addToUi();
}
// When the add-on is installed...
function onInstall(e) {
onOpen(e);
}
// Open sidebar in document with add-on UI
function showSidebar() {
var ui = HtmlService.createHtmlOutputFromFile('Sidebar')
.setTitle('Translate');
DocumentApp.getUi().showSidebar(ui);
}
// ...everything else in your document-bound script...
Developer caveat
● Understand authorization lifecycle
● developers.google.com/apps-script/add-ons/lifecycle
Generating Google Slides from images
var NAME = "My favorite images";
var deck = SlidesApp.getActivePresentation();
function addImageSlide(link, index) {
var slide = deck.appendSlide(SlidesApp.PredefinedLayout.BLANK);
var image = slide.insertImage(link);
}
function main() {
var images = [
"http://www.google.com/services/images/phone-animation-results_2x.png",
"http://www.google.com/services/images/section-work-card-img_2x.jpg",
"http://gsuite.google.com/img/icons/product-lockup.png",
"http://gsuite.google.com/img/home-hero_2x.jpg",
];
var [title, subtitle] = deck.getSlides()[0].getPageElements();
title.asShape().getText().setText(NAME);
subtitle.asShape().getText().setText("Google Apps ScriptnSlides Service demo");
images.forEach(addImageSlide);
}
Introducing
Slides Add-ons
goo.gl/sYL5AM
Generating Google Slides from images
Expense
reports...
● Expense reports
● Can't we do them
without leaving Gmail?
● On Web AND mobile?
● At your desk or on the road
● One place to complete
your expense report
● One code base
Gmail Add-ons
Expediting expense
reports
goo.gl/KUVCDu
● Not just for conversations
● Create microservice utilities
● Build chat bots to...
○ Automate workflows
○ Query for information
○ Other heavy-lifting
● Plain text or rich UI "cards"
● Very flexible ("any")
development environment
○ POST to HTTP port
Google Chat bots
(bot framework & API)
“I got to work deploying a
light-weight Flask app server…
and in less than an hour had a
working chatbot.”
Greg Meyers, Motorola Solutions CIO
goo.gl/1QeG51
Build bots for anyone, your org or your team… FAST
Traditional API workflow
Traditional APIs vs. Bot architecture
OAuth2
Bot architecture
"Hello World" (echo bot)
JavaScript: Google Apps Script
function onMessage(m) {
return {
'text': 'Hi ' + m.sender.displayName + '. You sent: ' + m.text,
'thread': {'name': m.thread.name}
};
}
Google Chat bots
goo.gl/jt3FqK
function onMessage(e) {
return createMessage(e.user.displayName, 0);
}
function onCardClick(e) {
// Create a new vote card when 'NEW' button is clicked.
if (e.action.actionMethodName === 'newvote') {
return createMessage(e.user.displayName, 0);
}
// Updates the card in-place when '+1' or '-1' button is clicked.
var voteCount = +e.action.parameters[0].value;
e.action.actionMethodName === 'upvote' ? ++voteCount : --voteCount;
return createMessage(e.user.displayName, voteCount, true);
}
Simple vote bot
JavaScript: Google Apps Script
}, {
textButton: {
text: '-1',
onClick: {
action: {
actionMethodName: 'downvote',
parameters: parameters
}
}
}
}, {
textButton: {
text: 'NEW',
onClick: {
action: {
actionMethodName: 'newvote'
}
}
}
}]
}]
}]
}]
};
}
function createMessage(voter, voteCount, shouldUpdate) {
var parameters = [{key: 'count', value: voteCount.toString()}];
return {
actionResponse: {
type: shouldUpdate ? 'UPDATE_MESSAGE' : 'NEW_MESSAGE'
},
cards: [{
header: {
title: 'Last vote by ' + voter + '!'
},
sections: [{
widgets: [{
textParagraph: {
text: voteCount + ' votes!'
}
}, {
buttons: [{
textButton: {
text: '+1',
onClick: {
action: {
actionMethodName: 'upvote',
parameters: parameters
}
}
}
Google Chat bots
goo.gl/jt3FqK
Vote bot interactive card
● Job: track your corporate
video performance
● Do you really want to go to
every video on YouTube &
write down the view count?
● NO WAY! Automate stats
gathering with Apps Script!
A day at the office counting up YouTube statistics
Automating YT stats
goo.gl/nKfBQi
goo.gl/SVxoCt
function getVideoInfo() {
var sheet = SpreadsheetApp.getActiveSheet();
var vid = sheet.getRange("A2").getValue();
var data = YouTube.Videos.list(
'snippet, statistics', {id: vid});
var item = data.items[0];
var info = [
item.snippet.title, item.statistics.viewCount];
sheet.getRange("B2:C2").setValues([info]);
}
Automating YouTube stats with Apps Script
const PROMPT = 'Describe a cat in a few sentences';
const MODEL = 'gemini-pro';
const scriptProperties = PropertiesService.getScriptProperties();
const apiKey = scriptProperties.getProperty('API_KEY');
const GEM_API_URL = 'https://generativelanguage.googleapis.com/' +
`v1beta/models/${MODEL}:generateContent?key=${apiKey}`;
function helloGemini() {
console.log(`** GenAI text: "${MODEL}" model & prompt "${PROMPT}"`);
const payload = {contents: [{parts: [{text: PROMPT}]}]};
const options = {payload: JSON.stringify(payload), contentType: "application/json"};
const response = UrlFetchApp.fetch(GEM_API_URL, options);
const obj = JSON.parse(response.getContentText());
if (obj.candidates.length > 0 && obj.candidates[0].content.parts.length > 0) {
console.log(obj.candidates[0].content.parts[0].text);
}
}
Google AI: Gemini API (Apps Script)
Apps Script
& Gemini API
● Command-line interface
● Integrate with git plus
your local IDE/dev env.
● Actions
○ Create
○ Pull
○ Push
○ Clone
○ Deploy
○ View logs
● Built on Apps Script API
● developers.google.com/a
pps-script/guides/clasp
Professional workflow with clasp tool
06
Inspiration
What you can build with Apps
Script & Google APIs
Big data analysis to slide presentation
Access GCP tools from Google Workspace (formerly G Suite)
Store big data results
Visualize big data results
Ingest data from Sheets
Link to chart in Sheets
Supercharge Workspace (G Suite) with GCP
Workspace (G Suite) GCP
BigQuery
Apps Script
Slides Sheets
Application
request
Big data
analytics
App summary
● Leverage GCP and build the "final mile" with Google Workspace (formerly G Suite)
● Driven by Google Apps Script
● Google BigQuery for data analysis
● Google Sheets for visualization
● Google Slides for presentable results
● "Glued" together w/Google Workspace (formerly G Suite) serverless
● Build this app (codelab): g.co/codelabs/bigquery-sheets-slides
● Video and blog post: bit.ly/2OcptaG
● Application source code: github.com/googlecodelabs/bigquery-sheets-slides
● Presented at Google Cloud NEXT (Jul 2018 [DEV229] & Apr 2019 [DEV212])
● cloud.withgoogle.com/next18/sf/sessions/session/156878
● cloud.withgoogle.com/next/sf/sessions?session=DEV212
Lightweight sales inventory web app
Help on-floor sales connect to backoffice
Sheets
Lightweight inventory management system
Cloud
Functions
Cloud
Vision
Google Workspace
(formerly G Suite)
GCP
Export
data
Cloud
Functions
Apps Script
Cloud
Storage
Get
inventory
Cloud
Pub/Sub
Analyze
image
Store
image
Update
shoe
CRUD
inventory
Cloud
SQL
App summary
● Motivation
● Help sales floor staff with store inventory information
● GCP helps Sheets scale and provide machine learning capabilities
● Web interface for scale and convenience
● Use Google Workspace (formerly G Suite) and GCP APIs to:
● Build friendly web interface (mobile or computer)
● Export Sheets data into Cloud SQL
● Allow users to make information requests
● Add intelligence to data and enhance user experience
● Cloud Functions microservices leveraging Sheets as "glue tool" for user experience
● Application source code: github.com/asrivas/Next2019
● "Serverless from the Ground Up with GCP & Google Workspace" (Cloud NEXT '19)
● youtu.be/NvCM7OC_5pA
07
Wrap-up
Summary & resources
Apps Script summary
● It’s just JavaScript
● Access to Google plus other online resources
● No API complexity… use authenticated, built-in services
● Serverless… no setup nor deployment required
● Variety of use cases
● Execution as scripts or add-ons
● No longer Google's best kept secret?!?
Apps Script references + next steps
● Introductory Apps Script codelab
○ g.co/codelabs/apps-script-intro
● Creating your own (custom) functions
○ developers.google.com/apps-script/guides/sheets/functions
● Developer videos, guides, and tutorials
○ developers.google.com/apps-script/guides/videos
● High-level introductory video
○ youtu.be/xDovB0pu4OU
● Official documentation site
○ developers.google.com/apps-script
● Alternative: Google Workspace APIs
○ developers.google.com/gsuite
Other Google APIs & platforms
● GCP (cloud-based compute, storage, networking, AI/ML, data analysis tools!)
○ cloud.google.com
● Firebase (mobile development platform and RT DB plus ML-Kit)
○ firebase.google.com and firebase.google.com/docs/ml-kit
● Google Data Studio (data visualization, dashboards, etc.)
○ datastudio.google.com/overview
○ goo.gle/datastudio-course
● Actions on Google/Assistant/DialogFlow (voice apps)
○ developers.google.com/actions
● YouTube (Data, Analytics, and Livestreaming APIs)
○ developers.google.com/youtube
● Google Maps (Maps, Routes, and Places APIs)
○ developers.google.com/maps
● Flutter (native apps [Android, iOS, web] w/1 code base[!])
○ flutter.dev
Bring me to your organization
... it is my job to help you!
● Engineering consulting
● Software development
● Technical seminars/tech talks
● Hands-on workshops
● Technical training courses
● Migration strategy & planning
● cyberwebconsulting.com
● appenginemigrations.com
Slides
you're looking at
them now
Work
cyberwebconsulting.com
Books
corepython.com
Blog
dev.to/wescpy
Intro post+video
t.co/rqHT2gYN6z
Automate YT stats
goo.gl/nKfBQi
goo.gl/SVxoCt
Big data ⇒ slides
bit.ly/2O9KqDd
Progress bars
goo.gl/69EJVw
Thank you! Questions?
Wesley Chun
Principal Consultant, CyberWeb
Python, GCP & GWS specialist
CONTACT: @wescpy@

Mais conteúdo relacionado

Semelhante a Automating Google Workspace (GWS) & more with Apps Script

Semelhante a Automating Google Workspace (GWS) & more with Apps Script (20)

Cloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google CloudCloud computing overview & running your code on Google Cloud
Cloud computing overview & running your code on Google Cloud
 
Intro to cloud computing & running your code on Google Cloud
Intro to cloud computing & running your code on Google CloudIntro to cloud computing & running your code on Google Cloud
Intro to cloud computing & running your code on Google Cloud
 
Serverless Computing with Python
Serverless Computing with PythonServerless Computing with Python
Serverless Computing with Python
 
Powerful Google Cloud tools for your hack
Powerful Google Cloud tools for your hackPowerful Google Cloud tools for your hack
Powerful Google Cloud tools for your hack
 
How Google Cloud Platform can help in the classroom/lab
How Google Cloud Platform can help in the classroom/labHow Google Cloud Platform can help in the classroom/lab
How Google Cloud Platform can help in the classroom/lab
 
Build with ALL of Google Cloud
Build with ALL of Google CloudBuild with ALL of Google Cloud
Build with ALL of Google Cloud
 
Google Technical Webinar - Building Mashups with Google Apps and SAP, using S...
Google Technical Webinar - Building Mashups with Google Apps and SAP, using S...Google Technical Webinar - Building Mashups with Google Apps and SAP, using S...
Google Technical Webinar - Building Mashups with Google Apps and SAP, using S...
 
Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)Powerful Google developer tools for immediate impact! (2023-24 A)
Powerful Google developer tools for immediate impact! (2023-24 A)
 
Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)Google Cloud @ Hackathons (2020)
Google Cloud @ Hackathons (2020)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Serverless Computing with Google Cloud
Serverless Computing with Google CloudServerless Computing with Google Cloud
Serverless Computing with Google Cloud
 
Google Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacksGoogle Cloud lightning talk @MHacks
Google Cloud lightning talk @MHacks
 
Serverless computing with Google Cloud
Serverless computing with Google CloudServerless computing with Google Cloud
Serverless computing with Google Cloud
 
Logic Apps and Azure Functions for Serverless Integration (2017-03-25)
Logic Apps and Azure Functions for Serverless Integration (2017-03-25)Logic Apps and Azure Functions for Serverless Integration (2017-03-25)
Logic Apps and Azure Functions for Serverless Integration (2017-03-25)
 
Google's serverless journey: past to present
Google's serverless journey: past to presentGoogle's serverless journey: past to present
Google's serverless journey: past to present
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
Exploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overviewExploring Google (Cloud) APIs & Cloud Computing overview
Exploring Google (Cloud) APIs & Cloud Computing overview
 
Serverless Computing with Google Cloud
Serverless Computing with Google CloudServerless Computing with Google Cloud
Serverless Computing with Google Cloud
 
Accessing Google Cloud APIs
Accessing Google Cloud APIsAccessing Google Cloud APIs
Accessing Google Cloud APIs
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 

Mais de wesley chun

Mais de wesley chun (14)

Easy path to machine learning (2023-2024)
Easy path to machine learning (2023-2024)Easy path to machine learning (2023-2024)
Easy path to machine learning (2023-2024)
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
 
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIsExploring Google APIs 102: Cloud vs. non-GCP Google APIs
Exploring Google APIs 102: Cloud vs. non-GCP Google APIs
 
Easy path to machine learning (2022)
Easy path to machine learning (2022)Easy path to machine learning (2022)
Easy path to machine learning (2022)
 
Google... more than just a cloud
Google... more than just a cloudGoogle... more than just a cloud
Google... more than just a cloud
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Image archive, analysis & report generation with Google Cloud
Image archive, analysis & report generation with Google CloudImage archive, analysis & report generation with Google Cloud
Image archive, analysis & report generation with Google Cloud
 
Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)Easy path to machine learning (Spring 2021)
Easy path to machine learning (Spring 2021)
 
Run your code serverlessly on Google's open cloud
Run your code serverlessly on Google's open cloudRun your code serverlessly on Google's open cloud
Run your code serverlessly on Google's open cloud
 
Introduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google CloudIntroduction to Cloud Computing with Google Cloud
Introduction to Cloud Computing with Google Cloud
 
Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2020)Easy path to machine learning (Spring 2020)
Easy path to machine learning (Spring 2020)
 
Exploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScriptExploring Google (Cloud) APIs with Python & JavaScript
Exploring Google (Cloud) APIs with Python & JavaScript
 
Google Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScriptGoogle Apps Script: Accessing G Suite & other Google services with JavaScript
Google Apps Script: Accessing G Suite & other Google services with JavaScript
 
Easy path to machine learning
Easy path to machine learningEasy path to machine learning
Easy path to machine learning
 

Último

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
FIDO Alliance
 

Último (20)

AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024Long journey of Ruby Standard library at RubyKaigi 2024
Long journey of Ruby Standard library at RubyKaigi 2024
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdfSimplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
Simplified FDO Manufacturing Flow with TPMs _ Liam at Infineon.pdf
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 

Automating Google Workspace (GWS) & more with Apps Script

  • 1. Automating Google Workspace (GWS) & more with Apps Script: Making the most of Gmail, Google Drive, Calendar, Docs, Sheets, Slides, Forms, Chat & other services Wesley Chun - @wescpy@ Principal, CyberWeb 3 Principal Consultant, CyberWeb ● Mission: produce accelerated Python developers, enable developers to be successful using Google Cloud and other Google developer tools & APIs ● Focus: Python, Google Cloud (GCP) & Google Workspace (GWS) APIs; GAE migrations; Google X-product sol'ns ● Services: technical consulting, training, engineering, speaking, code samples, hands-on tutorials, public technical content (blogs, social, etc.) About the speaker Previous experience / background ● Software Engineer & Developer Advocate ○ Google, Sun, HP, Cisco, EMC, Xilinx & ○ Original Yahoo!Mail engineer/SWE ● Technical trainer, teacher, instructor ○ Teaching Math, Linux, Python since '83 ○ Adjunct CS Faculty at local SV colleges ● Python community member ○ Popular Core Python series author ○ Python Software Foundation Fellow ● AB (Math/CS) & CMP (Music/Piano), UC Berkeley and MSCS, UC Santa Barbara ● Adjunct Computer Science Faculty, Foothill College (Silicon Valley) GWS Dev Show goo.gl/JpBQ40 GAE migration bit.ly/3xk2Swi
  • 2. Apps Script: why & agenda ● Google provides APIs giving programmatic access to its technologies ○ Its use can be challenging: REST, OAuth2, HTTP, authentication, etc. ● Apps Script: a developer "tool for everyone;" high-level API access ○ "Low code" solution via customized serverless, JavaScript runtime ○ Lets you automate & extend GWS, and ultimately, get the job done Cloud computing review 1 Google serverless platforms 2 Introduction to Apps Script 3 Coding with Apps Script 4 5 Advanced topics 7 Wrap-up 6 Inspiration 01 Cloud computing overview All you need to know about the cloud
  • 3. What is cloud computing? spar Google Compute Engine, Cloud Storage AWS EC2 & S3; Rackspace; Joyent Cloud service levels/"pillars" SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google BigQuery, Cloud SQL, Vertex AI, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Apps Script Salesforce Platform (formerly force.com) Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda
  • 4. Google Compute Engine, Cloud Storage AWS EC2 & S3; Rackspace; Joyent Outsourcing of apps (SaaS) SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google BigQuery, Cloud SQL, Vertex AI, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Apps Script Salesforce Platform (formerly force.com) Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google Compute Engine, Cloud Storage AWS EC2 & S3; Rackspace; Joyent Outsourcing of hardware (IaaS) SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google BigQuery, Cloud SQL, Vertex AI, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Apps Script Salesforce Platform (formerly force.com) Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda
  • 5. Google Compute Engine, Cloud Storage AWS EC2 & S3; Rackspace; Joyent Outsourcing of logic-hosting (PaaS) SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google BigQuery, Cloud SQL, Vertex AI, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Apps Script Salesforce Platform (formerly force.com) Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda Google BigQuery, Cloud SQL, Vertex AI, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Compute Engine, Cloud Storage AWS EC2 & S3; Rackspace; Joyent IaaS/PaaS gray area (DataB/S/P-aaS?) SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google Apps Script Salesforce Platform (formerly force.com) Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda
  • 6. Google Compute Engine, Cloud Storage AWS EC2 & S3; Rackspace; Joyent SaaS/PaaS gray area SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google BigQuery, Cloud SQL, Vertex AI, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda Google Apps Script Salesforce Platform (formerly force.com) Summary of responsibility SaaS Software as a Service Applications Data Runtime Middleware OS Virtualization Servers Storage Networking Applications Data Runtime Middleware OS Virtualization Servers Storage Networking IaaS Infrastructure as a Service Applications Data Runtime Middleware OS Virtualization Servers Storage Networking PaaS Platform as a Service Managed by YOU Managed by cloud vendor Applications Data Runtime Middleware OS Virtualization Servers Storage Networking on-prem all you, no cloud
  • 8. ● GWS developer home: developers.google.com/gsuite ● GWS developer intro: youtu.be/NqumcYgj5LI ● GWS REST APIs: youtu.be/2VpvWhDdXsI ● GWS Apps Script: youtu.be/xDovB0pu4OU ● Comprehensive overview: youtu.be/kkp0aNGlynw Google Workspace (formerly G Suite and Google Apps) (GWS) APIs Know your serverless compute platforms ● Google App Engine — deploy source-based web applications or mobile backends to the cloud without concerns of servers or autoscaling (PaaS—app-hosting in the cloud) ● Cloud Functions — for scenarios where you may not have an entire app; great for microservices, one-off utilities, or event-driven functions (FaaS/PaaS—function-hosting in the cloud) ● Cloud Run — serverless containers (any language, library, binary) along with convenience of serverless; use with Docker or "containerless" w/Cloud Buildpacks (CaaS—container-hosting in the cloud) ● Google Apps Script — Customized JavaScript runtime for automation, and extension & integration with Workspace plus other Google & external services ("restricted" PaaS)
  • 9. Google Compute Engine, Google Cloud Storage AWS EC2 & S3; Rackspace; Joyent SaaS Software as a Service PaaS Platform as a Service IaaS Infrastructure as a Service Google Workspace (was G Suite/Google Apps) Yahoo!Mail, Hotmail, Salesforce, Netsuite, Office 365 Google App Engine, Cloud Functions Heroku, Cloud Foundry, Engine Yard, AWS Lambda Google BigQuery, Cloud SQL, Cloud Datastore, NL, Vision, Pub/Sub AWS Kinesis, RDS; Windows Azure SQL, Docker Serverless: PaaS-y compute/processing Google Apps Script Salesforce Platform (formerly force.com) 03 Introduction to Google Apps Script Automate & extend Workspace apps and other Google & external services
  • 11. JS But it's not your Daddy's JavaScript... Google Apps Script is a serverless JavaScript runtime for automation, and extension & integration with Google Workspace (formerly G Suite), Google, or other external services.
  • 12. What can you do with Apps Script? Simple, < 10 lines Complex, > 1000 lines Sheets function Web app that sends email, creates calendar invites, & sends out customized docs Anything in between For Google services...
  • 13. … each is a JavaScript class Workspace, other Google, and external services Google Workspace Admin SDK Calendar Classroom Contacts Docs Drive Forms Gmail Groups Sites Sheets Tasks Other Google services AdSense Analytics BigQuery Data Studio Doubleclick Campaigns Maps Mirror (Glass) People Shopping Content Tag Manager Translate (Language) YouTube External services UrlFetch JDBC … and more…
  • 14. Types of Apps Scripts ● Standalone scripts ○ script.google.com ○ Drive: +New ⇒ More ⇒ Google Apps Script ● Add-ons and document-bound scripts ○ Extensions ⇒ Apps Script ○ Extensions ⇒ Add-ons ⇒ Get/Manage add-ons ● Simple web apps and classic Sites-bound gadgets ○ More ⇒ Manage Site ⇒ Apps Script ⇒ Add new script Document-bound scripts Tied to specific documents, i.e., Google Docs, Sheets, Slides, and Forms. Calls unique to doc types: ● getActiveCell() — Sheets ● getCursor() — Docs ● createPresentation() — Slides Add-ons: specific type of document- bound scripts. Gmail is special. Gmail Add-ons not tied to documents but individual email threads.
  • 15. Use case categories Enterprise workflows Resource management Automation Reporting Third-party integrations Domain administration Document approval, purchase orders Timekeeping, helpdesk, project tracking, billing Calendaring, mail merge, complex spreadsheets Dashboards, automated report generation CRM, accounting, marketing, telephony, HR, social User management, provisioning, and reset Teachers’ tools(i.e., GFormIt, Flubaroo, Doctopus)
  • 16. Automation(i.e., mail merge) Enterprise workflow(i.e., team OoO calendars)
  • 17. Productize & distribute “Our online diagram application makes it easy to sketch and share professional flowchart diagrams. That’s why millions of users choose Lucidchart.” ● lucidchart.com ● cloud.google.com/blog/products/appli cation-development/q-behind-scenes -with-lucidchart ● lucidchart.com/blog/announcing- lucidchart-diagrams-for-google-slides Diagram & drawing tool
  • 18. 04 Coding with Apps Script Basic scripts & custom functions Good spreadsheet software...
  • 19. … has useful functions Spreadsheets… any magic functions?
  • 20. Sure, how about GOOGLEFINANCE()? Spreadsheets… can you code them?
  • 21. Sure, if you know where to look... “Hello World!” in Apps Script
  • 22. Sheets-bound “Hello World!” Apps Script intro goo.gl/1sXeuD t.co/rqHT2gYN6z Leverage Google-only functionality
  • 23. But I want (to write) my own function! Creating my own ("custom") function! Bitcoin sample bit.ly/2kMbH1C
  • 24. Woo-hoo… using my own function! What can you do with this?
  • 25. Accessing maps from spreadsheets?!? goo.gl/oAzBN9 This… with help from Google Maps & Gmail function sendMap() { var sheet = SpreadsheetApp.getActiveSheet(); var address = sheet.getRange("A2").getValue(); var map = Maps.newStaticMap().addMarker(address); GmailApp.sendEmail('friend@example.com', 'Map', 'See below.', {attachments:[map]}); } JS g.co/codelabs/apps-script-intro
  • 26. 05 Advanced topics Add-ons, Chat bots/apps, Advanced services, UrlFetch, etc. ● Extend functionality of GWS apps ● Embed your app within Google's! ● 2014: Google Docs, Sheets, Forms ● 2017: Google Slides, Gmail ● 2018: Google Chat (apps/bots) ● Apps Script also powers Looker/Data Studio community connectors, and Google Ads scripts Apps Script powers add-ons… and more!
  • 27. Converting bound script to add-on // When the document is opened... function onOpen(e) { DocumentApp.getUi().createAddonMenu() .addItem('Start', 'showSidebar') .addToUi(); } // When the add-on is installed... function onInstall(e) { onOpen(e); } // Open sidebar in document with add-on UI function showSidebar() { var ui = HtmlService.createHtmlOutputFromFile('Sidebar') .setTitle('Translate'); DocumentApp.getUi().showSidebar(ui); } // ...everything else in your document-bound script... Developer caveat ● Understand authorization lifecycle ● developers.google.com/apps-script/add-ons/lifecycle Generating Google Slides from images
  • 28. var NAME = "My favorite images"; var deck = SlidesApp.getActivePresentation(); function addImageSlide(link, index) { var slide = deck.appendSlide(SlidesApp.PredefinedLayout.BLANK); var image = slide.insertImage(link); } function main() { var images = [ "http://www.google.com/services/images/phone-animation-results_2x.png", "http://www.google.com/services/images/section-work-card-img_2x.jpg", "http://gsuite.google.com/img/icons/product-lockup.png", "http://gsuite.google.com/img/home-hero_2x.jpg", ]; var [title, subtitle] = deck.getSlides()[0].getPageElements(); title.asShape().getText().setText(NAME); subtitle.asShape().getText().setText("Google Apps ScriptnSlides Service demo"); images.forEach(addImageSlide); } Introducing Slides Add-ons goo.gl/sYL5AM Generating Google Slides from images Expense reports... ● Expense reports ● Can't we do them without leaving Gmail? ● On Web AND mobile?
  • 29. ● At your desk or on the road ● One place to complete your expense report ● One code base Gmail Add-ons Expediting expense reports goo.gl/KUVCDu ● Not just for conversations ● Create microservice utilities ● Build chat bots to... ○ Automate workflows ○ Query for information ○ Other heavy-lifting ● Plain text or rich UI "cards" ● Very flexible ("any") development environment ○ POST to HTTP port Google Chat bots (bot framework & API)
  • 30. “I got to work deploying a light-weight Flask app server… and in less than an hour had a working chatbot.” Greg Meyers, Motorola Solutions CIO goo.gl/1QeG51 Build bots for anyone, your org or your team… FAST Traditional API workflow Traditional APIs vs. Bot architecture OAuth2 Bot architecture
  • 31. "Hello World" (echo bot) JavaScript: Google Apps Script function onMessage(m) { return { 'text': 'Hi ' + m.sender.displayName + '. You sent: ' + m.text, 'thread': {'name': m.thread.name} }; } Google Chat bots goo.gl/jt3FqK function onMessage(e) { return createMessage(e.user.displayName, 0); } function onCardClick(e) { // Create a new vote card when 'NEW' button is clicked. if (e.action.actionMethodName === 'newvote') { return createMessage(e.user.displayName, 0); } // Updates the card in-place when '+1' or '-1' button is clicked. var voteCount = +e.action.parameters[0].value; e.action.actionMethodName === 'upvote' ? ++voteCount : --voteCount; return createMessage(e.user.displayName, voteCount, true); } Simple vote bot JavaScript: Google Apps Script
  • 32. }, { textButton: { text: '-1', onClick: { action: { actionMethodName: 'downvote', parameters: parameters } } } }, { textButton: { text: 'NEW', onClick: { action: { actionMethodName: 'newvote' } } } }] }] }] }] }; } function createMessage(voter, voteCount, shouldUpdate) { var parameters = [{key: 'count', value: voteCount.toString()}]; return { actionResponse: { type: shouldUpdate ? 'UPDATE_MESSAGE' : 'NEW_MESSAGE' }, cards: [{ header: { title: 'Last vote by ' + voter + '!' }, sections: [{ widgets: [{ textParagraph: { text: voteCount + ' votes!' } }, { buttons: [{ textButton: { text: '+1', onClick: { action: { actionMethodName: 'upvote', parameters: parameters } } } Google Chat bots goo.gl/jt3FqK Vote bot interactive card ● Job: track your corporate video performance ● Do you really want to go to every video on YouTube & write down the view count? ● NO WAY! Automate stats gathering with Apps Script! A day at the office counting up YouTube statistics Automating YT stats goo.gl/nKfBQi goo.gl/SVxoCt
  • 33. function getVideoInfo() { var sheet = SpreadsheetApp.getActiveSheet(); var vid = sheet.getRange("A2").getValue(); var data = YouTube.Videos.list( 'snippet, statistics', {id: vid}); var item = data.items[0]; var info = [ item.snippet.title, item.statistics.viewCount]; sheet.getRange("B2:C2").setValues([info]); } Automating YouTube stats with Apps Script const PROMPT = 'Describe a cat in a few sentences'; const MODEL = 'gemini-pro'; const scriptProperties = PropertiesService.getScriptProperties(); const apiKey = scriptProperties.getProperty('API_KEY'); const GEM_API_URL = 'https://generativelanguage.googleapis.com/' + `v1beta/models/${MODEL}:generateContent?key=${apiKey}`; function helloGemini() { console.log(`** GenAI text: "${MODEL}" model & prompt "${PROMPT}"`); const payload = {contents: [{parts: [{text: PROMPT}]}]}; const options = {payload: JSON.stringify(payload), contentType: "application/json"}; const response = UrlFetchApp.fetch(GEM_API_URL, options); const obj = JSON.parse(response.getContentText()); if (obj.candidates.length > 0 && obj.candidates[0].content.parts.length > 0) { console.log(obj.candidates[0].content.parts[0].text); } } Google AI: Gemini API (Apps Script)
  • 34. Apps Script & Gemini API ● Command-line interface ● Integrate with git plus your local IDE/dev env. ● Actions ○ Create ○ Pull ○ Push ○ Clone ○ Deploy ○ View logs ● Built on Apps Script API ● developers.google.com/a pps-script/guides/clasp Professional workflow with clasp tool
  • 35. 06 Inspiration What you can build with Apps Script & Google APIs Big data analysis to slide presentation Access GCP tools from Google Workspace (formerly G Suite)
  • 36. Store big data results
  • 37. Visualize big data results Ingest data from Sheets
  • 38. Link to chart in Sheets
  • 39. Supercharge Workspace (G Suite) with GCP Workspace (G Suite) GCP BigQuery Apps Script Slides Sheets Application request Big data analytics App summary ● Leverage GCP and build the "final mile" with Google Workspace (formerly G Suite) ● Driven by Google Apps Script ● Google BigQuery for data analysis ● Google Sheets for visualization ● Google Slides for presentable results ● "Glued" together w/Google Workspace (formerly G Suite) serverless ● Build this app (codelab): g.co/codelabs/bigquery-sheets-slides ● Video and blog post: bit.ly/2OcptaG ● Application source code: github.com/googlecodelabs/bigquery-sheets-slides ● Presented at Google Cloud NEXT (Jul 2018 [DEV229] & Apr 2019 [DEV212]) ● cloud.withgoogle.com/next18/sf/sessions/session/156878 ● cloud.withgoogle.com/next/sf/sessions?session=DEV212
  • 40. Lightweight sales inventory web app Help on-floor sales connect to backoffice
  • 41. Sheets Lightweight inventory management system Cloud Functions Cloud Vision Google Workspace (formerly G Suite) GCP Export data Cloud Functions Apps Script Cloud Storage Get inventory Cloud Pub/Sub Analyze image Store image Update shoe CRUD inventory Cloud SQL App summary ● Motivation ● Help sales floor staff with store inventory information ● GCP helps Sheets scale and provide machine learning capabilities ● Web interface for scale and convenience ● Use Google Workspace (formerly G Suite) and GCP APIs to: ● Build friendly web interface (mobile or computer) ● Export Sheets data into Cloud SQL ● Allow users to make information requests ● Add intelligence to data and enhance user experience ● Cloud Functions microservices leveraging Sheets as "glue tool" for user experience ● Application source code: github.com/asrivas/Next2019 ● "Serverless from the Ground Up with GCP & Google Workspace" (Cloud NEXT '19) ● youtu.be/NvCM7OC_5pA
  • 42. 07 Wrap-up Summary & resources Apps Script summary ● It’s just JavaScript ● Access to Google plus other online resources ● No API complexity… use authenticated, built-in services ● Serverless… no setup nor deployment required ● Variety of use cases ● Execution as scripts or add-ons ● No longer Google's best kept secret?!?
  • 43. Apps Script references + next steps ● Introductory Apps Script codelab ○ g.co/codelabs/apps-script-intro ● Creating your own (custom) functions ○ developers.google.com/apps-script/guides/sheets/functions ● Developer videos, guides, and tutorials ○ developers.google.com/apps-script/guides/videos ● High-level introductory video ○ youtu.be/xDovB0pu4OU ● Official documentation site ○ developers.google.com/apps-script ● Alternative: Google Workspace APIs ○ developers.google.com/gsuite Other Google APIs & platforms ● GCP (cloud-based compute, storage, networking, AI/ML, data analysis tools!) ○ cloud.google.com ● Firebase (mobile development platform and RT DB plus ML-Kit) ○ firebase.google.com and firebase.google.com/docs/ml-kit ● Google Data Studio (data visualization, dashboards, etc.) ○ datastudio.google.com/overview ○ goo.gle/datastudio-course ● Actions on Google/Assistant/DialogFlow (voice apps) ○ developers.google.com/actions ● YouTube (Data, Analytics, and Livestreaming APIs) ○ developers.google.com/youtube ● Google Maps (Maps, Routes, and Places APIs) ○ developers.google.com/maps ● Flutter (native apps [Android, iOS, web] w/1 code base[!]) ○ flutter.dev
  • 44. Bring me to your organization ... it is my job to help you! ● Engineering consulting ● Software development ● Technical seminars/tech talks ● Hands-on workshops ● Technical training courses ● Migration strategy & planning ● cyberwebconsulting.com ● appenginemigrations.com Slides you're looking at them now Work cyberwebconsulting.com Books corepython.com Blog dev.to/wescpy Intro post+video t.co/rqHT2gYN6z Automate YT stats goo.gl/nKfBQi goo.gl/SVxoCt Big data ⇒ slides bit.ly/2O9KqDd Progress bars goo.gl/69EJVw Thank you! Questions? Wesley Chun Principal Consultant, CyberWeb Python, GCP & GWS specialist CONTACT: @wescpy@