Enable user to send text to specific Gmail contacts - gmail

In our website, we need to achieve a seemingly simple task: Enable the user to send a specific text to all or some of his/her Gmail contacts (including contact selection).
We don't actually need the contact data itself. We prefer some kind of "Gmail Plugin" (if there is one) that asks the user to login and does all the work. Alas, we couldn't find any.
We did find several different Google APIs related to this task. Some of them seem to give us contacts data. Others seem to handle sending email:
There is "Contacts API" under
https://developers.google.com/google-apps/contacts/v3/...
There is "Contacts Service" under
https://developers.google.com/apps-script/reference/contacts/...
There is "Gmail Service" under
https://developers.google.com/apps-script/reference/gmail/...
There is "Gmail Platform Integration" under
https://developers.google.com/gmail/...
Each of the above looks different and there seems to be much overlapping between them.
So what is the recommended method to achieve our original task? Is there a plugin that does it all? If not - should we use separate APIs for getting the contacts data and sending the emails, or are there Google APIs that combine both sub-tasks? In case those are separate tasks - is it possible to email via Gmail, or are there other recommended services for the email sending part?

To directly answer your question: you must use the first API you pointed, Contacts API under https://developers.google.com/google-apps/contacts/v3/.
Basically, you want to use the Google Contacts API with OAuth2 authentication in your website: user will be prompted by Google to allow your website to read user contacts.
First, read a bit about OAuth2 authentication flows here: http://alexbilbie.com/2013/02/a-guide-to-oauth-2-grants/
Second step: register your app on Google Console and get your key/pass for the Contacts API (you'll need contacts.readonly permission): https://console.developers.google.com
Then, as you'll use the OAuth2 for Web Servers, check this Google documentation: https://developers.google.com/accounts/docs/OAuth2WebServer
Alternatively, you can use third part libraries to easily import contacts to your website. There are free libraries, like PHP OpenInviter.org, Ruby OmniAuth gem, and paid alternatives, like CloudSponge.com (multi-language).
Disclaimer: I work for CloudSponge.com.

You could achieve this as you say with Google APIs and a Chrome Extension for example.
The user can add a Chrome Extension from the Chrome Webstore. The Extension will provide the user with a user interface to allow them to compose their message and send to the selected contacts.
The users contacts can be retrieved with the Google Contacts API.
The message can be sent to the selected contacts with the Gmail API.
There is a lot of documentation and examples for all of the above which together will give you what you want.
Depending on how much use this is going to get, you could use a contextual gadget which is browser agnostic - but visible in all emails in Gmail.

This is wrong the idea is to post the text to buffer a and submit pointer to array on buffet a and copy it to class b pointer a 0 than release the array and buffer so new allocation can be done

Related

How do you make sure you're getting the correct user's email in Dialogflow when they are speaking it?

Hi I'm not a coder and need guidance.
I'm creating a simple skill for Google Assistant in Dialogflow where the goal is to get a user's email. However, when I test it out verbally in Google actions console most of the time it picks up the wrong email address, (I'll say nhs.com and it thinks I'm saying something different) even though I have put example emails in the entities bit.
What is the solution around this? Is it possible to ask permission in Dialogflow to get a users data? I think Google Assistant says no you can only do that (account linking) if you build in Google Assistant? Can you ask the user to verbally spell out their email address, although no idea how you would go about doing that.
It is not recommended to ask the user for their email. Emails can have a very difficult structure consisting of characters and numbers. Because of this Google provides you with the option to retrieve the users details via accountlinking. I've listed some options for retrieving an email.
1) Google Sign-in (Requires Code)
Since you said you aren't a coder it will be a bit challenging to get the user's email easily. Your best option would be to use Google Sign-in accountlinking. This provides your bot with a flow that asks the user permission to use their email automatically.
To be able to use this code, you might have to use some code since I do not know if Dialogflow supports retrieving the user email from the webpage when using accountlinking.
The benefit of Google Sign-in is that you will get the active email that is in their Google profile.
2) Regex entity (Requires some technical knowledge about regex)
Dialogflow supports a feature called Regex Entities. With these entities you can provide a regex which will look through the user input for a pattern. If the user input matched the pattern it will take this from the user input. In your case you would need a regex to check for an email pattern.
With a regex entity the user can be prompted to tell their email. With this you approach you won't be certain if it actually is their real email and you might have to add a flow to double check if there weren't any typos in the email.
3) Email entity (Least technical option)
As Rally mentioned in the comments, Dialogflow also supports an email entity. This can be used to automatically detect an email in your user's input. Though it is an easy option to use, I've noticed that it doesn't always detect every email and since you can't improve it's behavior, it might not be the best choice. It definitely is the least technical option, but it might not always work.

Must a freelancer keep API Client IDs active for former employers?

I'm a newb with Google OAuth and am trying to understand the different business/application models and which API credential types go with my particular situation.
I am creating a Chrome extension for someone for their own private use which accesses their Google Sheets docs using their personal Sheets account. So, I will not own the code or extension once I deliver it to them and end the contract. So, I do not want to have to maintain any authorization/API ID's or credentials after I deliver the extension and its source code. But, obviously, the extension must continue to work for them indefinitely.
The only way I can see how to accomplish this is to instruct the employer (who has no developer or development skills) on how to create the OAuth Client ID with their own Google API developer console. Then, they can enter the client ID and other codes if necessary into the extension config screen so the extension can use this information for authorizing API calls. This seems like a huge hassle for someone who just wants to buy an extension to do something simple.
Am I missing something? Is there an easier way?
P.S. I know this question doesn't follow the proper format for SO, but this is the only place Google has provided for asking API OAuth 2.0 questions.

How to block spammers from using my public email api

I am working on a web application which allows users to share stuff on a web-page by clicking on an 'email to friend' link; similar to what extole is doing here
http://www.american-giant.com/mens-heavyweight-full-zip-hooded-sweatshirt-product.html
on this page if you click on the email icon near "REFER & GET $15", you will see a pop-up where you can enter your own email and a friends email and can edit the subject of the email. When you click send the data is sent to the backend as json. They are using a plain simple url to do this i.e. http://refer.american-giant.com/v2/share.
The problem for me is that somehow spammers got hold of my url (can't mention here) and now they are using it to spam others by using some sort of a script. What I did is I placed a check in the backend api to block an ip if more than 5 share requests originate from it, but it seems that the spammers have a lots of ips (more than 30,000 from what I counted in my logs) so they are still able to send lots of email. One possible solution is to use a captcha to thwart the spamming script. But I am curious that how extole is doing it. They aren't using any captchas; and they are famous too, so it is unlikely that spammers don't know about their publicly accessible api. Can any one shed some light on this?
Note:
1. I am using a third party email service to send the emails.
2. Users are not required to sign in as this defeats the purpose of sharing on a simple website
3. Users can edit the subject and body, thus these are sent to the api call and this is what allows the spammers to abuse the api with their own stuff.

Link to individual mails in gmail

I want to download all emails in a gmail account and also want to get the unique url which will open the exact mail in gmail, off course with authentication. I tried using javax.mail imap library but Imap probably doesn't supports anything like it.
I can use "https://mail.google.com/mail/feed/atom" gmail feeds. but won't give me entire email and it only gives unread email and I don't want to miss any email
You can do this if you are using Google Apps for Business/Education. If you are, you can access the Gmail inbox feed (Atom) by using OAuth. OAuth can also be used to access Gmail via IMAP - you can then have complete access to the IMAP server programmatically, see Gmail IMAP and SMTP using OAuth.
Google has extended IMAP to allow developers to provide a more Gmail-like experience via IMAP, see: (Gmail IMAP Extensions, X-GM-EXT-1).
The unique message (X-GM-MSGID) and unique thread (X-GM-THRID) ids can be used to produce links to Gmail messages directly - you just have to hex encode the id long (e.g. Long.toHexString(x_gm_msgId)). Your link will then need need to be in the form of:
http://mail.google.com/mail?account_id=ACCOUNT_ID_HERE&message_id=MESSAGE_ID_HERE&view=conv&extsrc=atom
supplying ACCOUNT_ID_HERE (something like user#someplace.com) and MESSAGE_ID_HERE as appropriate.
I have been working in this area and think you might find my project useful, see: java-gmail-imap.
[NB: URLs formatted as above do not work on Gmail's mobile site (at least on iPhone/Safari).]
https://mail.google.com/mail/#all/HexEncodeMessageID
replace the HexEncodeMessageID part with the ID. You get it, when you open the email in a new window (use the pop out icon in the upper right corner.
The id looks like this: search=inbox&th=1426b8f59e003aa0
I'm fairly confident this is not possible - that there is no reliable way to get the unique URL that'll lead to a single email in Gmail. I'd love to hear otherwise!
I do believe it is possible to get a URL that will lead to the Gmail thread containing the message - but you have no control over which message(s) are "expanded" in this threaded display.

Can I build an addin for Gmail?

Is there a way I can create an addin for my Gmail account? Is GreaseMonkey the only real way?
I use Gmail for customer service, and I'd like to create a tool that looks up the customer and preps a response to them based upon who it is in my database... instead of looking by hand for the client and typing it out.
You can add gadgets (same as iGoogle and wave) and add them to the side bar in GMail, but you will not have access to the e-mails themselves. You could create small lookup forms and such, though.
I don't see how else you could do it. You won't be able to run your own app on Google's backend, so that leaves the client (with javascript and something like GreaseMonkey) and your server (perhaps communicating with the client via AJAX).

Resources