n8n Advanced Course (4/8) - Subworkflows
7:33

n8n Advanced Course (4/8) - Subworkflows

n8n 20.06.2024 52 432 просмотров 661 лайков

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-4-8-subworkflows/48599 🛠 Workflow templates: https://n8n.io/workflows/ 📚 Documentation: https://docs.n8n.io/

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

Introduction

hello and welcome to video number four of the advanced course for naden in this video we'll be covering subw workflows the secret to making your end operations a lot more scalable but also increasing the speed of workflow building so the

What is a Subworkflow

first topic we need to cover is you know what is a subw workflow the execute workflow node allows you to call one workflow from another allowing you to either execute multiple workflows back to back or extract a part of a workflow into its own dedicated workflow for example this workflow has a group of nodes that are used to look up a user in a database everything here that is covered by the note we could replace this with a subw workflow from a technical point of view It executes The Chosen andn workflow by taking its input data and outputting it from the when called by another workflow trigger this workflow will then execute item by node item by item and the items from the final node of the workflow are returned to the original workflow so here in this diagram the output data from edit Fields would go into the execute workflow this would then be used as input data for the execute workflow trigger and when this workflow is done executing it'll take the items from the last node of the workflow and use it as output data for the execute workflow node and then it'll just continue in the original

Why Subworkflows

workflow so the subw workflow pretty much allows us to extract a set of nodes from a given workflow and make it into its own workflow but why is that used ful there are some sets of actions that you will often have to do in multiple different workflows for example enriching information about a person looking someone up in a database looking up a certain order number in a table and creating a subw workflow allows you to abstract a more complex task allowing everyone to use the right method simply by calling the subw workflow this also makes maintenance a lot easier if you need to update the enrichment process or add a new table in the lookup it can be done once and the updated version will be used across all workflows that call it there are two important things to note when using subw workflows first be sure to use a standard format for key names or embedded Json object structures if the input data has a key email with an uppercase E but the subw workflow reads a key email with a lowercase e the subw workflow will fail here we can see the output data has a capital or uppercase E and the subw workflow is checking for a lowercase e the output data of the execute workflow node would also be the output data of the last node of the workflow so be mindful of which node is the last one in your workflow what the different values of the keys are and if you need to join the input data or not so to illustrate how a subw workflow Works um we're going to use this um little workflow that I have here so I'm just going to test the workflow and on myself a web hook what this workflow does is it uh extracts the information from the web hook if it has an ID it tries to cross reference it with a Google sheet and um gets any potential matches if it doesn't have an ID but has an email then it does the same operation in the same Google sheet this time using the email as the key and if no ID and no email are in the web hook this means it will return an error and so we use the Stop and error node um then we just send some messages the whole point of a sub workflow is this lookup would be useful um in other places in other workflows than only this one so what we could do is extract this and replace it uh by a subw workflow that we would then call from the original workflow so here I'm going to take all of these nodes I'm going to cut them out and replace them by an execute workflow for now we're just going to leave this empty because we need to create the workflow to get the ID save this workflow create a new workflow called lookup here I will paste all of the nodes from earlier and launch the workflow with the execute workflow trigger one more thing we need to be uh careful about is the final node so what I like to do just to make it a little bit easier is drag everything here to have a very clear final node and then I can get the workflow ID from the URL and heading back to the original workflow I can now insert this and run the workflow as we did previously as we see it had exactly the same output it did the whole lookup and returned the right contact so this is very useful when um we have parts of workflows that we might want to execute multiple times um a very important thing to note is before using an execute workflow make sure to standardize the fields bring them all back top level um just so you don't have any um trouble using the subw workflow um you can also in the subw workflow add some documentation with a note for example saying please give me an ID or email field top level and that way anyone who wants to use this subw workflow will be able to very easily thanks for listening to the fourth video of the advanced course where we covered subw workflows when to use them and some tips and tricks in the next video we look into an advanced error workflow

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

Ctrl+V

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

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

Подписаться

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

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