Hi everyone,
I am starting out with n8n (been using it for a week now). I am trying to create a simple workflow composed of a Cron node to be executed every 30 minutes and it’s triggering a Function node which in turn triggering a Function Item node. The results are being stored into a Set node and then i want to send an email message at the end of the workflow with all the data from the Set node. Currently it’s sending one email message per line of data. My question is…how can i send one email message for all data accumulated into a Set node?
That is expected behavior. Based on the number of items returned by the previous node (in your case Set node), the next node gets executed. For example, if the Set node returns 10 items, the Send Email node will get executed 10 times. In such a case, you would have to transform the data into a single item. You can reference the code snippet here: JavaScript Code Snippets | Docs
Thank you so much for your prompt reply! I haven’t quite understood where i need to perform this kind of transformation? I mean…how to return an array of JSON?
Please bear with me i am still trying to understand!
I would add a Function node after the Set node to combine the data into a single item. I would then reference this data in the Email node.
I gave a talk on the data structure in n8n at our community meetup. This video might help you understand the data flow in n8n better: Data Structures in n8n by Harshil Agrawal - YouTube
If you can you share your workflow, I can reproduce the scenario and provide you the solution. Please replace any sensitive data with dummy data. (You can this out to understand how you can share your workflow: How can I contribute? | Docs)
Hi @harshil1712,
thanks again for your quick reply! If you don’t mind, let me play a bit with the information you gave me and i will let you know of the outcome! In case it’s too hard for me to solve i will reach out to you and provide the workflow. Don’t worry about the data…they are not sensitive! I always want to try and solve something by myself instead of just give it to someone else to do it for me!
Best regards and really appreciate your kind help!
I just wanted to get the raw values from the Function node into my Email node. When my Email node gets executed i am getting an error message about crashing for unknown reason.
Are you getting error messages? Also, is it the Email node that crashes or is it the Function node.
A quick tip: Since I want to refer to all the values in a single email, I would use the Function node to create the message and pass it on to the Email node.
Firstly let me thank each and everyone of you that took their time in answering my question and gave me even troubleshooting tips! I just wanted to let you know that i have managed to get the job done using @harshil1712 tip in concatenating all my data into a big String. What i was trying to do initially (with no success) is to assign as a text of my email message the “Raw Data” coming out of the Function node. I don’t know the “why” but that was the reason of my error message from the Email node.
I will try to explore n8n a bit more to become more familiar and then see what i can also contribute to the source code!