n8n Advanced Course (1/8) - Working with complex data flows
16:37

n8n Advanced Course (1/8) - Working with complex data flows

n8n 20.06.2024 118 485 просмотров 1 459 лайков

Machine-readable: Markdown · JSON API · Site index

Поделиться Telegram VK Бот
Транскрипт Скачать .md
Анализ с AI
Описание видео
⌨ Sign up to n8n Cloud for a free trial: https://app.n8n.cloud/register Or: npm install -g n8n n8n start *Resources:* ❔ Need help or want to discuss the course? Join the conversation on our forum: https://community.n8n.io/t/advanced-course-1-8-working-with-complex-data-flows/48596 🛠 Workflow templates: https://n8n.io/workflows/ 📚 Documentation: https://docs.n8n.io/

Оглавление (6 сегментов)

Introduction

hello and welcome to video number one of the advanced course for niden in this course we will be covering everything you need to know to become an expert workflow builder in this video specifically we'll talk about how data flows through anyen

Node execution order

workflows in the beginner course we started to create short branches so you might have wondered if we have multiple branches what order do the different nodes in those branches execute in so we're going to talk about node execution order for workflows created in version 1. 0 and above and then will execute each branch in turn completing one branch before starting another branches are ordered based on their position in the canvas from topmost to bottommost if two branches are at the same height it is the leftmost branch that will execute first in this workflow you can see that the node execution order would be weight then weight one then weight two and weight three followed by weight four and weight five so we'll be going top to bottom left to right this can be changed on a workflow basis however it is not recommended this will execute uh the first node of each branch then the second and so on and so forth when building workflows where branches depend on each other's output it is always recommended to merge branches together before using the data from those branches instead of changing the node execution

Split data

order as covered in the beginner course we can use the if node to split data into multiple branches the if node splits the input items down two distinct branches whether the condition is true or false we already saw this in the beginner course we won't be covering this uh in this video we can also use the switch node to create n branches and also assign a fallback Branch creating n total branches that split the items amongst them so here we have 10 items in the switches input and these are being split into one item one item and seven items totaling 10 a similar effect can be produced by dragging two output branches from a single node this will send all of the items from the nodes output down each one of those branches following the order of execution we mentioned previously this can be useful when you want to execute two separate sets of distinct actions from a set Target

Merge data

point the same way that we can split data into different branches we can also merge data from different branches using the merge node is a peculiar node because it has not one but two inputs the node waits for data from both branches to arrive and then performs one of the following merge options append combine choose append will simply output the sum of both branches appending them one to another choose will let you well choose one the other or no items to pass this can be useful to ensure that two or more branches have finished executing before continuing with the workflow and finally combine lets you merge the inputs by field position or all combinations a good mental model for the um merge node is the SQL join operation inner and outer joins are equivalent to keeping matches or not keeping matches the left join is equivalent to enhancing or enriching the first input branch and the right join enhancing the second input Branch unions are equivalent to aens in this case

Loop over items

another useful node when dealing with sets of items is the loop over items node sometimes when dealing with large amounts of data or when using certain nodes we need to be able to treat items as individual sets of items in comes the split in batches node or Loop over items it allows you to split the input items into different batches of a given size for example here the batch size is of one and so there's only going to be one item going down the loop most of the time you don't need this node and end nodes already execute once per item however this can be a very useful node when dealing with certain types of nodes some nodes will return n items even though they have only one input item an example of this would be Google Sheets if we are reading data from a sheet we're going to be reading potentially n lines of data here if we need to read multiple sheets because we have multiple items we can Loop over the items to be able to read each sheet per item we'll cover this in the um examples loopover items can also be useful when dealing with API rate limits so sometimes apis will only allow us to make X actions over y amount of time so for example only 10 calls per minute or 100 call calls every 10 seconds loopover items can help us spread out those different API calls especially if we have a lot of them to do by splitting into batches we can use the weight node and make sure that we aren't overloading the API you can access the different runs in the output panel here by clicking on run this will be useful for understanding what items are going through the different runs and how they're being changed as you Loop over the items the loop over items node as well as all the other nodes that are in the loop you create will have a green number next to the green check mark indicating what number Loop they're on you can also access the different output items in the same way as you did for the loop over items node itself where you can see for each different iteration of a loop what were the output items for the nodes in the loop so here we are in NN and the uh first thing I'd like to show you is a quick example on the Node execution order so here if we test this workflow and I'm using the weight node so we can sort of see it go through uh at a bit more visible rate here we'll have the first branch that will be executed in its entirety and then once we are finished with this Branch we'll move on to the second branch that will execute completely followed by the third so keep this in mind when building workflows uh branches will execute top to bottom and left to right so now we're going to be using uh this workflow to show two different ways of using the merge node so here we have a very simple workflow um that we pretty much covered in the beginner course we get a list of 10 contacts we use the if node to create two branches depending on if it's a personal email or a professional email and here we're going to be using the edit Fields node to add a email type personal or email type professional so if we execute this workflow we see the split and what we might want to do here is now continue working on all of these contacts as a whole so using here the merge node I can add in and connect the two inputs and we can see here we have three items here seven items here and if I select the append it will combine all items of input one and two so here if I test this step we're back to 10 items and each item will now have a email type personal or email type professional because we had our top branch that was personal we have all of our personals first and then all of our professionals a another way of using the merge node uh so what we're going to do is give ourselves a little bit of space is to um do what we call enrichment so what we could do here let's just give ourselves a bit of space here I have another Google sheet that we're going to read and this Google sheet contains information about the companies so if I execute this we're going to see we have information on the companies their website and their country so what we can do here is on the branch of professionals so people who have an Associated company we can enrich these contacts with information from the companies here if we were to use a simple append we would have different items for the contacts and for the companies so what we're going to do instead is we're going to combine the data um what we need to do here is figure out how can we um link the contacts to the companies so I'm going to show you two ways the first way and we could simply do it here would be uh to add a key called domain here using the email in a little bit of JavaScript we could split the email at the at sign and then take the first value so this is going to give us everything after the add sign so if we test this step for each contact we have the domain and now each contact has a domain key and each company also that we can see here website so here we can add a new merge node and this time instead of appending we're going to combine here we have the different inputs we can see that we have the Google sheet inputs and the tag as professional to make it a little bit clearer here let's rename this to get companies and looking at the merge node we can see that to merge by fields we need to give the name of a field in input one and two this is basically going to be our matching key so our two inputs are get companies input one and then this set sorry this edit Fields node which is going to be input two that we can read up here input one and input two from get companies we want the website and from TAG as professional we want the domain here we would like to we can choose between keeping matches keeping non-matches or keeping everything in this case U we're because we're doing an enrichment what we're going to do is keep all of input two with data from input one added in this is because we're working on a contact basis and we want to enrich all of the contacts that have professional emails with um company information so here if I test this step we can now see that Marcus Bennett from Quantum we now have the information from the other sheet uh that was that contained information on their website and the country this is a great way that we can enrich um branches with extra information this can be a Google sheet a database an API call and then we just merge the data depending on the field if we wanted to do a enrichment uh through for example API calls where for each item we would do one HTTP request we could merge not by Fields but by position and have a very similar result just finishing off this workflow I can pull this in here and now if we execute the workflow we can see that we've created two distinct branches and this one we need to set it as execute once because we only need one time all of the companies and we can see that we have very similar to the first uh result when we just did the simple penda merge 10 items here a split and an enrichment oops with an if three appear here seven down here that get enriched and then we merge them back into 10 and so here we have pretty much the same information as the sheets but with a bunch more information that we added through these

Summary

branches thanks for listening to this first video of the niden advanced course where we covered node execution order splitting and merging branches in the next video we'll take a deep dive into some more advanced nen nodes see you in the next one

Другие видео автора — n8n

Ctrl+V

Экстракт Знаний в Telegram

Экстракты и дистилляты из лучших YouTube-каналов — сразу после публикации.

Подписаться

Дайджест Экстрактов

Лучшие методички за неделю — каждый понедельник