Get your API key

Lesson 3 of 5

Schedules, errors and retries

A daily low-stock summary, retries for short failures, error paths, an alert workflow, and limits that stop a looping agent.

9 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson Shree Sarees will get a low-stock summary every morning at 9, and the workflow will retry short failures, fall back when the AI step fails, alert you when a run breaks, and stop an agent that goes round in circles.

You need: the Shree Sarees sheet from lesson 2, your Gmail credential, and the chat agent from lessons 1 and 2 · Time: 9 minutes

  1. You built this shape in n8n 101: a schedule, a sheet, one email. Today it gets an AI step and four safety nets. Create a new workflow called Daily stock check:

    1. Schedule Trigger: every day at 9am. In the workflow Settings, set the time zone to Asia/Kolkata.
    2. Google Sheets: Get Row(s) from the Stock tab, no filter, so it reads every row.
    3. Filter: keep only rows where Qty is less than 3.
    4. Aggregate: choose All Item Data and type data as the output field, so all rows become one item and you get one email, not ten.
    5. Basic LLM Chain with your AllModelAPI chat model, and this prompt:
    Prompt · copy it into your AI agent
    You write a short morning stock note for the owner of Shree Sarees, a saree boutique in Surat.
    Here are the items with less than 3 pieces left, as JSON: {{ JSON.stringify($json.data) }}
    Write at most 6 lines in simple English: first the items at 0, then the rest, each as "Item (Colour): N left". End with one line suggesting which item to reorder first and why. Do not invent items that are not in the list.
    1. Gmail: send the chain's text to the owner, subject Low stock today.

    Why a chain and not an agent? This job is the same five steps every morning. There is nothing for an AI to decide, only text to write.

    Top row: Schedule (every day, 9:00 IST) leads to AI Step (writes the summary), which leads to Email Owner (low-stock summary). Below, four safety nets: 1 Retry (a short blip? Retry On Fail, max 5 tries, up to 5 s apart), 2 Error path (one item fails? On Error: use the error output, park it for a human), 3 Alert (whole run fails? Error workflow with an Error Trigger emails you), 4 Limits (agent going round? Max Iterations and a Timeout stop it early).
    The daily workflow on top, and the four safety nets this lesson adds.
    Why?

    A workflow that runs while you sleep has no one watching it. If it fails silently, the owner doesn't get the email and nobody knows why. Safety nets turn silent failures into retries, fallbacks and alerts.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Net 1: retry short failures
  2. Net 2: a fallback when a step fails
  3. Net 3: an alert when a run breaks
  4. Net 4: limits for the chat agent
  5. Recap