# n8n Advanced Course (6/8) - Build a full example

## Метаданные

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=wOKLEfeJLVE
- **Дата:** 20.06.2024
- **Длительность:** 14:11
- **Просмотры:** 31,993
- **Источник:** https://ekstraktznaniy.ru/video/15641

## Описание

⌨ 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-6-8-build-a-full-example/48601

🛠 Workflow templates: https://n8n.io/workflows/

📚 Documentation: https://docs.n8n.io/

## Транскрипт

### Segment 1 (00:00 - 05:00) []

hello and welcome to video number six of the advanced course for nadn in this video we will be building a complete workflow from scratch so let's di right in the objective of the workflow that we're going to be building today is to use the form trigger to take a list of uh company URLs as an input then we will be enriching these URLs using the people data lab API um while making sure to manage all errors then we will append all of this data of the companies that are in Europe to a Google Sheets before summarizing the data and sending a um slack message so the first step here is going to be to add our form trigger um this will allow us to have an interface that we can share with people where they'll be able to uh submit this list of URLs so here we have submit URL form we'll leave the description blank for now and we'll just have one field called URL now I can test this step and I will see this uh form pop up and here I can have a list of URLs here we have Google naden Facebook pulan and spendesk when I submit the form I can go back to the workflow and I will would have the uh data here as one item the first thing we're going to do here is pin this data we don't want to have to go back into the form and submit it again and again every time um we can just pin the data so we have workable items um to start using the next step is we want to split out these URLs um so that we can go over them one by one from here we can use the edit Fields node to separate this uh string of URLs into an array or a list that we can then split the one item into multiple items so that we can Loop over field by field so here we're just going to name this URL list the type is going to be an array and for the value we want the list of URLs except this time we're going to split it by the comma value so here when we execute this we're going to have the list of URLs directly here we don't need anything else so I'm not going to include the other input Fields now I can use the split out node to take this URL list and turn it into different items and we can move over to the enrichment part of the workflow so what we're going to I want to do here is um iterate over each URL one by one so we can use the loop over items node here I want the batch size to be of one I want to go through the URLs one by one so if I execute here you see from the five items we go down to one after looping over all of the items I can add an HTTP node here and we can take a look at the document ation for people data Labs here we're going to use the SQL query so it's a get onto this URL so I can copy over the URL then I see here we have a header for authentication so I've already set this up I have generic credential type is going to be a header or as described in the documentation and I already have this set up with my API key here we have the body so we have two different fields that we need the size so the number of results that we want to get as a result and then the SQL query itself so we can send a body size one and SQL and I can just copy over this query now we should be ready to execute but we actually need to replace this Google. com with the expression for um the current URL that we are working on just to make sure that we're not always looking up Google but we're looking up the right company every time so here I can replace all of this website equals dollar json. URL list and here actually we need to separate this out because this is going to be

### Segment 2 (05:00 - 10:00) [5:00]

part of the string and the final um apostrophes so here when I execute this it should perfect so we have a status 200 and we have the information about Google that was returned the first thing we would like to do here is handle any potential error so how do we do this we're going to use an if node and we can check if the status field here is which is going to be a number is equal to 200 sorry it's not equal to 200 this means that we don't have a positive response and uh we need to handle the error so if the uh answer is not 200 then we can stop and throw an error on PDL enrichment if we don't have an error we can just loop back over and that way for all five items uh we're going to do this enrichment so starting again from the form trigger we can execute all of the nodes and uh one by one these are all going to be enriched from here we can set an edit fields and uh just maybe make the information a little bit easier to access here we have a very uh deep Json so what we can do is we can pull the primary information up uh top level so what we want is to find all of the companies that um are in Europe so what we're going to do is add a few Fields here the first thing here let's execute the full work so here we can just execute so that we have all of the uh data and we can keep building the workflow what we'd like to do here is take all of the data we need and move it up top level so we're only going to include specific fields and the fields that are going to be useful are the name the number of employees which is going to be a number employee count then we need the country which is going to be somewhere in location country United States we need the geography or the continent so we know if it's Europe and finally we're going to add the amount of funding because this might be useful and if we look in here total funding raised perfect so when we execute this uh we now have only the main information that we need um for every single one of these companies now we're going to uh filter this with an if node and here we're going to um only keep companies that are in Europe so I want the continent and here where string is equal to Europe and here we're only going to have three companies that are in Europe I have a Google sheet here with name employees country and funding and we're going to add a Google sheet node we're going to append rows into the company and data and here we we're just going to map the fields so we have name employees country and funding when we execute this it's going to add all of the names to that Google sheet the final step in our workflow is going to be sending a summary message in slack um so that we know how many companies we added um to the Google sheet so we're going to use the summarize node here and we're simply going to be counting the number of names which is going to give us here the length we could have done this with um set Fields node that we uh using an expression for example but here we have a built-in node that we can just use finally let's add the slack node and we're going to send a message here I already have uh my authentication set up it is simply uh an oo so I can just log in it'll open a

### Segment 3 (10:00 - 14:00) [10:00]

window and I can log into my slack account we're going to be sending a message to a user in this case myself and instead of using a simple text message we're going to use blocks allow you to have a little bit more control over um the slack messages uh for example including buttons and what we're going to do here is add a button that links back to the sheet so that it's very easy to access in the slack documentation we have a few uh templates that we can use to help building blocks instead of starting from scratch we're going to use this one and modify it for our use case so we're going to start with a maxim here we're going to confirm what the workflow just did your NN workflow just added X companies to your Google sheet and we will replace X in the um expression directly in anyen we don't need these puted points and here we can just add here is a link to access your Google sheet and here using the button I can uh change the text Google Sheets and I can just copy over the value directly here so now this I can use by copying all of this directly in naden and I can paste the block Builder directly here so obviously I now need to change the x that I mentioned up here and I can simply do this with an expression here using oops json. counter name and when I execute this I can add a little notification message when I test the step I'm going to oops it's going to send the message with the direct number of um companies that were added in the sheet mentioned in the message so now we have the full workflow uh what we can do is do a final test run it A to Z and make sure that everything is working as expected so I'm going to get the list of URLs again refresh the page test the workflow oops okay now refresh the page here I'm going to unpin the data so that we can start a fresh and when I click test step and I put in my list of companies submit form we should see everything go through so here we get all the URLs split them out start looping over get enriched five times all of them were 200s we go back and we get our main data top level add them to the Google Sheets summarize the number of items that were added to the sheet and then send our final slack notification uh confirming that the work was successful and giving a recap thanks for listening to video number six of the advanced course in the next video we'll be covering how to handle files in your nend workflows
