Duck
Tutorials5 min read

Tutorial on AI agent customization: build your own workflow from scratch

Samet Turan— Editor··5 min read

Learn to tailor AI agents to your exact workflow with real prompts, tool examples, and debugging tips. A practical guide for solopreneurs and small teams.

Running a solo operation means you wear every hat, and repetitive tasks eat up hours that could be spent on strategy. This tutorial on AI agent customization shows you how to shape an agent to fit your exact workflow, using real prompts and tools you can run today. By the end you’ll have a working agent that qualifies leads, drafts follow‑ups, and logs outcomes without constant babysitting.

What most guides get wrong about AI agent customization

Many tutorials start with a blank slate and tell you to “just add more prompts.” They ignore the fact that an agent’s behavior is shaped by the data it sees, the tools it can call, and the way you handle errors. If you skip those layers you end up with a chatbot that repeats itself or hallucinates facts.

Instead of piling on prompts, think of the agent as a small factory: raw material (input) goes in, a series of stations (tools, checks, transformations) process it, and a finished product (output) comes out. The most common mistake is treating the language model as the only station and forgetting the conveyor belt.

Why does my agent keep forgetting context after three turns?

This is a reader‑question I hear all the time. The short answer: the model’s context window is being overwritten by each new user message, and you’re not storing the summary anywhere.

When you send a fresh chat completion request, you must include the entire conversation history—or a compressed version of it—if you want the model to remember earlier turns. If you only send the latest user message, the model has no idea what came before.

Here’s a concrete pattern that works: keep a running summary in a separate variable, prepend that summary to the latest user message, and trim the summary when it grows too long. Below is a tiny Python‑like pseudocode you can adapt to any platform.


# pseudo‑code for context preservation
summary = ""
for turn in conversation:
prompt = f"Summary: {summary}\nUser: {turn.user}"
response = llm.generate(prompt)
summary = summarize(summary + "\n" + turn.user + "\n" + response)
if len(summary) > 500:
summary = summary[-500:] # keep last 500 chars
yield response

Apply the same idea in a no‑code tool by storing the summary in a variable node and feeding it back into the next LLM call.

Concrete example: building a lead‑qualification agent with n8n workflows and OpenAI

Let’s walk through a real scenario I ran last month. I needed an agent that would take a new LinkedIn lead, pull the profile URL, ask GPT‑4o whether the person matches our ideal customer profile, and then push a qualified record into a Google Sheet.

First, I set up a trigger in n8n that fires when a new row appears in a “Leads” sheet (the sheet is filled by a Zapier automations scraper). The trigger node outputs the lead’s name and LinkedIn URL.

Next I added an HTTP Request node to fetch the public profile JSON from LinkedIn’s public endpoint (yes, it’s limited but works for demo purposes). I then fed the raw HTML into a Function node that extracts the headline, location, and recent posts.

The extracted text goes into an OpenAI node. I used the following prompt, which you can copy‑paste:


You are a sales assistant. Given the following LinkedIn snippet, decide if the person is a good fit for our B2B SaaS product that helps mid‑size companies automate invoicing. Reply with ONLY "YES" or "NO".

Snippet:
{{ $json["summary"] }}

The OpenAI node returns a single word. I then use an IF node to split the flow: if YES, the lead goes to a Google Sheets node that appends a row with a timestamp and the label “Qualified”; if NO, it goes to a node that logs the lead to a “Rejected” sheet for later review.

What I love about this setup is the execution view in n8n: each node lights up as it runs, and you can see the exact prompt and response in the sidebar. It makes debugging a breeze when the model returns something unexpected.

One gripe I have is the free tier of n8n limits you to 100 workflow executions per month. I hit that limit during a test burst and had to wait until the next cycle to continue testing. (which, yes, is annoying)

On the price side, the $20/mo starter plan gives you 2,500 executions, which feels fair for a solo operator who runs a handful of agents. The $50/mo team plan jumps sharply in price without a clear jump in features, so I’d stick with the starter unless you’re running five or more agents in parallel.

How to debug when this breaks

When the agent stops behaving as expected, start by checking three things in this order: the input data, the prompt, and the tool outputs.

First, look at the raw data that enters the workflow. In n8n you can click any node and see the JSON that came in. If the LinkedIn scraper returned an empty field, the OpenAI node will get a blank snippet and will likely guess.

Second, examine the prompt you sent to the model. Copy the exact string from the Function node or the OpenAI node’s configuration and run it manually in the OpenAI playground. If the model’s answer changes when you tweak the wording, you know the prompt is fragile.

Third, verify the tool that does the action—like the Google Sheets node. A common silent failure is a permission error that doesn’t stop the workflow but leaves the sheet unchanged. In n8n the node will show a red error badge; hover over it to read the message.

If all three look good and the agent still misbehaves, add a logging node after each step to write the intermediate values to a separate sheet or a text file. That trail lets you pinpoint exactly where the drift started.

It’s simpler than you think.

We cover this in more depth elsewhere — deeper coverage of AI agent platforms.

If you’d rather skip the build and deploy a working version in an afternoon, we’ve packaged this workflow as a blueprint at deepusecase.com/vault/ai-agent-builder-kit.

— The Colophon

One AI tool. Tested. Reviewed.
In your inbox every Sunday.

~3 minute read. Real outcomes from operators, not marketers.

Free. One email per Sunday. Unsubscribe in one click.