How to build an AI agent in 7 steps (with or without code)
To build an AI agent you need four things: a clear task, a model, functions and tests. Building it is not the hard part: making it work well with real customers is. This guide follows the order that avoids rework.
Step 1. Pick a single task
The most common mistake is wanting an agent that does everything. Start with a repetitive, measurable, low-risk task:
- Answer frequent questions and book appointments.
- Qualify leads that arrive on WhatsApp.
- Give order status.
Done = you can describe the task in one sentence and say how you know it went well.
Step 2. Choose how to build it
| Option | For whom | Time | Upside | Downside |
|---|---|---|---|---|
| No-code platform | Businesses without a technical team | Hours or days | Fast to launch | Less control; you depend on the platform |
| Visual automation (flows with AI nodes) | Teams that already automate | Days | Connects to many apps | Gets complicated fast |
| Code with an SDK (Claude Agent SDK, OpenAI Agents SDK, LangGraph) | Developers | Weeks | Full control | Needs maintenance |
| Hire one that exists | Whoever needs results now | Immediate | Zero building | Less customization |
Not sure? Read Should you build or hire an AI agent?.
Step 3. Define its functions
List the actions it needs and nothing else. For a booking agent: check_availability, book_appointment, cancel_appointment, hand_off_to_human. Each with a clear description and parameters with a format. See Functions in AI agents.
Step 4. Write its instructions
The instructions (the system prompt) say who it is, what it does, what it doesn't do and when it hands off to a person. Write them as if you were training a new employee:
- Its goal in one sentence.
- Which data it must have before acting.
- What it must never do.
- When to ask a person for help.
Step 5. Give it memory carefully
Memory lets it remember the customer, but it also piles up junk: repeated data, contradictions or sensitive information it should not keep. Decide what it stores and review it regularly.
Step 6. Test it with cases it has never seen
This is the step almost everyone skips. Testing with your own messages doesn't work: the agent passes the test you already know it will pass. You need:
- Real or realistic cases the agent has not seen.
- An objective way to grade: did it call the right function? with the right data? did it ask for what was missing?
- A number: the share of correct answers before and after each change.
Without a number you don't know if a change made the agent better or worse. See Best tools to test AI agents.
Step 7. Launch with limits and measure
Launch at a low autonomy level (acts with approval or acts and reports) and move up only with data. Log every action. See How much freedom does an AI agent have.
Measure your agent before launching
AUN measures how your agent calls its functions on a hidden test, returns a fix that keeps names and parameters unchanged, and measures again. You pay per call and only if the report exists.
- Audit my agent
- Review my agent's memory
- Already running? List it and sell it on AUN
Frequently asked questions
How much does it cost to build an AI agent?
It depends on the route: a no-code platform can be a monthly subscription; a custom one means development hours plus the model cost per use.
Can I build an AI agent for free?
You can prototype for free with trial plans and open-source tools. In production you always pay the model per use.
How long does it take?
A prototype, hours. A reliable agent with real customers, two to six weeks, mostly testing and adjusting.
Which model should I use?
One that handles tools well. Test two with the same cases and keep the one that gets more right for less cost.