الدرس 6 · الوحدة 2: Your First Working AI Automation
Error handling, retries and alerts so a workflow never fails silently
الفيديو قريبًا
Learn it with your tutor on the live board
أهم نقاط الفيديو
The leads nobody answered
- A lead form feeding a sheet and a welcome email
- One login expired on Friday night
- Monday: 14 quote requests never answered
- No crash on screen, just silence
What you will learn
- Tell the three kinds of failure apart
- Add retries and safe routes for bad data in n8n
- Build an error workflow that alerts you within a minute
Three ways a workflow breaks
- Timeout: retry
- Bad data: its own route
- Expired key: alert a human
Retries in n8n
- Open a node, then its Settings tab
- Retry On Fail: on
- Max Tries: 3
- Wait Between Tries: 5000 ms
- Short wait respects rate limits
Worked example: one retry, step by step
Execution 1042: Send welcome email (Gmail)
Try 1 09:02:00 failed: mail server busy
wait 5 s
Try 2 09:02:05 failed: mail server busy
wait 5 s
Try 3 09:02:10 success: email sent
Result: run finished, no alert needed Bad data gets its own route
- Never retry bad data
- Check the data first with an IF node
- No email? Send the lead to a Review tab
- Node setting On Error: Continue (using error output)
The error workflow
- A separate workflow that starts with an Error Trigger
- Sends the alert by email, Telegram or Slack
- Main workflow: Settings, then Error Workflow
- Fires when a live, automatic run fails
What a useful alert says
Workflow: {{ $json.workflow.name }}
Node: {{ $json.execution.lastNodeExecuted }}
Error: {{ $json.execution.error.message }}
Open: {{ $json.execution.url }}
Next: reconnect the account, then retry Sara's flow, rebuilt
- Retry when Gmail is busy
- Review tab for leads with no email
- Alarm for everything else
Common mistake: hiding the errors
- Setting every node to Continue just to stop red runs
- Failures turn into empty rows and missing emails
- An alert that was never tested is not an alert
- Fix: break something on purpose once
Recap
- Timeouts get retries; bad data gets its own route
- Expired logins need a human, so send an alert
- Test the alert by breaking the flow on purpose
Your exercise
- Add retries to the Gmail and Sheets nodes of your lead flow
- Route leads with no email to a Review tab
- Build an error workflow and link it in Settings
- Break the Gmail login on purpose and time the alert
النص المكتوب
The leads nobody answered. Picture Sara, who runs a small online bakery. Her lead form drops every request into a Google Sheet and sends a friendly welcome email. One Friday night her Gmail login expired. The workflow stopped quietly, and nobody noticed. On Monday she found fourteen customers who'd asked for wedding cake quotes and never heard back. Nothing flashed red on her screen. The automation simply failed silently. For a client, that's worse than having no automation at all, because they trust it's working. In this lesson we'll make sure every workflow you build either fixes itself or calls for help.
What you will learn. Here's the plan for the next few minutes. First, you'll learn to tell the three kinds of failure apart, because each one needs a different fix. Second, you'll add retries to the nodes that talk to outside services, and a safe route for messy customer data so it never breaks a run. Third, you'll build an error workflow, a small separate automation that sends you an alert within a minute of something going wrong. By the end, Sara's Friday night problem becomes a two-minute fix instead of a lost weekend of sales.
Three ways a workflow breaks. Before fixing failures, let's name them. Almost every failure in a small business workflow is one of three kinds. First, the timeout: Gmail or Google Sheets is busy for a moment, and the very same request would work a few seconds later. Second, bad data: a customer typed their phone number in the email box, so trying again will never help. Third, the expired key: a password or login token stopped working, and only a human can reconnect it. Notice how each kind needs a different answer? That idea is the whole lesson in one picture.
Retries in n8n. Timeouts are the easy ones, and n8n handles them for you. Open any node that talks to an outside service, like Gmail or Google Sheets, and switch to its Settings tab. Turn on Retry On Fail. Set Max Tries to three and Wait Between Tries to five thousand milliseconds, which is five seconds. Many services also have a rate limit, meaning a cap on how many requests you may send per minute, like a shop that lets only five people in at once. A short wait respects that cap. Those three settings alone quietly fix most of the hiccups you'll ever see.
Worked example: one retry, step by step. Let's watch one retry happen, step by step. This is the log of Sara's Gmail node for one execution. An execution is simply one run of the workflow. Try one fails because the mail server is busy. n8n waits five seconds, the wait you set, and tries again. Try two fails too, so it waits another five seconds. On try three the welcome email goes out, and the run finishes green with no alert at all. Notice that the wait stays the same each time. n8n's built-in retry uses a fixed wait, not a growing one. If all three tries had failed, the node would stop with an error, and that's where the alarm comes in.
Bad data gets its own route. Bad data needs a different fix, because retrying it just fails three times instead of once. Put an IF node right after the form trigger and check that the email field isn't empty. Good leads continue to the sheet. Leads without an email go to a separate Review tab, and Sara gets a short note to call them. For nodes that might still reject an odd value, set On Error to Continue, using error output. That gives the node a second exit, so the faulty item takes its own path while the rest of the batch carries on.
The error workflow. Now the expired key, the failure only a human can fix. Create a new workflow whose first node is an Error Trigger. Add a node that sends a message, by email, Telegram or Slack, whatever the owner actually reads. Then open your main workflow, go to its settings, and choose this new one as the Error Workflow. From now on, any automatic run that fails hands its details to the error workflow. One catch: it doesn't fire when you click test by hand, only on real, active runs. One error workflow can watch all of a client's automations.
What a useful alert says. An alert that just says something failed is almost useless at nine in the morning. The Error Trigger hands you real details, and you drop them into the message with expressions, placeholders that n8n fills in with the real details. Say which workflow broke, which node it stopped at, and the error message itself. Add the link to the failed execution, the exact run that broke, so one tap opens it. Finish with a plain next step, written for the client rather than for you. When the alert lands on Sara's phone, she knows what broke, where, and what to do, without calling you first.
Sara's flow, rebuilt. Let's put all three layers on Sara's lead flow. Here's the mail carrier knocking again: when Gmail is busy, the node waits and makes another Retry, up to three times. Next, the sorting tray on the counter: any lead with no email lands in the Review tab instead of breaking the run. Finally, the bell in the back office, our Alarm: if anything still fails, like that expired login, the error workflow pings Sara's phone within a minute. Same Friday night, same expired login, but now Sara reconnects Gmail before breakfast. Zero lost leads.
Common mistake: hiding the errors. Here's the trap many beginners fall into. They see red failed runs, set every node to Continue, and the red disappears. But the failures didn't go away, they just went quiet. Now Sara's sheet fills with empty rows and customers get no email, with no warning at all. It's like taking the battery out of a smoke alarm because it beeps. The second trap is never testing the alert itself. So before you hand over a workflow, break something on purpose, and watch the alert arrive on the client's phone.
Recap. Let's wrap up. First, match the fix to the failure: timeouts get retries with a short wait, and bad data gets its own route to a review tab, never a retry. Second, problems only a human can fix, like an expired login, go to an error workflow that sends a clear alert with the workflow, the node, the error and a link. Third, an alert you haven't tested doesn't count, so break the flow once on purpose. Do this and your client's automations never fail silently.
Your exercise. Now it's your turn, using the lead capture flow from lesson two. Turn on retries for the Gmail and Google Sheets nodes, with three tries and a five second wait. Add an IF node that sends leads without an email to a Review tab. Build an error workflow that sends you a message with the workflow name, the node, the error and the link. Then activate the flow, disconnect the Gmail credential, the saved login n8n uses, on purpose, and submit a test lead. Time how long the alert takes to arrive. Next lesson, we'll build the appointment booking assistant.
ملخص الدرس
- مشاهدة الفيديو
- Timeouts get retries; bad data gets its own route
- Expired logins need a human, so send an alert
- Test the alert by breaking the flow on purpose