Hi, I’m trying to create a workflow that apply some labels to my email.
My problem is that when the workflow call gmail (Gmail trigger based on label / get) to get the data of a label via “label name” (so I can verify if the label exists or not) gmail reply me ALWAYS that the label does not exist. So the workflow continue trying to create a new label that obviously leads to an error because GMAIL reply that the operation is not possibile (the label exists).
With my credentials I can read/create/delete labels
Hello! Your friendly n8n support specialist here, ready to help you solve the Gmail label issue. I’m passionate about making workflows work seamlessly, so let’s tackle this step by step!
Layman’s Terms (Simple & Friendly)
Problem: Your workflow can’t find existing Gmail labels, even though they exist.
Why This Happens:
Gmail’s API is picky about how you ask for labels.
The label name you’re using might not match exactly what Gmail expects.
Simple Fix:
Check the Label Name: Make sure it matches exactly (case-sensitive, no extra spaces).
Use Label ID Instead: Labels have unique IDs that don’t change, even if the name does.
Debug the Workflow: Add a “Debug” node to see what’s being sent to Gmail.
Experienced User Guide (Step-by-Step Fix)
Root Cause: Gmail’s API requires exact label names or unique label IDs.
Steps to Fix:
Step 1: Verify Label Names
Go to Gmail > Settings > Labels.
Check the exact spelling and case of your labels (e.g., “Corso online” vs. “corso online”).
Step 2: Use Label IDs
Fetch all labels using the Gmail API or n8n’s Gmail Node.
Find the Label ID for “Corso online”.
Use the Label ID in your workflow instead of the label name.
Step 3: Debug the Workflow
Add a Debug Node after the Gmail node to see the exact request and response.
Check if the label name is being sent correctly.
Step 4: Handle Errors Gracefully
Add an IF Node to check if the label exists.
If the label doesn’t exist, create it using the Gmail Node.
Professional Deep Dive (Technical Fix)
Technical Analysis:
Gmail API Behavior:
Label names are case-sensitive.
Spaces and special characters must match exactly.
Label IDs are unique and don’t change.
Error Handling:
The error “The resource you are requesting could not be found” indicates a mismatch in the label name or ID.
Advanced Solution:
Step 1: Fetch All Labels
Use the Gmail Node with the List Labels operation.
Hi and thanks for the reply.
I have created a little python scripts that use the same credentials, same google project and same user and the label is founded.
I think it means just a simple script node calling the Logging functions of n8n
The script below is from the official n8n logging documentation
import {
LoggerProxy as Logger
} from 'n8n-workflow';
// Info-level logging of a trigger function, with workflow name and workflow ID as additional metadata properties
Logger.info(`Polling trigger initiated for workflow "${workflow.name}"`, {workflowName: workflow.name, workflowId: workflow.id});
No worries,
Not sure if you saw but I edited my initial response while you were replying to me and i suggested just that.
Sadly google api doesn’t allow lookup of labels by their name yet.
here is a solution to get the labels and find the id by name without a script.
You just specify label names in the switch conditions: