Skip to content

Instantly share code, notes, and snippets.

@radk2

radk2/onOpen.gs Secret

Created May 10, 2024 08:04
Show Gist options
  • Save radk2/45e729f5859d76197d8f7e6b53dd6d71 to your computer and use it in GitHub Desktop.
Save radk2/45e729f5859d76197d8f7e6b53dd6d71 to your computer and use it in GitHub Desktop.
call a webhook on opening Google doc
// https://developers.google.com/apps-script/guides/triggers
function onOpen() {
var webhookUrl = 'https://X.X.X.X/';
var payload = {
'action': 'Open',
'timestamp': new Date().toISOString(),
'userInfo': Session.getActiveUser().getEmail()
};
var options = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify(payload)
};
UrlFetchApp.fetch(webhookUrl, options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment