Hi all. I’m writing a workflow where I need to check if an email (unread) has a label and if there isn’t I need to add this label and send an email.
I have no problem to get new email, get the list of the current email’s labels, loop through the lists of labels to check if the label is present, but I don’t know how to
follow a flow when the label is not present in the email’s labels. I can not use “variables” because I’m on the free plan.
And I don’t want use Javascript.
Any possibility ?
thanks
M.
Information on your n8n setup
n8n version: last online
Database (default: SQLite): online
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Hi, it’s possible if I edit my array via JS before the IF node, where JS transform (for example) my array in a string like “n8n imporant mylabel2”. But I don’t want to use JS because many pleople don’t know this programming language.
I need to check if “labels” array contains an item where “name” is equal “n8n”.
I don’t know how to continue after the “loop” node only if there isn’t an item with name “n8n”. I can use javascript ($input…map(…)) in a “code” node but I don’t want use JS.
Main idea is the same:
0.I’m a lawyer and i receive lots of messages from courts about my cases; all of them have the same schema and can be categorized.
receive a message.
check if it complies with the rule:
the message body should contain specific value over the pattern - like 922/194/23 3 digits, separator “/”, 1 to 5 digits, separator “/”, 2 digits.
if it complies - get all existing labels from mailbox.
chech if there existing a label, that matches pattern above.
if yes - set this existing label to new message.
if no - create new label with the pattern, then set this new label to new message which body contains that specific pattern
I’m stuck on steps 5 and 6.
Will appreciate your advice.
n8n version: 1.85.4
Database (default: SQLite): postgres
n8n EXECUTIONS_PROCESS setting (default: own, main): main
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
function estraiPattern(body) {
const pattern = /\b\d{3}\/\d{3}\/\d{2}\b/;
const match = body.match(pattern);
return match ? match[0] : null;
}
// Esempio d'uso:
const body = "C'è un codice interessante: 922/194/23 in questo testo.";
const risultato = estraiPattern(body);
return {"pattern": risultato}
the node’s output will be a JSON/SCHEMA like {“pattern”: “922/194/23”} or {“pattern”: “”} (the last if 922/194/23 is not contained in the body).
Thank for your reply.
I have no problem to find the messages, which comply with the pattern.
The problem is to
set exeisting labels depending on the pattern
[IF message comply with pattern AND label, which comply with pattern exist, THEN set to this message label]
add
add new labels and set them to messages
[IF IF message comply with pattern AND thehe is no label, which comply with pattern exist, THEN
label with the pattern AND set this new label to this message].