Better way to handle id storage on N8N workflow

I have a workflow to get new mails on Gmail API with a push notification system. It works really great and I can get every notification and get my mails content.
The only thing is that I have to storage the historyId because Gmail API Push notification works with an invalidation token. Every new changes on the subscribed ressource invalidate the older history id and the response call from the push notification contain the new historyId in base64.
I have then to make a call with the old history Id to get the delta between the old history id and the new head history.
Maybe a schema is more clear :slightly_smiling_face:

I would like to store the historyId inside my workflow and don’t make a get/set call every time to store it in a database.
Is the globalStaticData a proper way to handle this usecase or do you think it’s not reliable?
If not have you another way to handle it?
Here is my workflow:

Thank you very much.

Hi Samuel,
using $getWorkflowStaticData('global') sounds like a good alternative for your szenario. Keep in mind that static data is only available when running active workflows, not with manual executions (which makes it a bit harder to test).

If you are self-hosting n8n you could also read/write your historyId to the filesystem.

1 Like

Thank you for your help

1 Like

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