Google Apps Script - Trigger Logic

72 views
Skip to first unread message

urwa shabir

unread,
Apr 22, 2019, 12:42:33 PM4/22/19
to Google Apps Script Community
Hi,

I am struggling with a logic for trigger.  I am trying to send "CALL" reminder for google calendar events 10 mins before the event. For call, I am using Twilio API.

I am able to extract all calendar events for a particular day. For extracting all calendar events, I can simply set a trigger that updates the event sheet on Calendar Update.

I am also able to make a calls using Twilio BUT how should I set up the trigger for call.

The events are going to be added and moved constantly through out the day. So I am unsure how to make it work for 10 mins before the event.

A trigger that runs every 5 mins might work (at least in terms of logic) BUT I think I am going to run out of quota.

Any suggestions would be appreciated.

Thanks.

IAlex

unread,
May 1, 2019, 3:31:03 AM5/1/19
to Google Apps Script Community
Hi!

I think the best way for this It's the decision - what is the primary action and what is slave.

Let's assume Twillo is a master, Calendar is a slave. Then you have to subscribe to Twillo API broadcasting/webhooks/events stream or something else (depends on their service).

Otherwise you can sync your calendar more simply.

Create a trigger onEventUpdated

function userActionRegisterEventUpdatedTrigger(){
  ScriptApp.newTrigger('eventUpdatedTrigger_')
  .forUserCalendar(Session.getActiveUser().getEmail())
  .onEventUpdated()
  .create();
}

function eventUpdatedTrigger_(event){
  console.log(event);
}


~Alex
Reply all
Reply to author
Forward
0 new messages