# n8n Advanced Course (5/8) - Error workflows

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

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=77Ewdaby47M
- **Дата:** 20.06.2024
- **Длительность:** 7:49
- **Просмотры:** 24,161
- **Источник:** https://ekstraktznaniy.ru/video/15642

## Описание

⌨ 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-5-8-error-workflows/48600

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

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

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

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

hey and welcome to video number five of the advanced course for NN in this video we'll be covering everything you need to know about the error workflow and an example workflow that you can Implement in your instance today in the beginner course we briefly covered the error trigger node this node returns information such as the node that errored the reason for the error the link to that execution and much more information using this set of information about the error we can construct a standard error message for example this one here we have the name of the workflow just failed the execution ID the type of error and the link to the failed execution this makes it really easy to see what kind of error occurred and quickly access the execution history of that specific workflow we could even use the error workflow to attribute an urgency score or priority level depending on the type of error for example a 500 error would be low because it means that the service that we are using is unavailable and there's most likely nothing we can do about it whereas a 400 error might be much higher on the priority list because this won't fix itself over time if you have multiple users in your NN instance you might have different owners for different workflows these owners will be the best person to contact if you need to update or maintain workflows you can use a tag system to assign a user to contact for support on any given workflow here we can see that these four workflows have owner tags Maxim Anna and Paul let's look at how we can build an error workflow to notify the right naden user when a workflow has an error by recreating the workflow we can see below briefly before we jump into it what this workflow does is it gets the error of the work flow it goes and enriches information about the given workflow for example getting the owner then it looks up in a table who the associated owner is and then it notifies the associated owner through slack or through gmail together let's build this uh Advanced error workflow uh we're going to start off with uh an error trigger so as we mentioned in the course the error trigger is going to give you information about the workflow that failed uh as well as the node the execution um everything you need to go back to the workflow and uh make any corrections the first thing we're going to want to do here is get more information about the workflow itself we already have some information but uh because we're going to be routing the error message to the owner it's going to be a lot better if we get the tags on the work flow so what we're going to do here is add the NN node and I want to get a workflow uh here we have the workflow ID so um when I'm going to get the ID going to get this one but uh for the purpose of this exercise let's work with uh another workflow that has uh an owner name then using the edit Fields node we can uh get the owner and put it top level so workflow owner and here I'm going to get the owner here tags name maximum this is going to be our owner tag and I want to put it uh top level so we have it here work for the owner Maxum it's going to be a lot easier to access then we obviously still need the information from the eror trigger so we're going to merge by position here we have the information about the workflow and error while we're at it uh I'm going to add a little error message so here again I'm going to add an edit fields and include an error message so here as a string and add the expression so this is

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

just a little work um error message that I wrote earlier here by merging I'm going to have everything I need then we need to figure out okay now that we have the owner and all the information uh we need to figure out for that specific owner how do we contact them so I already made to save us some time a little code node this node just contains a list of items with the name of the person owner and their Associated email so as we saw last time we're just going to use again another merge to enrich so this time combine Again by position sorry here combined by Fields because we need in input one I need to execute in input one we want to match the name to input to the workflow owner so here it'll give me the email and from here I can decide to just send an email for example send a message to the workflow owner on your workflow little typo and include the message that we added at the beginning perfect and now depending on which error has the workflow it'll send to the right person if you want to take this to the next level uh what we could do here is not only have Associated email but we could have an Associated um workflow ID and use this as well as the execute workflow to uh pass here the workflow ID of the owner and that way the owner can deal with however um deal with the workflow error however they want um they could have some logging they could have a message on slack or on teams or an email and that means that every wor every person is going to be able to manage this however they see fit thanks for listening to the fifth video of the niden advanced course where we covered the trigger error node and an example of an error workflow
