Hey! I am trying to acheieve an auto-filter for emails where I can get an output of specific emails details where the subject or body has specific keywords.
I am running a workflow where emails received every hour for a gmail node is sent, passed through a function node, which has certain defined keywords to filter. If the emails meet the criteria, it reuturns ‘true’, which is finally linked with a google sheet node, to return certain details about that email like Sender, Receiver, Subject, Body, date time, and ID.
Error Code:
Using the item method doesn’t work with pinned data in this scenario. Please unpin ‘Code’ and try again.
An expression here won’t work because it uses .item
and n8n can’t figure out the matching item. You can either:
- Add the missing information to the node ‘Code’
- Or use
.first()
,.last()
or.all()[index]
instead of.item
By default the Json has the structure of “{{ $(‘Gmail Trigger1’).item.json.headers.subject }}” and this works perfectly well when the output is a single email, but moment I get multiple outputs I get this error. I have tried upadting it to .all(), and first/last also don’t suffice the requirement.
Workflow
Return Output
.item- works perfect in testing as there can be maximum single output or when there is single output in live executions but throws above error whenever the output is more than 1
.all()- Doesn’t return multiple rows of data which would be my ideal result, where every email meeting the criteria would be added to the sheet
.first/.last- doesn’t meet the use case we have
n8n version: [email protected]
Database : SQLite (default)
EXECUTIONS_PROCESS setting: Main
Running n8n: via desktop app
Operating system: Windows 10