Skip to content

AI Automation & Agents for Small Business · Automation foundations · lesson 4 of 16 · 18 min

Hands-on: building your first AI workflow end to end

What you will build

An inbound enquiry assistant that runs whenever a new enquiry email arrives:

  1. Reads the email.
  2. Classifies and extracts details with an AI step (structured JSON).
  3. Routes by category; spam is archived, unclear items go to review.
  4. Logs every enquiry to a Google Sheet (your lightweight CRM or audit log).
  5. Drafts a reply with AI, saved as a draft, not sent.
  6. Posts a review request in team chat with approve / reject, and only then sends.
  7. Alerts the owner if anything fails.

We will use n8n node names (cloud or self-hosted), with the equivalent Zapier and Make steps in a table, so you can follow along in the platform you chose. Budget about two hours for the first build.

Before you start

  • A business Google account with Gmail and Sheets (or Outlook and Excel; swap the nodes).
  • An AI model credential (for example an Anthropic, OpenAI or Google API key) added in the platform's credentials area, never pasted into prompts or workflow notes.
  • A test inbox or label with 10 realistic, anonymised enquiries, including one in Arabic or Urdu, one with no budget, one complaint and one spam.
  • A Google Sheet named Enquiries with columns: received_at, from, category, brand, budget_amount, budget_currency, deadline, language, confidence, route, status, draft_link.

Step-by-step build (n8n)

Step 1: Trigger. Add a Gmail Trigger node, event "Message Received", filtered to your enquiries label. Set polling to every minute while testing. Click "Fetch test event".

Step 2: Classify and extract. Add an Information Extractor node (in n8n's AI nodes), connect your chat model, and define the attributes using a JSON schema:

{
  "type": "object",
  "properties": {
    "category": {"type": "string", "enum": ["BRAND_DEAL", "PR_GIFTING", "FAN", "SPAM", "OTHER"]},
    "brand": {"type": ["string", "null"]},
    "budget_amount": {"type": ["number", "null"], "description": "Only if explicitly stated"},
    "budget_currency": {"type": ["string", "null"], "enum": ["AED", "SAR", "PKR", "GBP", "USD", null]},
    "deadline": {"type": ["string", "null"], "description": "YYYY-MM-DD if stated"},
    "language": {"type": "string", "enum": ["en", "ar", "ur", "other"]},
    "confidence": {"type": "string", "enum": ["high", "low"]}
  },
  "required": ["category", "brand", "budget_amount", "budget_currency", "deadline", "language", "confidence"]
}

Set the text input to the email subject and body, and add to the system prompt: "Never guess missing values; use null. If unsure, category OTHER and confidence low."

Step 3: Route. Add a Switch node with rules: category is BRAND_DEAL or PR_GIFTING and confidence is high → output 1 (deal); SPAM → output 2 (archive); everything else → output 3 (review).

Step 4: Log. On every branch, add a Google Sheets node, operation "Append Row", mapping the extracted fields plus route and status.

Step 5: Draft. On the deal branch, add a Basic LLM Chain node (or your platform's AI text step) with this prompt:

Draft a warm, concise reply (max 120 words) to this brand enquiry, in the same language as the email.
Thank them, confirm what they asked for, and ask for any missing details among: budget, deliverables,
deadline, markets. Do NOT quote prices, promise dates or agree terms. Sign off as "The Partnerships Team".
Email: {{ $('Gmail Trigger').item.json.text }}
Known details: {{ JSON.stringify($json) }}

Then a Gmail node, operation "Create a draft" as a reply to the thread.

Step 6: Human approval. Add a Slack (or Microsoft Teams, or Gmail) node using the "send message and wait for response" operation, with an approval question showing the original email, the draft and the extracted details. On approve, send the draft (Gmail "Send") and update the sheet status to "sent"; on reject, update status to "rejected" and notify the owner.

Step 7: Errors. Create a separate workflow starting with an Error Trigger node that posts to your alerts channel with the workflow name, failed node and execution link; set it as the error workflow in this workflow's settings. On the review branch, also post a chat message so unclear enquiries are never lost.

Equivalent steps in other platforms

| Step | Zapier | Make | |---|---|---| | Trigger | Gmail "New Email Matching Search" | Gmail "Watch emails" | | Classify/extract | AI by Zapier (structured output fields) | AI module / OpenAI or Anthropic module with JSON output | | Route | Paths | Router with filters | | Log | Google Sheets "Create Spreadsheet Row" | Google Sheets "Add a row" | | Draft | AI by Zapier + Gmail "Create Draft" | AI module + Gmail "Create a draft" | | Approval | A human-approval step or chat-based approval pattern | Chat module + webhook response pattern | | Errors | Zap error notifications / error handling paths | Error handlers on modules |

Test before switching on

Run all ten test emails and fill in: expected category, actual category, correct route (Y/N), draft acceptable (Y/N). Fix prompts or rules for any failure, re-run everything, then activate. Keep the test emails; you will re-run them after every change.

Go deeper

Go deeper: AI Automation with n8n, Make and Zapier has more platform-specific builds; Latest AI Techniques: RAG, Tool Use, Agents & MCP explains the structured outputs and tool use behind these steps.

Video lecture: Hands-on: building your first AI workflow end to end

Lecture coming soon · 15 chapters · about 9 minutes. Read the full transcript below.

  1. Build: inbound enquiry assistant
  2. Why this workflow first
  3. Set-up
  4. Thinnest version first (15 minutes)
  5. Steps 1–3
  6. Steps 4–5
  7. Steps 6–7
  8. Other platforms
  9. Business example (illustrative)
  10. Test before activating
  11. Common mistakes
  12. How you'll know it's working
  13. Watch me do it: the full n8n build
  14. Recap
  15. Try this now: three short sessions

Lecture transcript

Build: inbound enquiry assistant

Enough theory. In this lesson you'll build a complete AI workflow, the kind that saves a busy agency or creator business hours every week. An inbound enquiry assistant that reads new emails, extracts the details, routes them, logs everything, drafts a reply, asks a human to approve it, and alerts you if anything breaks. We'll use n8n node names, with the equivalent steps in Zapier and Make, so you can follow along in whichever platform you chose. Set aside about two hours.

Why this workflow first

Why build this particular workflow first? Because it combines every important idea in one small, low-risk project: a trigger, a structured AI step, routing, logging, a draft rather than an automatic send, a human approval and error alerts. Think of it as learning to cook with an omelette. It's quick, it teaches heat control, timing and seasoning, and if it goes wrong, you've lost two eggs, not a dinner party.

Set-up

Get set up first. You need a business email and spreadsheet account, an AI model credential stored in the platform's credentials area, never pasted into a prompt, and a test label with ten realistic, anonymised enquiries: include one in Arabic or Urdu, one without a budget, one complaint and one piece of spam. Create a spreadsheet called Enquiries with columns for received time, sender, category, brand, budget, currency, deadline, language, confidence, route, status and a link to the draft.

Thinnest version first (15 minutes)

Before the full build, here's the thinnest version you could build in fifteen minutes to prove the idea. Trigger on a new labelled email, send the subject and body to an AI step that returns just the category, and append the email's sender and category to a sheet. That's it. Run your ten test emails through it. If the categories are mostly right, you've proven the core, and every step after this is adding safety and usefulness.

Steps 1–3

Step one, the trigger: a Gmail trigger watching your enquiries label. Step two, classify and extract: an information extractor node connected to your chat model, with a JSON schema that lists the categories, brand, budget, currency, deadline, language and confidence. Budget, brand and deadline allow null, and the instructions say never guess; if unsure, use other with low confidence. Step three, route: a switch node sends confident brand deals and gifting to the deal branch, spam to the archive, and everything else to review.

Steps 4–5

Step four, log: on every branch, append a row to the Enquiries sheet with the extracted fields, the route and the status. That sheet becomes your audit trail and your first dashboard. Step five, draft: on the deal branch, an AI text step writes a warm, concise reply in the same language as the email, confirming the request and asking for any missing details, with strict instructions not to quote prices, promise dates or agree terms. Then a Gmail node creates a draft reply in the thread. It does not send.

Steps 6–7

Step six, human approval. A Slack, Teams or Gmail node uses the send-and-wait-for-response operation to post the original email, the draft and the extracted details, with approve and reject options. On approve, the workflow sends the draft and marks the row as sent. On reject, it marks the row as rejected and notifies the owner. Step seven, errors. Build a small separate workflow that starts with an error trigger and posts the workflow name, failed step and a link to the execution into your alerts channel, and set it as this workflow's error workflow. Also alert the team when items land in the review route.

Other platforms

If you're in Zapier or Make, the shape is identical. The trigger is a new matching email or a watch-emails module. Extraction is an AI step with structured output fields. Routing is paths in Zapier or a router with filters in Make. Logging is a new spreadsheet row. Drafting is an AI step plus create-draft. Approval uses a human approval step or a chat-based approval pattern. And errors use the platform's error notifications and handlers. The lesson includes a table mapping each step.

Business example (illustrative)

A deeper business example, illustrative. A Riyadh events agency built this assistant for its partnerships inbox, which gets about three hundred enquiries a month in Arabic and English. After a month, every enquiry was logged, about eight percent went to review, approved drafts needed only light edits, and the partnerships lead's inbox time fell from roughly an hour and a half a day to about twenty minutes. Two failures, both expired credentials, were caught by the error workflow within minutes.

Test before activating

Now test before you switch it on. Run all ten test emails and record the expected category, the actual category, whether the route was right, and whether the draft was acceptable. Fix the prompt or rules for any failure, then re-run everything, not just the one you fixed. Activate only when all ten pass. Keep the test emails, because you'll re-run them after every change, including when your AI provider updates its models. That's your regression test.

Common mistakes

Common mistakes on a first build. Pasting an API key into a prompt or workflow note. Testing with one easy email. Letting the draft send automatically because approval felt slow. No error workflow, so the first failure goes unnoticed. Mapping the wrong field, so the sheet fills with blank rows. And activating the workflow before saving your test emails for next time.

How you'll know it's working

How will you know it's working after launch? Every enquiry appears in the sheet, with sensible categories. The review route catches a small number of unclear emails. Approved drafts need only light edits. Error alerts are rare, and when they come, they arrive in your channel with a link. And the person who handled enquiries by hand says they now spend minutes, not hours.

Watch me do it: the full n8n build

Watch me do it. I start with the Gmail trigger watching the enquiries label and fetch a test event. Next, the Information Extractor: I connect the chat model, paste the JSON schema with categories, nullable fields and confidence, and add the system instruction never guess. I run it on the test event and see brand deal, budget null, language Arabic. Then the Switch node with three rules. On each branch, Google Sheets append row, mapping each field. On the deal branch, the Basic LLM Chain with the drafting prompt, referencing the original email text and the extracted details, then Gmail create a draft in the same thread. Next, the Slack node's send and wait for response operation, showing the email, the draft and the details. I click approve, and the draft sends and the sheet row changes to sent. Finally, the separate error workflow: Error Trigger to Slack. I break the sheet ID on purpose and watch the alert arrive.

Recap

To recap: a complete AI workflow combines a trigger, structured extraction, routing, logging, drafting, human approval and error alerts. Allow null and low confidence, save drafts instead of sending, approve in chat, and build an error workflow. Test with ten realistic cases and keep them. Your next step is to build this assistant in your chosen platform and activate it only when every test passes. Next module: assistants and agents.

Try this now: three short sessions

Try this now. Build the thinnest version today: trigger, AI category, sheet row. Run your ten test emails. Tomorrow, add routing, the draft and the approval step. The day after, add the error workflow and run all ten tests again before activating. Three short sessions, and you'll have a real AI workflow saving time by the end of the week.

Key takeaways

  • A complete AI workflow combines a trigger, structured extraction, routing, logging, drafting, human approval and error alerts.
  • Use the platform’s structured-output or extractor features with a JSON schema that allows null and a low-confidence route.
  • Save AI replies as drafts and send only after a human approves in chat.
  • Build a separate error workflow and test with ten realistic cases before activating; keep them for regression tests.

Try it

Build the enquiry assistant in your chosen platform with ten test emails, record results in a test table, and only activate once every test passes.