Hi everyone,
I am facing an issue with a workflow involving email parsing.
Issue description
I am polling Gmail every minute to get new email and parse them using a function node.
The only issue is that sometimes I get several emails within the minute I last parsed.
For exemple :
Email n°1 : Received at 14:05:10
Email n°2 : Received at 14:05:45
I am seeing the two items in my trigger so no issue on this end but when I am going through my function node, my code seems to be running only on the first item.
Being aware that a function node only run once (vs. other nodes that run several times), I encapsuled all my code into a loop that should parse all my items.
for (item of items) {
//my code here
// some HTML parsing
item.json.key1 = value1
item.json.key2 = value2
item.json.key3 = value3
item.json.key4 = value4
}
return items
Except that my code runs only for the first item & the second items is the initial email object.
Here is what the current output looks like
[
{
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4"
// this is obtained through my code
},
{
"id": "XX",
"threadId": "XX",
"labelIds": [
"UNREAD",
"CATEGORY_FORUMS",
"INBOX"
]
// this is the 2nd email which is not formatted as I want
The Execute Workflow node will ony be executed once but it will be executed with all input items so 2 gmail trigger events should NOT be a problem here. From the screenshots I don’t see a problem why it shouldn’t work, but I can only guess.
To debug your workflow you could use our data pinning feature with your Gmail Trigger node to simulate two events going through your workflow. Did you try out a workflow without executing subworkflows to see at what point it fails for more than one event?
I haven’t succeeded in pinning 2 events going through with the trigger but I am going to use a function nodes that outputs an array with 2 elements to check how it goes.
Regarding your second questions, my executions fails at the first node (Extract Contact Info) as only one item is processed by the function where I would expect all of the items to be processed
Edit: trying the process described above my function parse the content without any problem but when replaying the executions I am encountering bugs again I’m kind of stuck