Google script quota - google-apps-script

I am running an online free computer science education course website. I use Google scripts to evaluate the student quizzes (I use the MCQ script). Yesterday, there was a spike in visitors to my site. I noticed that the quiz scoring script is no longer sending results to students. I checked the failure notification, and it says "Service invoked too many times for one day:"
Is it because of a quota? If there is a quota, then is there any way to increase it?
My class has more than 800 students, so it is likely that they will submit their homework on the very day I post it online. So, I badly need to increase the email quota. If there is any workaround, that will also be very useful to know.
Thanks in advance.

If you deploy the app to run as the user executing, not as you, then it will run with their quota. However, they will have to click to authorize sending mail, and it will appear to have come from their own account to themselves.

The quotas are shown on the dashboard that can be also accessed through a link in the side panel of the documentation page. I'm afraid you hit quotas for email service.
...
EDIT : Ah, didn't see Corey's answer... smart suggestion of course ;-)

Try using an external API (i.e. Mandrill). Mandrill (it's by Mailchimp, so it's pretty robust) has an easy external API with much larger limits (in the order of thousands).
You can even set the from address so that it wouldn't look spammy (or, really, any different than the normal Google Apps Script send email).
Take a look at Use Mandrill API in Google Apps Script.

Related

Gmail limits between consenting gmails

I am using a gmail account to selectively forward incoming mail to the correct recipient based on criteria in the incoming mail. Bear in mind I can't solve this using Gmail filters. I need to run Apps script in order to look up the sender in a database before deciding who to forward the mail to.
I quickly hit a "service invoked too many times" for sending Gmail, which is likely intended to prevent spam mail. However this is not spam and the recipient gmails are consenting and limits are unhelpful here.
Is there any way to remove sending limits between consenting gmails?
You're probably hitting one of the Apps Script quotas. In my experience, Google is unlikely to make exceptions or raise Apps Script limits upon request.
Most of these quotas are per-account, so a workaround that you could try is to run the script from another account once the limit is reached.
Also, the limits of the Apps Script Gmail Service are more restrictive than the limits of the pure Gmail API REST calls or other API libraries, so another workaround could be to write the script in another language and use the API, or if you want to keep using Apps Script you can use REST calls rather than the Gmail service.
Even if you still hit the quotas with the Gmail API there are ways to request a quota increase, while there is no such process for Apps Script. My guess is that Apps Script is intended for smaller projects, but if you're working with a larger volume you're supposed to use the Gmail API instead.
Quotas imposed based upon exceeding the rate not an absolute limit
It may be that you are looping to fast. Because google imposes limits based on an instantaneous rate. So assume you can send 2000 letters per day then that means you can send email every 0.023 second so it send one every 0.05 seconds you will probably stay out of trouble. By the way I don't really know what the quota is.

Is it possible to increase the limit for URL Fetch daily quota for the Apps Script API?

We have hundreds of users and we occasionally get blocked because we exceed the quota for UrlFetch. Is it possible to increase this limit? Or is there another workaround so we don't get throttled?
If I am not mistaken, it is possible, you would need to associate your script with a standard project from GCP (in case you have not done this yet). What I mean by this is that you need to create a separate project on GCP, then enable the APIs and configure the scopes and everything manually, and then associate it with your script from the script settings (see screenshot).
After all that just go to the project, then IAM & Admin >> Quotas and click "Edit quotas". This is also officially documented here and make sure that billing is enabled for the project.
What you would be doing with all this is submitting a request for the Google team in charge to review it and decide if approve it or not. It can take a couple of days for you to get a response from them.
I can't guarantee that the quota that you need to increase would be available, but at least this is how you can request any quota increase for any script you may have.
If you already have a project from GCP with the Apps Script API enabled, you can just follow the instructions to submit the request without having to follow the other steps.

Putting a stop to fake emails from our leadership team... how do I deploy my script?

Tired of my G Suite users falling for emails "from" our CEO and other leadership team members, and the [EXTERNAL] that I appended to the subject of all external emails has been great but not helping everyone.
I have written a Google Apps Script that compares the "from" name of the sender to that user's company email and personal email, and then if there is not a match, it forwards the email to IT (to confirm/let the user know if it was somehow legit) and then deletes it to the user's trash.
I've got a trigger to setup so it runs every minute. It's only looking 3 mins back in emails so it doesn't waste resources/runs but also doesn't miss if it has an error for some reason. Have individually set up for a couple users as a test and myself and it appears to be working great.
My question after not finding a use case in the Google Add-Ons examples that really fit this use case...
How do I best deploy this to all of my domain users such that it uses the existing 1 min trigger, requires no user interaction - except maybe to install, and updates as I update the script?? I'm reading stuff about cards and icons and triggers for opening an email and such but none of this is what I'm looking for. I want it running in the background at all times to where if the user only looks at email on their phone or Mac Mail/Outlook that the script is still catching the phony emails.
Has anyone done anything like this. Google Support people, is there a page I've missed in my search for answers?
Depending on your g suite account...why not enable "Advanced phishing and malware protection". Specifically the section on spoofing as you can choose a giant warning banner, send to spam or quarantine it. If you only want execs then you could do a check in Gmail settings for unauthenticated email vs a whitelist and take action that way also.
https://support.google.com/a/answer/7490901?hl=en#spoofing-authentication-safety
I figure out that the question here is that you want to develop an add-on over your whole domain. If my assumption is correct, then you can opt in to follow these steps on how to install G Suite Marketplace apps in your domain. If you want to test the reach of this operation, you could develop an reviewed and trivial app like Cats and introduce it to your domain. While developing your add-on, please be aware of the best practices. After the developing process you can publish it to G Suite Marketplace. Keep in mind that you could add this add-on to your domain even if it's published as internal.
After reading your comments I get that you want to use this add-on even if users aren't online. In that case you could activate domain wide delegation of authority over your domain and use service accounts to control G Suite API interactions. To run this script at every minute you can use cron, but please be mindful of Gmail API quotas.
Along with the former, you can reach G Suite support and they'll better assist you with preventing phishing forces. Please, ask me any question to better clarify myself.

Apps Script HTML Service Post request / sheet append limits

We have a chrome extension that posts data back to a Google Apps Script app and I'd like to know if I'm going to hit any limits at Google.
The Apps Script app has a doPost function that takes the information that was passed across and uses appendRow to add the content to different sheets. Very similar to how forms works but allows us to deploy to users (via the chrome extension) and have a better looking UI.
We're wanting to push this out to potentially thousands of users and we expect a few form submissions a day from each of them. Should I be expecting to hit any set limits with this?
I've already taken a look at https://script.google.com/a/netpremacy.com/dashboard but don't see anything that would indicate any limits.
Let me know if you need more info.
There are no published limits at this time. However, the key thing to ask with apps deployed as web apps is that is the App running as you (the developer) OR the users accessing the web app?
If its running as the users, then you are going to be ok with the volume. The quota is fully debited to the end user.
If its running as you, then you need to worry about other quota first - does it send out lots of emails, does it create a lot of documents, etc.
The only exception to quotas is ScritptDb that always consumes the script developers quota.

“Pushing” Gmail to GAS — using Gmail forwarding to trigger GAS script

Summary
Is it possible to use the Gmail forwarding feature to send (i.e., “push”) via HTTP (GET/POST) to my GAS script URL? (And perhaps include its contents as a parameter?)
Goal/Background
My goal is to immediately process my incoming Gmail instead of, say, using the GAS trigger feature to query and “pull” my Gmail on a periodic basis.
The former method is relatively immediate. Whereas, the latter method creates an expected delay equal to the mean interval time between (automatically triggered) queries to my inbox.
Possible Solutions
1. Gmail Data API
This documentation states Gmail lacks a data API.
2. Atom/RSS Feeds
Atom/RSS feeds still require an aggregator to pull the data from the server and, thus, do not accomplish my goal of a push-only solution to my GAS URL to, then, in turn, trigger my script via doGet() or doPost().
3. IMAP/POP
These solutions are designed for desktop/offline processing of emails and, therefore, do not meet my goals. I need a solution that lives on the web and automates my web-based email checking tasks.
4. High-frequency GAS Trigger
A, say, 60-second trigger interval in GAS does not work because there is a cost to such high-frequency triggers in GAS due to quota limitations. i.e., I don't want to use up that much quota space on this one task because I need it for other stuff.
5. 3rd Party Listeners
I would prefer something free if possible. Someone has suggested Zapier® — which does have a free version. Do these work? Are there others?
Conclusion
Are there any creative ideas out there? Perhaps to point me in a creative direction?
I would even settle for just a way to be immediately notified (programmatically) that I received a new email.
Not possible from Google Apps Script:
Google Apps Script currently available events:
https://developers.google.com/apps-script/understanding_events
Does Gmail have a Data API?
FAQ: https://developers.google.com/gdata/faq#GmailAtomFeed
Looks like IMAP is the only option, not sure if IMAP supports callback.
A trigger can kick off a script every 60 seconds. As you stated before, this puts your average notification at 30 seconds (let's not get started on possible flaws in statistical assumptions).
Another possibility for a more immediate action is to use a service like Zapier.com as a listener. It can listen for new emails in your gmail inbox, apply filters, and initiate a GET/POST to the URL for your Apps Script (make sure it is the newest version published).
I hope this helps. Curious why you need immediate handling of the messages ...