Zarif Automates

How to Build Your First AI Automation in Under 30 Minutes

ZarifZarif
||Updated May 2, 2026

Most "build your first AI automation" tutorials are 8,000-word epics that take three weekends to follow and end with a workflow you will never use again. This one is different. In the next 30 minutes you will ship a real automation that turns inbound emails into structured CRM entries, completely free, with the same architecture you would use for production work.

Definition

An AI automation is a workflow where one or more AI model calls sit inside a sequence of trigger, processing, and action steps that runs without human intervention.

TL;DR

  • The simplest valuable AI automation has three parts: a trigger (something happens), an AI step (model interprets unstructured input), and an action (write the result somewhere useful).
  • This tutorial uses n8n cloud's free tier, Gmail, and the OpenAI API — total cost to ship and run for a month is under 5 dollars.
  • The workflow takes inbound emails, asks an LLM to extract sender intent, contact info, and urgency as JSON, then creates a row in a Google Sheet you can use as a starter CRM.
  • The same three-step pattern (trigger, AI, action) generalizes to dozens of real workflows: support ticket routing, lead qualification, document classification, social mention triage.
  • You will hit one of three classic failure modes by step 4 — wrong JSON, missing field, model hallucinated. The tutorial includes the exact fixes.

What you will build

The end result is a workflow that watches a Gmail inbox, and every time a new email arrives, sends the subject and body to GPT-4o-mini, which returns a JSON object with the sender's name, company, intent (sales, support, recruiting, spam), urgency (low, medium, high), and a one-sentence summary. The result is appended as a row in a Google Sheet. You have just built a starter inbound-lead CRM that beats most paid solutions for personal use.

The same pattern with different inputs and outputs powers countless production automations. The point of this tutorial is the pattern, not this specific use case.

What you need before you start

Three accounts. None require a credit card to start.

  • An n8n cloud account at n8n.io (free trial, then 20 dollars per month for the Starter plan — or self-host for free if you prefer)
  • A Google account with Gmail and Sheets access
  • An OpenAI account with API access and a few dollars of credit on file (this workflow costs roughly 0.001 dollars per email processed)

If you want a fully free path, swap n8n cloud for n8n self-hosted on your laptop or a 5-dollar-a-month VPS, and swap OpenAI for the free Groq API or Google AI Studio's Gemini free tier. The architecture is identical.

Step 1: Set up the trigger

Sign in to n8n cloud and create a new workflow. Add a Gmail Trigger node and connect your Google account through the OAuth flow. Set the trigger to "On Message Received" with a polling interval of one minute. Filter to a specific label like inbox or a custom automate-me label so you can test cleanly without flooding your sheet with every existing email.

Click "Listen for Test Event" and send yourself a test email from another account. The node should light up green with the email's subject, body, and sender visible in the right panel. If it does not, the most common issues are insufficient Gmail OAuth scopes (re-authenticate and select the correct scopes) and the wrong label filter (verify the label name exactly matches).

Step 2: Send the email content to an LLM

Add an OpenAI node after the Gmail trigger. Choose the "Message a Model" operation, model gpt-4o-mini, and set the temperature to 0. The system message goes:

You are a strict JSON extraction service. Given an email, return ONLY valid JSON matching this schema:
{
  "sender_name": "string",
  "company": "string or null",
  "intent": "sales | support | recruiting | spam | other",
  "urgency": "low | medium | high",
  "summary": "one sentence summary"
}
Do not include any text outside the JSON.

The user message is the email content, built from the trigger output:

Subject: {{ $json.subject }}
From: {{ $json.from.value[0].address }}
Body: {{ $json.text }}

Execute the node. The output should be a JSON-parseable string in the message field. If you get prose instead of JSON, the model ignored the system instruction — set temperature to 0 and add the phrase "ONLY JSON, no prose" to the system message.

Step 3: Parse the JSON response

Add a Code node after the OpenAI node. The default JavaScript snippet should be:

const raw = $input.first().json.message.content;
let parsed;
try {
  parsed = JSON.parse(raw);
} catch (e) {
  parsed = { sender_name: 'unknown', company: null, intent: 'other', urgency: 'low', summary: 'JSON parse failed' };
}
return [{ json: parsed }];

This is the single most important node in any AI automation. Models occasionally return malformed JSON, and without a try/catch your workflow crashes. The fallback values mean a bad model response writes a row you can manually review later instead of breaking the entire pipeline.

Warning

Always wrap LLM JSON parsing in a try/catch with sensible fallbacks. The single most common production AI workflow failure is a model returning prose when you expected JSON, and the second most common is a missing field. Defensive parsing is not optional.

Step 4: Write the row to Google Sheets

Add a Google Sheets node. Connect your Google account, create a new sheet called email-triage with columns: received_at, sender_name, company, intent, urgency, summary, original_subject. Set the Google Sheets node operation to "Append Row" and map each column to the upstream nodes — received_at from the Gmail trigger's date, sender_name through summary from the Code node's output, original_subject from the Gmail trigger.

Execute the workflow end to end with a test email. You should see a new row appear in your sheet within seconds.

Step 5: Activate and test

Click the Active toggle at the top right of the workflow. Send three test emails of different types — a sales inquiry, a support question, and an obvious recruiter pitch. Check your sheet after one minute. All three should appear with the correct intent classifications.

Congratulations. You have shipped your first production AI automation. The total node count is four. The total cost per run is under one tenth of a cent. The pattern you just used is the same pattern that powers every "AI agent" product you have read about.

What to do when it breaks

It will break. Here are the three failures you will hit in the first week and the fixes.

The model returns prose instead of JSON. Set temperature to 0, restate the JSON-only requirement in the user message, and add an "Output: " prefix the model can complete. If it still happens, swap to a model with native structured output mode (gpt-4o with the response_format: json_object parameter).

The model hallucinates a sender name or company that was not in the email. This is usually because the prompt asked for a field that is genuinely missing. Make the field nullable in the schema and explicitly instruct the model to return null when the value is not present.

The Google Sheets node throws a quota error. Google Sheets has a 60-write-per-minute limit per user. For low-volume personal use you will not hit it. For higher volume, switch the destination to Airtable or a Postgres table.

The pattern, generalized

The trigger-AI-action pattern is the building block for almost every useful AI automation. Examples that drop into the same template:

  • Trigger: new Slack message in a channel. AI: classify whether this needs the on-call engineer. Action: page on-call if yes.
  • Trigger: new Stripe charge. AI: write a personalized thank-you email referencing the customer's plan and history. Action: send via SendGrid.
  • Trigger: new podcast episode in an RSS feed. AI: summarize the episode and extract three key claims. Action: post to a Notion database.
  • Trigger: new GitHub issue. AI: classify priority and tag the right component. Action: update the issue with the labels.

Each of these is the same four nodes with different connectors. Once you have built one, the next ten take 15 minutes each.

What to do next

Three concrete next steps to extend what you have built.

First, add a Filter node before the OpenAI call to skip newsletters and automated emails — this saves money and noise. Second, add a Slack node alongside the Sheets node that pings you immediately for any email tagged as high urgency. Third, swap the Google Sheet for an Airtable base where you can add follow-up tracking columns and turn the triage feed into an actual mini-CRM.

The thing to internalize is that the hard part of AI automation is not the AI. It is the workflow design — picking a trigger that fires at the right time, structuring the prompt so the output is reliable, and writing to a destination that is actually useful. The AI is one node in a four-node pipeline.

FAQs

Do I need to know how to code to build AI automations?

No. n8n, Make, and Zapier are no-code platforms that let you wire up triggers, AI calls, and actions visually. You will encounter small JavaScript snippets in nodes like the JSON parser in this tutorial — those are short, copy-pasteable, and well-documented. Most useful automations require zero original code.

What is the cheapest way to run AI automations?

Self-host n8n on a 5-dollar-a-month VPS or your laptop, use the Groq API or Gemini's free tier for LLM calls, and write outputs to free Google Sheets or Airtable bases. You can run thousands of automation executions per month for under 10 dollars total. Cost scales with LLM token usage, so picking a small model like gpt-4o-mini, Gemini Flash, or Llama on Groq matters a lot.

Should I use n8n, Make, or Zapier for my first automation?

For pure ease of use and the largest app catalog, Zapier. For the best price-to-power ratio with multi-step logic, Make. For the most flexibility and a self-hostable option, n8n. The patterns are identical across all three. Most readers of this site end up on n8n because the AI ecosystem has standardized around it for production work.

How do I keep my OpenAI costs from getting out of control?

Set a hard monthly spend limit in your OpenAI billing dashboard — that is your real safety net. Use the smallest model that solves the problem (gpt-4o-mini handles most extraction tasks for a fraction of gpt-4o's cost). Add filters before the LLM call so you do not pay to process newsletters and noise. And log token usage so you can spot a runaway prompt early.

Are AI automations reliable enough for production?

Yes, if you build them with defensive parsing, validation rules, and good observability. The unreliable AI automations you read about usually skipped the parsing safeguards or had no monitoring. A well-built automation with a try/catch on the LLM output, a validation step, and error notifications runs at high reliability for years.

Zarif

Zarif

Zarif is an AI automation educator helping thousands of professionals and businesses leverage AI tools and workflows to save time, cut costs, and scale operations.