Gmail API, Get many, and ignoring previously retrieved

My Gmail inbox is too large and running Get many → Return all takes too long and fails. I changed it to Get many and set a limit of 5 as a test. I was hoping to set a schedule as a trigger until I grabbed everything, but every time it runs during testing, it grabs the most recent. If I don’t receive any new emails in between testing, it grabs the same 5 and outputs them over and over… to a Google Sheet. Is it possible to start with the oldest available mail and have Get many ignore previously retrieved messages?

I was hoping to be able to do this without having to do too much coding or none, but will do so if that is my only option.

I searched all over the place, but did not find anything that was helpful; it is possible that I missed an import thread or two.

Any assistance is appreciated.

Kind regards,

Klawd

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

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

Hi there @Klawd , welcome to the community
on the gmail node, theres this option at the bottom to add some type of filter

you can maybe play around with that, maybe have a schedule trigger that will output the current time of tht schedule trigger and only take the last 2 hours of when is tht trigger gets triggered

or only takes the one with a certain label or read status

a lot of options that you can choose, i suggest you to play around with it!

hope it helps!
and if it did help, please give a like to my answer and mark it as the solution, thank you!

I can’t get any more granular; I’ll have to figure out a different way to do this. Maybe use before and after filter in 6 month increments.

Thanks

1 Like

yea, tht should definitely work to achieve wht ur trying to do

but because 6 months is such a long time and i assume you will get a lot of email, dont forget to use some loop over items node and wait node on each services so you dont get any rate limit error