1

May i get some help on the below points where i am using app-script to develop a gmail add-on:

  1. How can we refresh gmail add-on with back ground process? => Here is my case, I need to display card with multiple sections which is the process of hitting multiple apis to fetch data and to display the card. For this initially we will show a card with minimal information to the user once i get information from api, i need to update the basic cards with complete information.
  2. How can we trigger a function on every mail thread open? => Currently it works once for a mail, here as explained above point need to refresh a card once we fetch the data. If not, user will be seeing same basic information card every time he opens the mail.

From above mentioned issues for point one we are trying to get solution where we can hit service for certain interval of time to check data availability and if data exists then fetch data and update cards, i mean to say need a setTimeout function kind of thing, unfortunately we did'nt found this in app script and We found sleep/waitLock functions in app-script, but my services may take little time to fetch data as it connects though multiple services so we cant make the user to wait until the whole process is to be completed. So that we will show a card with basic information required then after need to auto refresh the cards once we fetch the data. we tried of keeping refresh button for the user to click and fetch the updated data but here we are losing user experience, trying for auto refresh with out user interference to get updated information.

Need a process / solution where we can auto refresh the card with out user interference after the data available at our end instead of making user to wait until the process to be completed.

Earliest reply will be more helpful for us.

Thanks.

1 Answers1

0
  • If a data status on a third-party backend changes as the result of a user interaction with your add-on UI, it is recommended that the add-on set a 'state changed' bit to true so that any existing client side cache is cleared. See the ActionResponseBuilder.setStateChanged() method description for additional details.

  • The card-based interface in Gmail Addons is an Apps Script Service.

  • You can interlink it with other Apps Script services as well as implement API calls - everything within the same Apps Script file.

  • Gmail Addons contents automatically update every time the user opens a different e-mail or refreshes his browser.

  • Within your Apps Script code you can install time-driven triggers to run the data availability check with a customized frequency.

  • Consider to install for your users an Auto Refresh extension if you do not want them to refresh the card themselves.

ziganotschka
  • 25,866
  • 2
  • 16
  • 33
  • Thanks for the reply. Yes Addons content automatically updates when user opens a different email, But in my case user will be seeing the old basic information card itself when user visits for second time for same email. Need to update content if the user visits the email for the next time. How can we achieve this requirement?. Time driven triggers do we can get the email content which a user is opened? my app uses content from the specific mail and authorizes user for availability check. we can't insist users to use extensions to refresh the page. Please help us to solve. – Satish Goud Banda Jul 24 '19 at 12:34
  • Does the user keep seeing the old information even when he refreshes his Browser session (e.g. with F5)? Can you show me your code to udnerstand your desired functionality better? – ziganotschka Jul 24 '19 at 13:39
  • No. User wont see the old information on browser refresh, but if he visits the same email for the second time without refreshing the browser then the user will see the old information itself.But in my case if app holds the new information user should able to see the new content on add-on. This should be handled by refresh/trigger add-on on every email visit so that new data can be populated on add-on. And any suggestions on my first issue how to auto refresh the add-on cards once the data is available without user interaction. Thanks for the helping us. – Satish Goud Banda Jul 24 '19 at 15:48
  • As mentioned above - you can implement installable triggers in your code, which can be time-driven (e.g. checking every 5 minutes if there is new information) or "onEdit" (automatically running the script every time e.g. a Spreadsheet has been updated with new information). Here more informaton about all available triggers: https://developers.google.com/apps-script/guides/triggers/installable – ziganotschka Jul 25 '19 at 06:11
  • **Add-on can use a time-driven trigger once per hour at most** it is high amount of time for the user to wait and also we can't get event for the email to read out the email and to process my add-on logic.Spread sheet is as editor add-on and mine is an gmail add-on.Do we have any in build functions to do auto refresh the cards after certain time, specific to gmail add-on? – Satish Goud Banda Jul 25 '19 at 08:53
  • It is hard for me to understand your issue without seeing your code, but if the idea is that the card gets updated if the content of a thrid-party backend changes - see my updated answer. – ziganotschka Jul 25 '19 at 09:15
  • Apps Script triggers are not available in scripts that are deployed as Gmail Add-ons. [See documentation on Gmail Add-on restrictions](https://developers.google.com/gsuite/add-ons/guides/restrictions#use_apps_script_triggers) – TheAddonDepot Jul 27 '19 at 10:29
  • You can define Apps Script trigger for Gmail Add-ons in the manifest: https://developers.google.com/gsuite/add-ons/concepts/triggers – ziganotschka Jul 27 '19 at 12:13
  • https://goolgedev.blogspot.com/2018/05/create-time-driven-trigger-in-gmail-add.html – ziganotschka Jul 27 '19 at 12:38
  • Hi Team, please help me out on this, My case is simple, when we open email we will show a temp card with *Pending *status. After processing at our server end, Now need to change *pending* status to complete in the card and few other *widgets* need to populate in the same card, where we displayed pending status. Right now if we try to open the same email i still see the same pending status in the card until and unless i refresh tab. i've tried with time driven triggers, functions those are executed within time but still see pending status card is visible without new widgets.. Thanks. – Satish Goud Banda Aug 01 '19 at 16:17
  • If you have a new question, you should post it as a new question rather than a comment. You will reach more people. – ziganotschka Aug 01 '19 at 16:24
  • Thanks for the reply, It is not an new question, i have explained my use case and the problem which am facing so that it could be clear understanding about the question. – Satish Goud Banda Aug 02 '19 at 08:06