0

I'm writing a gmail addon with appscript and I want it to perform an http request only when the addon is opened by an user, instead of everytime the card is rendered.

function main(e){
   var mainCard = CardService.newCardBuilder();
   // Set up card sections
   UrlFetchApp.fetch(...) // Will perform the request even if addon is not opened
   return [card.build()]
}

Is it possible, to execute UrlFetchApp on card open instead of on render?

Kara
  • 6,115
  • 16
  • 50
  • 57
angrykoala
  • 3,774
  • 6
  • 30
  • 55

1 Answers1

1

According to the documentation, you cannot create or use Apps Script simple nor installable triggers in a Gmail add-on.

However, you can try looking into time-driven triggers as a workaround.

Time-driven triggers

A time-driven trigger (also called a clock trigger) is similar to a cron job in Unix. Time-driven triggers let scripts execute at a particular time or on a recurring interval, as frequently as every minute or as infrequently as once per month. (Note that an add-on can use a time-driven trigger once per hour at most.)

You can also refer to this SO post for information on its usage.

Jacque
  • 757
  • 4
  • 9