How does polling work with gmail?

Is someone able to explain how gmail polling works, please?

I have my setup like this:


Which is set to poll gmail every minute. When I run the workflow, it processes the most recent email (and only one email to be exact). Is this the way this works, in that it always returns the most recent email? If that is true, what happens if two emails are received within a minute. Logically, it follows that one of those two emails will not be processed.

If that assumption is true, is there a way to set this up so when it polls, it looks for new emails that n8n hasn’t seen before? For example, if I have the trigger set up to poll every hour, n8n only processes the emails received within that hour. In other words, I don’t want emails to be missed and also I don’t want to process the same email multiple times.

Thanks for any advice.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @paulg,

We use the time so the node will connect every minute and look for anything that has occured since the last run. You can check the code here if you are interested: n8n/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts at master · n8n-io/n8n · GitHub

Hi @Jon Thanks so much for this. I will take a look at the code.

Quick question though. When I click the “Test workflow” button, is that fundamentally different than when the polling actually happens automatically?

I have tested the workflow multiple times and each time it brings up my most recent email. Based on what you’re saying, if I run it the first time, it should pick up all of the emails and then on the second time, it should return no emails if there are no new emails received between the first and second test. Unless, manually testing the workflow is different than when it automatically runs.
Thanks

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.