Skip to content

Agent workflows

Build a first AI agent workflow in n8n

Design an n8n lead triage example using sample records, a read-only tool, structured results and an approval step. Includes retry cases.

Jump to setup
A node editor showing connected stages in a sample workflow

Start with triage rather than sending replies. Use fictional student enquiries, let the workflow propose a course category and a draft next step, then check the result in a review table. You can learn how tools, outputs and approvals fit together without connecting a live inbox or CRM.

Step-by-step setup

Set up an agent with one catalogue tool

What you need An n8n workspace and a supported chat model credential, such as OpenAI. Use test data. Configure the credential in n8n rather than in the prompt.

  1. Chat Trigger
  2. AI Agent
  3. Catalogue tool
  4. Draft you can review
  1. Create a catalogue workflow

    Add When Executed by Another Workflow. Set Input data mode to Define using fields below and add a String field named course.

  2. Return a small result

    Connect an If node to check {{ $json.course }} equals Video Editing. On true, use Edit Fields to return course: Video Editing and topics: Editing, motion graphics. On false, return status: not_found. Save the workflow.

  3. Create the agent workflow

    In a second workflow add a Chat Trigger and connect it to AI Agent. Attach a supported Chat Model under the agent’s model connector and select its credential.

  4. Give the agent one tool

    Attach Call n8n Workflow Tool under Tools. Select the catalogue workflow, refresh the input fields and let the model supply course. Describe the tool as “Look up approved course topics, with no batch dates.”

  5. Run one test chat

    Open the workflow’s chat test panel and send the prompt below. Review the tool result and the final answer. Try an unknown course next.

Copy this example

Use the catalogue tool to look up Video Editing. Give me the course and topics, then tell me whether the next batch date is available. If a fact is missing, say so. Draft only and do not send a reply.

How to tell it worked

The tool returns Video Editing and its two topics. The agent explains that the next batch date is unavailable. An unknown course returns no match.

Run this in the test panel first. Keep write and email tools out of the practice workflow.

Start with test data and a known output shape

Run the workflow manually with a few sample records, each with an enquiry ID and message. Check required fields before the model runs. Decide that the result must contain one allowed category, a concise summary and a review flag. Keep the original enquiry available outside the model output.

Give the agent one read-only tool

The n8n AI Agent node connects a chat model and tools. For this exercise, the only tool looks up approved entries in a sample course catalogue. Write its description so the agent knows when to use it. If the catalogue cannot answer a question, have the agent mark the missing information for review.

Sample review queue on a computer with pending and completed items
A draft queue lets you inspect the result of a practice workflow before connecting an inbox or CRM.

Validate and add a review step

Check the category outside the model and route unrecognized values to a manual queue. Save the draft with the input, course facts and reason for the classification. When a later version can perform actions, put review immediately before the specific tool or workflow step that has an external effect.

Test retries before using real records

Send the same enquiry ID twice and verify the second run does not create a duplicate draft. Simulate a failed lookup and a rejected review. Decide which errors can be retried and how someone will see unfinished runs. Start with a recorded mock result when testing whether approval logic works.

Try it yourself

Create five fictional enquiries about course fees, batch dates and syllabus details. Implement a draft queue and prove that a duplicate ID and a rejected decision never lead to a second draft or a send action.

Common questions

Do I need an email tool to practise?

No. Return a draft to a test table first. That gives you something to evaluate without sending messages.

Does this article confirm live n8n classes at Picmkr?

It is a practice guide. Ask admissions which platforms and workflow exercises are included in the current course batch.

Sources and further reading