Find Gmail message ID

I have a mailhook coming from my gmail.com email address. my goal is to change the Label after this happens but from what I can see the values I get back from the mail hook don’t contain the correct Gmail message ID.
image

This is an example from the scenario that I have.

This video should give more details.

Hello Jared,

I trust this message finds you well!

I’ve the exact same issue!

Did you find a workaround for this Jared?

I am looking to understand how to obtain the “Gmail Message ID” for use in the “Gmail - Modify Email Labels” module. The challenge is, I need to do this without using the “Gmail - Watch Emails” module.

Why the Need?
My goal is to utilise the “Gmail - Modify Email Labels” module in different scenarios, without having the “Gmail - Watch Emails” as the initial module. Unfortunately, I cannot achieve this because it seems impossible to get the “Gmail Message ID” without using the “Gmail - Watch Emails” module.

Unsuccessful Attempts
Upon reviewing both the “Gmail” and “Email” modules, I was unable to find a way to derive the “Gmail Message ID”.

Error in Make.com’s Guide
In the Make.com online guide located at Gmail Modify Email Labels (https://www.make.com/en/help/app/gmail#modify-email-labels), there seems to be an error. The guide suggests that the “Email ID (UID)” can replace the “Gmail Message ID” in its respective field. However, in practice, this proves to be incorrect and causes an error.

In Conclusion
In essence, I am seeking guidance on how to get the “Gmail Message ID” for use in the “Gmail - Modify Email Labels” module, without resorting to the “Watch Emails” module.

I aim to use the module in scenarios that do not involve the “Gmail - Watch Emails” as the opening module.

Did you find a workaround for this @jaredryanwright ?

1 Like

@Hugh_Peters Wow, you did an amazing job explaining the problem and what you are trying to accomplish I am 100% in the same place and sadly I have not come up with a workaround yet but I will follow up as soon as I do.

Hi Jared,

OK, perfect. I’ve messaged Make.com Support about it. Will let you know if I come up with a solution.

2 Likes

Hey,

@Hugh_Peters Thank you so much I look forward to hearing back.

Hi Jared,

Though that message ID is unique to the individual message, it’s also unique to Google API and lives outside the message body and headers so it makes sense that once it gets to the Mailhook you no longer have access to that ID.

I would say the most straightforward fix to this is to have GMail Module watch your emails rather than forward them to the mailhook.
In your forwarding rule in GMail, instead of forwarding emails to the Mailhook, send them to a folder instead, then have your GMail trigger monitor just that folder.

Is this an option for you?

If not, I think your other option is to use the Google Mail API directly with HTTP modules, but it’s rather complicated.

  1. In your Mailhook module output bundle, you will find an “in-reply-to” field.
    This should be the message ID of the original message that was forwarded in Gmail.

  2. Then, using HTTP Module and the Google Mail API, query your messages, looking specifically for that value from in-reply-to.
    Use a query that looks like this: rfc822msgid:in-reply-to-id -to:makemailhookaddress@hook.us1.make.com
    You can test this search query in GMail GUI as well.

  3. Once you find the message, get the GMail-specific message ID from it, which you can use in the module that labels the message.

4 Likes

As @Hugh_Peters Said in his response the watch email responses module will not work because I need an instant trigger not a polling trigger.

There from what you have said I will need to try the second more complicated method if you could add some screenshots that would really help too.

I haven’t actually set it up, so no screenshots to share.

What if you use Watch Emails, but instead of polling every x minutes, change to on-demand.
Create a second Scenario with a Mailhook trigger, followed by an HTTP module to kick off the first Scenario.

That should give you the ease of finding the gmail ID and labeling your email, but also the instant trigger.

3 Likes

I like that Idea but how would I trigger an on-demand scenario automatically? I thought on-demand meant you had to trigger manually.

Here is how Make describes On demand scheduling
image

Here’s the documentation on how to execute a Scenario via API: https://www.make.com/en/api-documentation/scenarios-scenarioId-run-post
This won’t work on the free plan, however.

You have two Scenarios:

  1. Mailhook → HTTP (or Make)
  2. GMail Watch Emails (On Demand) → remainder of your original Scenario

From #1, use HTTP or Make to trigger #2.
You may not even need HTTP as Make has their own Module to run Scenarios.
image

3 Likes

Hi Donald,

I trust you’re doing well. I appreciate your response, but I believe there’s some confusion regarding the “Message ID” values.

Three Types of “Message ID” Values
The “Gmail - Watch Emails” module generates three different types of “Message ID” values:

  1. Message ID
  2. Email ID (UID)
  3. Gmail Message ID

Our target here is to acquire the third one, the “Gmail Message ID”.

Issue with Acquiring “Gmail Message ID”
While we can conveniently get both the “Message ID” and the “Email ID (UID)”, we’re facing an issue with obtaining the “Gmail Message ID”. This problem obstructs your “Webhook - Custom Mailhook” to “HTTP - Make a Request” solution.

Misconception About “Email ID (UID)”
You might be under the impression that “Webhook - Custom Mailhook” to “HTTP - Make a Request” will function because the Make.com training on “Gmail Modify Email Labels” suggests that we only need the “Email ID (UID)”. However, there is a misunderstanding here.

Correction to Make.com Training
Make.com’s training incorrectly states that we need the “Email ID (UID)”. Contrarily, we are supposed to use the “Gmail Message ID”. I have validated this by testing both the “Gmail Message ID” and the “Email ID (UID)”. Only the “Gmail Message ID” succeeds, while the “Email ID (UID)” leads to an error.

You’ll note that the field’s name is “Gmail Message ID”, which should align with the value “Gmail Message ID”.

1 Like

@Hugh_Peters You are 100% correct this is the exact issue I am faced with.

@Donald_Mitchell Please take this into consideration with any future solutions.

Hello Hugh,

Yes, there’s definitely some confusion surrounding the various message IDs.
You should use the #3 Gmail Message ID when you want to modify labels, not #2 Email ID (UID) as indicated in the Make documentation.
We can all agree on the fact that Make’s documentation is incorrect.

I had time today to make this work, so here are some screenshots:

In Gmail, I have a filter set up to label and forward specific pieces of mail.

  • In this case the Label is “Test”.
  • Mail is forwarded to the Mailhook.

Scenario #1: Mailhook trigger → Make Run a Scenario
image

Scenario #2: Gmail Watch Emails (filter those Unread with a “Test” Label, then mark it as Read) → Gmail Modify Email Labels (Label it as “Read-Processed”)

Scenario #1 executes Scenario #2.
Since Scenario #1 is triggered by a Mailhook it’s as near instant as a Webhook.
Since Scenario #2 is triggered by a Gmail module, I have access to the GMail Message ID needed to modify its labels.

I believe this would be a good work-around for Jared.

3 Likes