Duck
Tutorials5 min read

how to build an ai agent

Samet Turan— Editor··5 min read

Step‑by‑step guide to building a working AI agent: prompts, tools, costs, debugging, and when to grab a ready‑made blueprint for solo operators today.

You keep copying prompts into ChatGPT and hoping the output sticks, but the agent forgets context, repeats itself, or just hallucinates. After reading this, you’ll be able to assemble a simple AI agent that calls an LLM, stores short‑term memory, and triggers actions via a no‑code workflow tool.

It’s frustrating when the agent loops.

What most guides get wrong

Many tutorials treat an AI agent as a single prompt and call it done. They ignore state, error handling, and the glue that moves data between steps. The result is a demo that works in a notebook but falls apart when you try to run it on a schedule or from a webhook.

What they miss is that an agent needs three layers: a language model for reasoning, a memory store for context, and an orchestrator for actions. Skipping any layer leaves you with a brittle script that either repeats the same answer or crashes on unexpected input.

I’ve seen guides suggest using a plain HTTP request to the model and then calling it a day. That approach works only if you never need to remember anything beyond the current turn. In real workflows you need to remember user preferences, previous outcomes, or external data fetched earlier.

How to debug when this breaks

Start by logging the raw input and output of each layer. If the model returns nonsense, check the prompt template and the temperature setting. If the memory store returns empty, verify that you are writing to the correct key and that the storage backend is reachable.

A common failure point is the orchestrator timing out while waiting for a webhook response. Increase the timeout, add a retry loop, and log the HTTP status code. If you see 429 responses, you are hitting a rate limit—back off and try again later.

When the agent seems to hang, look at the orchestrator’s execution log. A stuck step usually means a downstream service is down or returning an error that isn’t being caught. Wrap each action in a try‑catch and send the error to a slack channel or email so you know exactly where it broke.

Why does my agent keep hallucinating?

Hallucinations happen when the model tries to fill gaps with plausible‑sounding fiction. The fix is to ground the model in verifiable data before it generates.

One reliable method is to fetch the needed facts from a database or API, inject them into the prompt as a system message, and then ask the model to answer based only on that context. If the data source is empty, tell the model to say “I don’t have enough information” instead of guessing.

I love how the built‑in memory store in LangChain lets the agent recall the last three messages without extra code. It’s a small feature, but it cuts down on repetitive prompts and makes conversations feel natural.

A concrete example: building a lead‑qualification agent with GPT-4o and Make

First, sign up for a Make account (the free tier gives you 1 000 operations per month). Create a new scenario and add a Webhook module as the trigger. This will receive a JSON payload from your CRM whenever a new lead is created.

Next, add an HTTP module to call the OpenAI API. Use the endpoint https://api.openai.com/v1/chat/completions with model GPT-4o. Set the system message to include the lead’s details (name, company, industry) pulled from the webhook, and ask the model to return a qualification score and a short reason.

Then add a Parser module to extract the score from the model’s response. Finally, use a Router to send high‑scoring leads to your sales Slack channel and low‑scoring ones to a Google Sheet for nurturing.

Here’s a simplified step list you can follow inside Make:

  • Webhook → receive lead JSON
  • HTTP → POST to OpenAI with prompt containing lead data
  • Parser → extract “score” field from response
  • Router → if score ≥ 8 → Slack notification else → Google Sheet append
  • Respond → 200 OK to webhook sender

The cost of the OpenAI call is about $0.003 per 1 k tokens; a typical qualification prompt uses ~800 tokens, so each run costs roughly $0.002. Make’s free tier covers thousands of these runs, so you can test without paying.

I think paying for a premium agent framework is overkill for most solo operators. The combination of Make and a direct API call gives you full control, transparent pricing, and no vendor lock‑in.

My gripe with Make is that the documentation assumes you already know how to set up a webhook security token, which left me staring at a blank screen for an hour before I found the hidden setting in the module’s advanced tab.

(which, yes, is annoying) but once you locate it, the rest of the flow is straightforward.

Choosing the right framework: no‑code vs code

If you prefer writing Python, LangChain or LlamaIndex give you programmatic access to memory, agents, and toolchains. You gain flexibility at the cost of managing a server or a serverless function.

For a solo operator who wants to ship fast, a no‑code orchestrator like Make or Zapier automations reduces the operational overhead. You can still call the same LLM API; you just wrap it in a module instead of a function.

Both approaches can use the same prompt and model, so pick the one that matches your tolerance for infrastructure.

Cost breakdown and opinion on pricing

OpenAI’s GPT-4o pricing is $0.03 per 1 k tokens for input and $0.06 per 1 k tokens for output. A qualification flow that sends 800 tokens in and receives 200 tokens out costs about $0.0036 per execution.

Make’s free tier offers 1 000 operations monthly; each scenario step counts as an operation, so a five‑step flow uses five operations per lead. At 200 leads per month you stay well within the free limit.

Zapier’s free plan limits you to 100 tasks per month, which is too low for any real lead volume; their starter plan at $29.99/mo gives 750 tasks, which still feels tight if you run multi‑step agents.

$29/mo is fair for a basic automation tool, but $199/mo for an enterprise plan that only adds concurrency feels ridiculous when you can achieve the same with a self‑hosted script and a cheap VPS.

Adjacent reading: 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.