Send Google Pay request using Google Apps Script - google-apps-script

I am trying to automate my monthly flow of doing some math and sending people Google Pay requests using Google Apps Script. Right now my script sends people email with what is due but I would like to also attach GPay request in the email or just send GPay request alone.
Background -
I receive an email from a phone service every month with the bill amount. I split that with a group of 4-5 people depending on their usage and any overages they may have. My script correctly finds out the email and parses to find out the total amount due and then also goes ahead and figures out who owes me how much. I pay the entire bill and then collect money from other people. In the end, the script sends each person an email with the amount they owe me each month.
Problem -
tbh, it is not a "problem" as such but this is an enhancement I would like to add. Gmail allows attaching Google Pay request in the email. (Please see screenshot). I would like to enhance my script so that I can attach such a Payment request in the email that this script sends out.
My question is if this is at all possible?
References
Google Apps Script
Google Apps Script Console
Google Pay API
For my use case, it does not have to be an email with Google Pay attachment. It can just be a Google Pay request.

Unfortunately the public Google Pay APIs aren't set up for this.
Unless you happen to also be registered as a merchant and are able receive payments I would avoid this.
If on the other hand you are an existing Google Pay merchant and you're interested in doing it for giggles, you could try the following:
Create a webpage that you can link to in your email
Have the webpage accept required query string parameters (like amount and description)
Render payment information (like amount and description) and integrate the Google Pay Button
Embed the link in your email
IMHO this isn't practical at all... it just depends on how desperate you are for giggle.

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 there a way to automatically delete emails from a Google Workspace Google Groups?

I was wondering if there is a way to automatically (or on a trigger) delete emails from a Google Group.
I use a Collaborative Inbox Group for archiving automated emails.
I looked at the Google Apps Script overview for Google Groups, but I don't see anything. It only seems like you can do this from GmailApp...
I also read this thread from 2012 but nothing helpful there
Answer:
Programmatically this isn't possible.
More Information:
The GroupsApp class of Apps Script only has read methods available for use - there is not a way of executing any write data using the class - for example deletion of emails.
Emails are sent to everyone in the group when a post is made (as per subscription settings). If you want the Email to be deleted then as you have already pointed out, you will need to use GmailApp to delete it from the recipients' inboxes.
In short: All mailbox manipulation must be done using the Gmail API (or GmailApp).
Feature Request:
You can however let Google know that this is a feature that is important for access to their APIs, and that you would like to request they implement it.
Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services, I'd urge you to make a feature request there. The best component to file this under would be the Admin SDK component, with the Feature Request template.

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.

How to figure out permalink for a Google Groups message by email

I'm building a system on Google Apps where people in a number of offices scan documents to a Google Group email. Currently, these are forwarded to me and I have a Google Apps Script running that looks at each email, copies the attachment to Drive, and adds a link to it on a Site in an structured manner, by fiscal year, office, etc. (all from the email subject line).
My Drive will eventually run out, and my organization refuses to create a separate account for technical reasons, and Groups has unlimited storage. I'm trying to figure out a way for the script to instead figure out the permalink to each message. I've seen Groups messages online that include "To view this discussion on the web visit" links, but can't find a setting to enable that. I've tried looking at the email headers, but can't see anything there either.
Does anyone know of a way to generate links to a Groups message based upon the email contents?

Google script quota

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.