Set Fields not pulling data behind IF

, ,

I can’t seem to get my data thru the IF node. I thought by using the SET node and getting only the data I would need farther down the line, this would be the best approach. But it isn’t pulling the data. Is this not the right usage?

Basically I am trying to match a new email I have received with the parsed data from mailparser.io. From what I can tell, I can’t actually delete the email without getting the message id as its unique in gmail and doesn’t get forwarded. Maybe there is a better way to accomplish this.

It shows there is no data, but if I put it in front of the IF node, it works. So I am wondering if I need to do that, but I only want to continue with the matching email and parsed data.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It looks like you’re explicitly using the webhook node in the expressions, so that’ll be empty if the gmail node is the one that triggers the workflow, can you instead use the item names as they are passed along, e.g. $json.body.email_sender_address, etc? Try testing the workflow and pinning response data in each node to see what’s available at each point during execution, it may help figure out what you have the best access to.

I just started using n8n a couple of days ago. I didn’t know I could pin things! I just found out how to do that. So that will save me lots of time having to resend the data! Thanks for that tip!

Also, is there a way to hold data till both triggers get stuff? I have my gmail set to forward to mailparser.io as soon as it comes in. Maybe there is a better way to parse my emails?

You mentioned using the item names as passed along. I don’t quite follow. Can you elaborate a little more?

I am still new to this and trying to figure it out on the fly. Any help you can provide me would be greatly appreciated!

Thanks!

Ah, welcome! :slight_smile:

Here’s the help article on pinning - it’s for when you’re developing a workflow: Data pinning | n8n Docs - basically, you can test an individual node and then “pin” the response, so that the next nodes can see that data for testing their inputs as you work on the workflow.

I think I see what you’re doing with that webhook now - you can feed the Gmail and webhook in to a “Merge” node, which will wait for both inputs before passing execution onwards. You can set it to Combine → Multiplex, and then it will just contain all input from both previous nodes (be careful if you may have property/name collisions from each input! You’d have to take a slightly different approach if so).

Is the webhook being hit by the mailparser service, based on the same event/email that the gmail node is triggering? If so, can you just skip the gmail trigger and let the webhook be the only triggering node?

As far as using the item names from the previous nodes instead of from the webhook node, this is probably a good page to read and understand how n8n passes data between nodes and the lifecycle of data in a workflow: Understanding the data structure | n8n Docs - and to be honest, I just did that basic course myself which is why it’s top of mind, I’d recommend giving it a go if you have time!

What type/level of parsing are you having mailparser.io perform for you? I have a really basic bit of Python code (using the email python module) that I use in a code node to parse basic multipart/mime emails, which probably isn’t robust enough to really publish anywhere, but if that sounds at all helpful, I wouldn’t mind sharing it.

I am using mailparser.io to pull the event name, event date, start time, end time and zoom URL. I was trying to get the gmail node to do this, but for some reason it is not displaying all the data from the email. So that is why I had to go look somewhere else for help getting this information. Does your python do this? I would prefer to have one place to do all this so I am not relying on something else that could change and break my connection.

Disable the simplify switch in the Gmail trigger to get all the email data

Ok I was able to get some more data. I now have some Set Field nodes to extract some of the data but the date/time doesn’t seem to be working correctly to search Google Calendar for an event. I can’t figure out why its not working. Any ideas?

Try the below syntax (and please, don’t use legacy syntax):

{{ $('Edit Fields').first().json.eventStartDate }}

It should not be defined as an Array with an Object.

@barn4k Ok I updated the code as you suggested. Still getting the same error.

Here is my Set Fields Node.

I am really new to n8n and coding. I was able to use the AI to help get what I wanted accomplished. So I am not really sure what you meant by this “It should not be defined as an Array with an Object.”

It’s not clear what the issue is about. Can you provide a workflow and a sample for any email?

Ok, my workflow is above. I am extracting the date and time from the email which outputs correctly. Then I’m trying to search Google Calendar for an event with that name during the time. If there is one, I want to update it with the new information. If not, I want to create it. But I am getting that bad request error I showed above.

Bad Request Error

If I take out the date/time, then it finds any event with that text, but sometimes I have multiple events on different days/times. That is why I need to be able to search for it at a specific date/time. I hope this makes sense. I am new to n8n. I am on the cloud trial right now.