Academy5 Jul 20249 min read

Build Your First AI Agent in 4 Hours: Complete Beginner's Guide

Step-by-step tutorial for building your first AI agent from scratch -no coding experience required. Working agent in one afternoon using Zapier and Claude API.

MB
Max Beech
Head of Content

TL;DR

  • Build a working AI agent in one afternoon with zero coding experience using Zapier + Claude API.
  • Our example: Email classification agent that automatically labels, prioritizes, and routes incoming emails.
  • Total cost: £20-25/month (Zapier Starter + Claude API credits for ~500 emails/month).
  • Skills learned: AI prompt engineering, workflow automation, API integration -foundational for advanced agent building.
  • By hour 4, you'll have an agent handling real tasks autonomously.

Jump to prerequisites · Jump to hour 1 · Jump to hour 2 · Jump to hour 3 · Jump to hour 4 · Jump to FAQs

Build Your First AI Agent in 4 Hours: Complete Beginner's Guide

Right, let's build an actual working AI agent this afternoon. Not a toy example -a real automation that'll handle tasks while you sleep.

I'm assuming you've never written code before. That's fine. We'll use no-code tools that do the heavy lifting. By hour 4, you'll have an agent that reads your emails, decides which are urgent, categorises them, and routes them appropriately.

Sound useful? Let's start.

What We're Building

Agent name: Email Triage Assistant

What it does:

  1. Monitors your Gmail inbox for new emails
  2. Reads each email's subject and first 100 words
  3. Classifies into categories: Urgent, Work, Personal, Newsletter, Spam
  4. Assigns priority: High, Medium, Low
  5. Applies Gmail labels automatically
  6. Sends you a Slack message for High priority emails

Why this agent? Email overload is universal. An agent that filters noise and surfaces what matters saves 30-60 minutes daily for most people. Plus, once you've built this, you can adapt the pattern to automate dozens of other workflows.

Prerequisites

Time: 4 hours (can split across 2 days if needed)

Cost:

  • Zapier Starter plan: £16/month (first 14 days free)
  • Anthropic Claude API: ~£8-10/month for 500 emails (pay-as-you-go)
  • Total: ~£24/month (cancel anytime)

What you need:

  • Gmail account (free)
  • Slack workspace (free tier fine, optional but recommended)
  • Computer with web browser
  • Credit/debit card for paid accounts (trials available)

Skills required: Absolutely none. If you can use Gmail, you can do this.

Hour 1: Setup and Accounts

Step 1: Create Anthropic Account (15 minutes)

Anthropic makes Claude, the AI we'll use for decision-making.

  1. Go to console.anthropic.com
  2. Click "Sign Up"
  3. Enter email, create password
  4. Verify email (check inbox/spam)
  5. Once logged in, click "API Keys" in left sidebar
  6. Click "Create Key"
  7. Name it "Email Agent" and copy the key (starts with sk-ant-)
  8. CRITICAL: Save this key somewhere safe (password manager). You'll need it in Hour 2.

Cost check: Anthropic gives you £4 free credit to start. That's enough to process ~400 emails. After that, it's pay-as-you-go: roughly £0.02 per email classified.

Step 2: Create Zapier Account (10 minutes)

Zapier connects apps without code.

  1. Go to zapier.com
  2. Sign up with Gmail (click "Sign up with Google" for easy auth)
  3. Choose "Starter" plan (14-day free trial, no card required initially)
  4. Skip the template suggestions (we're building custom)
  5. You'll land on the Zapier dashboard

Step 3: Set Up Slack (Optional, 15 minutes)

If you don't have Slack, skip this. We'll use email notifications instead.

If you have Slack:

  1. Open your Slack workspace
  2. Click your workspace name → Settings & Administration → Manage Apps
  3. Search "Incoming Webhooks"
  4. Click "Add to Slack"
  5. Choose a channel (create #agent-alerts if you want)
  6. Copy the Webhook URL (keep this handy)

Step 4: Understand the Flow (20 minutes)

Before building, understand what happens:

New Gmail arrives → Zapier detects it → Sends to Claude API → Claude classifies → Zapier applies label + sends Slack alert

Key concept: Trigger → Action → Action

  • Trigger: New email in Gmail (Zapier watches inbox)
  • Action 1: Send email to Claude, get classification back
  • Action 2: Apply Gmail label based on classification
  • Action 3: If High priority, send Slack message

This pattern (trigger → decision → actions) is the foundation of all AI agents.

Hour 2: Build Classification Logic

Now we build the "brain" -the prompt that tells Claude how to classify emails.

Step 5: Create Zap (5 minutes)

  1. In Zapier, click "Create Zap" (big orange button)
  2. Name it "Email Triage Agent"
  3. Click "Trigger" → Search "Gmail" → Select "New Email"
  4. Click "Sign in to Gmail" → Authorize Zapier to read emails
  5. For "Label/Mailbox," choose "INBOX" (only monitors inbox, not sent/drafts)
  6. Click "Test trigger" → Should show your most recent email
  7. If test works, click "Continue"

Step 6: Add Claude API Action (20 minutes)

This is where the AI magic happens.

  1. Click "+ New Step" → Search "Webhooks by Zapier" → Select "Custom Request"
  2. Set these fields:

URL:

https://api.anthropic.com/v1/messages

Method: POST

Headers:

x-api-key: [PASTE YOUR ANTHROPIC API KEY HERE]
anthropic-version: 2023-06-01
content-type: application/json

Data (this is the prompt):

{
  "model": "claude-3-5-sonnet-20241022",
  "max_tokens": 256,
  "messages": [
    {
      "role": "user",
      "content": "Classify this email. Return ONLY valid JSON with no additional text.\n\nEmail Subject: {{1. Subject}}\n\nEmail Body (first 100 words): {{1. Body Plain}}\n\nReturn this exact JSON format:\n{\n  \"category\": \"Urgent\" | \"Work\" | \"Personal\" | \"Newsletter\" | \"Spam\",\n  \"priority\": \"High\" | \"Medium\" | \"Low\",\n  \"reason\": \"brief explanation\"\n}\n\nClassification criteria:\n- Urgent: Time-sensitive, requires action today (meetings, deadlines, client requests)\n- Work: Job-related but not urgent\n- Personal: Friends, family, personal matters\n- Newsletter: Marketing emails, updates, subscriptions\n- Spam: Unsolicited, irrelevant, or suspicious\n\nPriority:\n- High: Requires response within 4 hours\n- Medium: Requires response within 24 hours\n- Low: FYI only, no response needed"
    }
  ]
}

What's happening here?

  • {{1. Subject}} and {{1. Body Plain}} are Zapier variables pulling from the email trigger
  • We're telling Claude exactly how to classify (5 categories, 3 priorities)
  • We demand JSON output so Zapier can parse the response
  1. Click "Test step" → Should return JSON like:
{
  "category": "Work",
  "priority": "Medium",
  "reason": "Project update email from colleague"
}

If test fails, check your API key is correct and has no extra spaces.

Step 7: Parse Claude's Response (15 minutes)

Zapier needs to extract the classification from Claude's response.

  1. Click "+ New Step" → Search "Code by Zapier" → Select "Run JavaScript"
  2. In "Input Data," add:
    • Key: claudeResponse
    • Value: Click and select "2. Data Content 0 Text" (this is Claude's response)
  3. In "Code," paste:
const response = JSON.parse(inputData.claudeResponse);
return {
  category: response.category,
  priority: response.priority,
  reason: response.reason
};
  1. Click "Test step" → Should output category, priority, reason as separate fields

Now we can use these in the next steps.

Hour 3: Connect and Test

Step 8: Apply Gmail Label (20 minutes)

Make Gmail automatically label the email.

  1. Click "+ New Step" → Search "Gmail" → Select "Add Label to Email"

  2. Click "Sign in" (if not already connected)

  3. Set fields:

    • Message ID: Click and select "1. Message ID" from trigger
    • Label: Create formula: Agent: {{3. Category}}

    This creates labels like "Agent: Urgent", "Agent: Work", etc.

  4. Click "Test step" → Check Gmail -email should now have label applied

Note: First time, Gmail will ask you to create these labels. Click "Create" for each.

Step 9: Send Slack Alert for High Priority (15 minutes)

Only alert you for emails that need immediate attention.

  1. Click "+ New Step" → Search "Filter by Zapier"
  2. Set condition:
    • Field: Click and select "3. Priority"
    • Condition: "Exactly matches"
    • Value: High

This means next step only runs if priority is High.

  1. Click "+ New Step" → Search "Slack" → Select "Send Channel Message"
  2. Connect Slack account
  3. Set fields:
    • Channel: #agent-alerts (or whatever you created)
    • Message Text:
:rotating_light: High Priority Email

*From:* {{1. From Name}}
*Subject:* {{1. Subject}}
*Category:* {{3. Category}}
*Reason:* {{3. Reason}}

<{{1. Message URL}}|View Email>
  1. Click "Test step" → Check Slack -should see alert

Step 10: Test Full Flow (25 minutes)

Moment of truth. Let's test with real emails.

  1. In Zapier, click "Publish" at top right

  2. Turn on the Zap

  3. Send yourself 5 test emails:

    • Test 1: "URGENT: Meeting moved to 2pm today" (should be Urgent, High)
    • Test 2: "Weekly team update" (should be Work, Medium)
    • Test 3: "Hey, free for coffee this weekend?" (should be Personal, Low)
    • Test 4: "Subscribe to our newsletter!" (should be Newsletter, Low)
    • Test 5: "You've won $1 million!" (should be Spam, Low)
  4. Wait 2-3 minutes (Zapier polls Gmail every 1-5 minutes on Starter plan)

  5. Check Gmail -are labels applied correctly?

  6. Check Slack -did only Test 1 trigger alert?

If something's wrong:

  • Go to Zapier → Zap History (left sidebar) → See which step failed
  • Most common issue: API key typo or Claude response not parsing
  • Click "Replay" to retest failed runs

Hour 4: Deploy and Iterate

Step 11: Monitor Performance (15 minutes)

Your agent is live! Now track how well it works.

Over the next day, let it process real emails. Then review:

  1. In Zapier, go to Zap History
  2. Check "Task History" → Look at last 20 runs
  3. Note accuracy:
    • How many classifications were correct?
    • Any obvious misclassifications?

Example issues I've seen:

  • Issue: Newsletters marked as Work

  • Fix: Add to prompt: "Newsletters have 'unsubscribe' links -check for this"

  • Issue: Urgent emails missed

  • Fix: Add examples to prompt: "If subject contains 'ASAP', 'urgent', 'deadline', classify as Urgent"

Step 12: Improve the Prompt (25 minutes)

This is where you make the agent smarter.

Current prompt vs Improved prompt:

Before:

Urgent: Time-sensitive, requires action today

After:

Urgent: Time-sensitive, requires action today
Examples:
- "Meeting in 1 hour"
- "URGENT: Client needs response by EOD"
- "Deadline tomorrow"
- Subject contains: ASAP, urgent, deadline, today, EOD

Go back to Step 6, click "Edit" on the Claude step, and add 3-5 examples for each category based on your actual emails.

Test again with 5 more emails. Accuracy should improve from ~75% to ~90%+.

Step 13: Add More Actions (20 minutes)

Now that core agent works, extend it:

Option A: Auto-reply to Newsletters

  1. Add Filter step: Category = Newsletter
  2. Add Gmail "Send Email" step
  3. Template: "Thanks, I've received this. I review newsletters weekly."

Option B: Forward Urgent to Phone

  1. Add Filter step: Priority = High
  2. Add "Send SMS" step (via Twilio or your carrier's email-to-SMS)
  3. Message: "Urgent email from [sender] -check inbox"

Option C: Archive Low Priority

  1. Add Filter step: Priority = Low AND Category = Newsletter
  2. Add Gmail "Archive" step
  3. Keeps inbox clean automatically

Pick one and implement. Should take 10-15 minutes.

Common Pitfalls

Pitfall 1: API key errors

  • Symptom: Zap fails at Claude step
  • Fix: Double-check API key has no spaces, starts with sk-ant-

Pitfall 2: Gmail permission issues

  • Symptom: Can't read emails or apply labels
  • Fix: Disconnect and reconnect Gmail in Zapier settings, allow all permissions

Pitfall 3: Claude returns invalid JSON

  • Symptom: Parsing step fails
  • Fix: Add to prompt: "Return ONLY valid JSON with no explanation or additional text"

Pitfall 4: Too many Slack alerts

  • Symptom: Getting alerts for Medium priority emails
  • Fix: Check Filter step -ensure "Exactly matches" not "Contains"

Pitfall 5: Agent too slow

  • Symptom: Takes 5+ minutes to process
  • Fix: Normal on Starter plan (polls every 5 min). Upgrade to Professional for 1-minute polling.

What You've Learned

Congratulations -you've built a working AI agent. Here's what you now understand:

  1. Trigger → Decision → Action pattern: Foundation of all automation
  2. Prompt engineering: How to instruct AI to make reliable decisions
  3. API integration: Connecting services programmatically
  4. Workflow orchestration: Chaining steps with conditional logic
  5. Iteration: Testing, measuring, refining based on real use

These skills transfer directly to building more advanced agents.

Next Steps

This week:

  • Let agent run for 7 days
  • Review Zap History daily
  • Refine prompt based on misclassifications
  • Target 90%+ accuracy

Next month:

  • Build second agent (try: Customer support ticket triage or Sales lead qualification)
  • Explore LangChain or OpenAI Agents SDK for code-based agents
  • Read our guide: How to Implement Autonomous AI Agents

Within 3 months:

  • Automate 3-5 repetitive workflows
  • Build multi-agent systems (one agent hands off to another)
  • Consider migrating from Zapier to custom-coded agents for more control

Frequently Asked Questions

Can I use ChatGPT instead of Claude?

Yes, but you'll need OpenAI API key instead. In Step 6, use URL https://api.openai.com/v1/chat/completions and adjust the JSON format. Claude tends to be better at following structured output instructions, but both work.

What if I have 1,000+ emails/day?

This setup works up to ~500 emails/month on £25 budget. For higher volume:

  • Claude API costs scale linearly (~£0.02/email)
  • Zapier Starter allows 750 tasks/month -upgrade to Professional (£40/month) for 2,000 tasks

Is my email content sent to Anthropic?

Yes -Claude needs to read emails to classify them. Anthropic's API policy: they don't train on your data or store it beyond processing. If you handle sensitive data, consider running a local LLM instead (more advanced).

How do I handle emails in languages other than English?

Claude supports 100+ languages. Just add to prompt: "Email may be in [your language]. Respond in English." It'll classify correctly.

Can I classify into custom categories?

Absolutely. Change the categories in the prompt to whatever fits your workflow: "Client", "Internal", "Invoices", "Legal", etc. Test with 10 examples to make sure Claude understands your taxonomy.


You did it. In 4 hours, you've gone from zero to working AI agent. Most people talk about AI agents theoretically -you've built one that's handling real work.

The pattern you've learned (trigger, classify with AI, take action based on classification) powers 80% of business automation agents. Master this, and you can automate almost anything.

Ready for more? Check out our Multi-Agent Orchestration guide to build agents that collaborate.