This repo contains the boilerplates for gamil add-on and notes for development.
- create standalone script project, manually switch it to a standard google cloud platform project. For difference of default and standard projects and why/how to migrate, see official guide to cloud platform projects.
- setup clasp.
- install as developer add-on for test, doc here.
If setup a standard google cloud platform project and link to the apps script projetc, use console.log
, console.info
, console.error
, etc, will send log to stackdriver logs automatically.
- each log has a user key attached in "labels" of the log metadata
- can also send customized information such as user id
- enable
Log exceptions
in apps script project to capture exceptions in large user base. - Stackdriver Error Reporting - no additional setup is needed for apps script projects
if log for debugging, can use Logger.log
instead of console.log
. This will send data to Apps Script Logger, which is lightweight but only persists a short time, more here.
- Basic navigation - stack cards together, as in
contextualAddOn.buildContextualAddOn
- Custom Navigation, refer to
buildButtonCard.btn2OnClickCallback
,buildInfoWidgetCard.navToButtonCard
, anduniversalActions.createSettingsResponse
use try{...}catch(e){...}
to render error handling UI, for example universalActions.showErrorUIexample
.
- put external api domain to
urlFetchWhitelist
field ofappsscript.json
-- only allow https protocol, and must have trailing slash. - check
buildExternalCard.onConfirmDropdown
.
connect to non-google services
Examle external api used for testing: News API. Need to register and get free API Key.
- Cards for contextual and for compose may not be used interchangeably, because the two triggers pass different information to the callbacks.
- UI components are the same.
- Compose trigger event object does not contain accessToken, thus cannot use some
GmailApp
methods, such asGmailApp.createDraft()
. UseGmail API
instead. See example codes in./compose/composeAddOn
.
- search threads
- create/modify draft
- send/reply/forward message (can add attachment)
- get message metadata
- create/delete label
- mark message/thread (un)read, (un)important, (un)starred
- (un)trash/(un)spam/(un)archive threads
Note: can also use MailApp
to send mail instead of GmailApp
, docs.
- Interact with other google services
- Interact with external API