Google apps script

1,825
-1

Published on

Let's create your business in Google!

Published in: Technology, News & Politics
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
1,825
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
38
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide

Google apps script

  1. 1. Google Apps Script Simon Su
  2. 2. About me... ● Job:MiCloud RD Leader (http: //micloud.tw) ● Skills: ○ Service Architecture ○ Node.js ○ Google Service ● Open Sources: ○ opennodes.arecord.us ○ peihsinsu.blogspot.tw ○ blog.micloud.tw ○ slideshare.net/peihsinsu
  3. 3. We are...
  4. 4. Cloud is Already Exists!
  5. 5. Cloud Changes the Developer Few years ago ● system and os ● network setup ● install what I need ● mail sdk ● sms bridge ● backup and archive ● socket protocol ● building versioning system for develop ● ... Now ● cloud machine ● vpc and permission ● software preload ● email service ● sms service ● object storage ● restful protocal ● git deploy & github in the world ● ...
  6. 6. Our Topic
  7. 7. What does Simple Business in the Cloud need?
  8. 8. Most Small Service Needs: OA + Landing Page + REST Services
  9. 9. What is Apps Script?!
  10. 10. Apps Script Serves By Type ● Standalone Scripts ● Container-Bound Scripts By Function ● Spreadsheet Custom Functions ● Web Apps ● Google Sites Gadgets ● Container Extensions
  11. 11. API Supports ● Google Apps Services ● Calendar ● Contacts ● DocsList ● Document ● Domain ● Drive ● ● ● ● ● ● ● ● Finance Forms Gmail Groups Language Maps Sites Spreadsheet
  12. 12. What you can do with Apps Script? Monitor your Web Google Form integrate Build a RESTful endpoint
  13. 13. First Apps Script Service Monitor using Google Drive ● Idea ○ Using google sheet for data persistance ○ Using apps script UrlFetch to retrieve monitor target resource ● Some Reference ○ http://gappsnews.blogspot.tw/2013/01/google-appsscript-http-monitor.html ○ http://gappsnews.blogspot.tw/2013/03/re-googlegoogle-apps-scriptgoogle-form.html
  14. 14. You will know... ● SpreadsheetApp.openById(...) ○ getSheetByName(...) ○ insertSheet(...) ○ appendRow(...) ● UrlFetchApp.fetch(...)
  15. 15. Piece of Code
  16. 16. Save data to sheet and setting chart
  17. 17. Web / Google Site Integrate
  18. 18. 2nd Apps Script Google Form send notification ● Idea: ○ Send mail notify when form sent ○ Call remote rest when form sent ● Some References: ○ http://gappsnews.blogspot.tw/2013/03/fwd-googleapps-script-event-object.html ○ http://gappsnews.blogspot.tw/2013/02/google-appsscriptgoogle-form.html
  19. 19. You will know... ● SpreadsheetApp.getActiveSheet() ● GmailApp.sendEmail(...) ● JSON ○ Object.keys(jsonObject) ○ JSON.stringify(jsonObject) ○ JSON.parse(string)
  20. 20. Create your form and result sheet Live Form Editor
  21. 21. Create Script for Result Sheet
  22. 22. Piece of Code function notify(){ function getLastRowTable(arr){ var sheet = return jsonObjToTableWithTitle(arr[0], SpreadsheetApp.getActiveSheet(); arr[arr.length-1]); var rows = sheet.getDataRange(); } var values = rows.getValues(); function jsonObjToTableWithTitle(title, row){ var content = getLastRowTable(values); var TRs = ''; var htmlBody = "Hi Admin: <br/><br/>”+ var keys = Object.keys(row); ”有人填表拉,檢 查一下吧! <br/><br/>" + for(var j = 0 ; j < keys.length ; j++) { content + var TR = '<tr>'; “<br/><br/>Send by Google Apps”; var rowvalue = row[keys[j]]; GmailApp.sendEmail( TR += ('<td>' + title[keys[j]] + "your-mail@gmail.com", '</td><td>' + rowvalue + '</td>' ); "Form Submit Confirm Notice", TR+= '</tr>'; htmlBody, TRs += TR; {from: your-mail@gmail.com, } htmlBody:htmlBody} var table = '<table border="1px">' + ); } TRs +'</table>'; return table;
  23. 23. Create the form submit event trigger
  24. 24. Test your form
  25. 25. 3rd Apps Script Build a RESTful Service ● Idea ○ The advance interactive to all clients ● Restrictions ○ base url is fixed, only query and form as patameter can be the input ○ get, post method only (2013.7.21) ○ need solve the HTTP CODE: 302 problem ● Some Reference ○ http://gappsnews.blogspot.tw/2013/07/apps-scriptwith-restful.html ○ http://gappsnews.blogspot.tw/2013/07/fwd-appsscript.html ○ http://gappsnews.blogspot.tw/2013/07/apps-script-
  26. 26. You will know... ● doGet() ● ContentService.createTextOutput(...)
  27. 27. Demo of Using RESTful Piece of Code
  28. 28. Deploy & Publish
  29. 29. Testing in curl URL Pattern:https://script.google. com/macros/s/:id/exec Script ID
  30. 30. Testing in Advance REST Client
  31. 31. Testing in Ajax Code...
  32. 32. Thinking in different... ● Drive application integrate related, scheduling, data present and interactive... ● Static page service (Github Page, Cloud CMS) interactive... ● Mobile devices' remote thin app server, to be a RDB, NDB, BigQuery... middleware ● The chrome extension server side...
  33. 33. Chrome Web Store Connect
  34. 34. Script Gallery
  35. 35. Quota of Apps Script
  36. 36. Other Features Connect to Google Services ● Google Apps ○ Document extension ○ Simple form services ● Google Cloud Platform ○ BigQuery integrate ○ ScriptDB ● External Services ○ Connect with JDBC
  37. 37. Reference ● Apps Script Example: https://developers. google.com/apps-script/case-studies ● Sunset Scripts: https://developers.google. com/apps-script/sunset
  38. 38. Q&A Slideshare: http://www.slideshare.net/peihsinsu/google-apps-script-24469585
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×