Skip to content
the360techLearn. Certify. Work. Grow.

Popular searches

Automation

How to build an AI agent with n8n, step by step

From trigger to tool calls: build a working agent that qualifies leads automatically.

PDPrashant Deol2 min read
On this page
  1. What we're building
  2. 1. Start with a reliable trigger
  3. 2. Ask the model for structured output
  4. 3. Give it tools and branches
  5. 4. Keep a human in the loop
  6. 5. Log everything and ship

What we're building

We'll build an agent that receives new leads, decides how promising each one is, updates the CRM and sends the right follow-up — without a human touching the easy cases.

The same pattern works for support tickets, job applications or any inbound queue.

1. Start with a reliable trigger

Use a Webhook node to receive leads from your website form or ad platform. Normalise the fields immediately — name, email, company, message — so every later step sees the same shape of data.

2. Ask the model for structured output

Give the LLM your ideal-customer profile and ask it to return JSON with a score, a short reason and a recommended next step. Structured output is what makes AI steps dependable inside a workflow.

  • score: 0–100
  • intent: high / medium / low
  • reason: one sentence
  • next_step: sales_call / nurture / disqualify

3. Give it tools and branches

Route on the score with an IF or Switch node. High scores create a CRM deal and notify sales; medium scores join a nurture sequence; low scores get a polite reply. Each branch is a tool the agent effectively 'chooses' through its output.

4. Keep a human in the loop

For borderline scores, send a Slack message with the lead summary and two buttons: approve or reject. Humans handle the ambiguous cases; the agent handles the obvious ones.

5. Log everything and ship

Write every decision and its reason to a sheet. After a week, review the log, adjust the prompt and thresholds, and you'll have an agent your sales team actually trusts.

PD

Written by

Prashant Deol

Founder & Instructor, the360tech

About the author →

Turn reading into doing

Our programs take these ideas from article to working system.

  • Learn
  • Certify
  • Work
  • Grow