In a Gmail add-on is there a reliable way to work with an individually selected message within the conversation? - google-apps-script

We're looking into building a Gmail add-on to replace our Gmail contextual gadget and trying to work out a way to provide equivalent features.
Because a contextual gadget is displayed underneath each message in a conversation we used this to display contact details and allow storing a copy of specific messages within a conversation.
For Gmail add-ons the add-on is passed a messsageId in the event object and sometimes the add-on will refresh with a new messageId when clicking or expanding messages in the conversation. However, this does not appear to be consistent and there doesn't appear a clearly explicit action to select a "current" message in a conversation that the add-on should act upon.
In the documentation messageId is described as as the "message ID of the thread open in the Gmail UI so it's not clear if this is meant to refer to a specific message or the overall conversation.
We also took a look at the Android Gmail app and the add-ons only appear to be accessible when scrolling down to the end of the conversation, so similarly I'm unsure if an add-on can be triggered for specific messages in the mobile UI?
We looked at the Trello add-on as an example. This allows creating a Trello card using the first few words from an email message as the description for the card and we noted that the description would sometimes update to reflect a different message in the conversation when clicking the headings or body of messages in the conversation, but again not consistently.
Can anyone from the Gmail add-ons team advise if what we're seeing are just some quirks that are being worked on, or if we're approaching the add-on design with the wrong model in mind and shouldn't be developing around the concept of individual messages in the conversation?

Related

How to set GMail custom star color in Apps Script

Running an Apps Script on my GMail Inbox to help me prioritize my emails (NOTE: the built-in prioritization for GMail is not working after training it for months, it still gets things backwards all the time, so I turned it off - so please don't suggest I do that)
I have a loop that goes through all the relevant messages, and sets each message to a GmailMessage class variable called thisMessage. I can set a "star" using thisMessage.star() and I can remove a "star" using thisMessage.unstar(). However, I would prefer to be able to use the different, built-in custom start shapes and colors (e.g. red-bang, yellow-bang, green-check). From other questions here, I have figured out how to search for them and bring up emails with particular stars. However, I have to manually set them in the GMail app. I want them to be automatically set under some conditions in my script (Note: I'm currently using labels in place of the stars, but I would like to not clutter up my label list in the app)
How do you actually set one of these custom stars in a given message in Apps Script?
Currently this is a feature only available in the Web UI. Star type cannot be changed either with Apps Script or the API in general. Even the mobile Gmail app doesn't support the different types.
A few hints to this are that the message object doesn't have any star-related attributes. Also, if you check the messages.get representation of an email you will notice that the starred status of an email is defined by "labelIds":["STARRED"], but you can change the star type in the UI and the label will still be the same and there are no other attributes changed.
There are multiple threads in Google's issue tracker requesting this, such as this one or this one and also this one. They've been open for a while so it doesn't look like Google is prioritizing this feature, so the best you can do for now is to +1 these threads and hope they see that there's more user demand for it. If you really must automate these differentiations between important emails the closest you'll get is to use labels, which do have Apps Script methods.

Is there a way to get the current label name/id of a selected Mail?

I was wondering if its possible to get the current label name/id of the label the user selected in gmail.
I can get all labels a mail thread has, but I want to figure out which label the user currently looks at.
Maybe there is also a posiibility to parse the url of gmail in google app script? I know there is server side and client side but I dont have any other idea...
Thanks for your help
Anne
Google Workspace doesn't have a feature to retrieve what email or label a user is currently looking at in their Gmail. This request can be promoted for future development through the Google Workspace Feature Ideas Community.
What you can do with the Gmail API is list the messages in the user's mailbox and list all labels in the user's mailbox.

google hangout chat can bots message bots?

I have a use scenario where I'm testing a bot in google hangout. To facilitate testing of multiple users, I'd like to create a series of other bots that replicate the functions of users. But this is all dependent on the bots in the room listening to one another. It also requires that I get the userid of the bots so they can name each other. In Google Scripts I can find no way to retrieve that (the rest API is not an option).
Any suggestions?
The information is documented, but I understand GCP docs aren't the easiest to navigate. According to the Event Format reference: "Only messages from "real", non-bot users are delivered to bots. A bot will never receive messages posted by itself or by a different bot."
So the answer to the question appears to be no. Bots do not appear to be able to talk to each other. When you put the userid in the text property of the bot it does not replace it to an #botname as it does with human users. If anyone can figure out another way to do it I would appreciate it.
But the second question of where to get the bots userid I can now answer and I leave here in case anyone else is curious. This appears only in a message event, when a bot is mentioned as the property event.message.annotations[0].userMention.user.name

Finding Gmail Snooze dates in API

Is it possible to access the date of a Gmail snooze through the API? I came accross a hack in stackoverflow that allows users to search for which emails are snoozed via a secret label search “label:snoozed”, but lables dont normally have an associated date, especially one that will return to the inbox in the future.
Im trying to create a web routine that syncs a todo list with emails and want to the due date to automatically update with when the snoozed email will re-appear.
Is this possible with any API or developer resources google offers?
No, you can’t retrieve the date of a Gmail snooze using the API.
There is a Feature Request already reported for this behavior on Issue tracker:
https://issuetracker.google.com/issues/109952618
At the moment you can only list them and retrieve the messages that has this label ‘snoozed’ active on them:
GET https://www.googleapis.com/gmail/v1/users/me/messages?q=label%3Asnoozed

Keeping Email Message from Grouping into Conversation View in Gmail

I'm working on a feature for a client to send them email updates whenever a specific event occurs on their site. When the message shows up in Gmail, the messages get grouped together in conversation view even through they aren't the same conversation. It appears that this is due to the fact that Gmail groups based only on the subject. The client is adamant that we not change the subject line (don't get me started).
Does anyone know how I can disable this by sending a special header in the mail or am I out of luck?
There appears to be no way to prevent this, short of turning off conversation view (have you considered that?).
My guess is that Gmail is actually threading based on its own Thread-Topic header field, which it adds (overwriting any value you pass; it just copies the Subject field) - there's no way of telling, though, unless you can change that field after the fact. Which leads to the suggestion of writing an IMAP application to download the message, edit the headers, and re-upload it again. You'd need to investigate the feasibility of this, though.