Full Technical + Beginner Guide

My Complete n8n Setup Journey

From zero to a fully working AI-powered automation system — every concept explained, every error documented, every fix recorded.

n8n OAuth 2.0 Google APIs Groq / LLaMA AI Agents Automation
Contents

This document covers the full journey of setting up n8n for real-world automation work. Every concept is broken down into beginner-friendly language, every error is documented with its root cause, and every fix is explained step by step.

By the end, a complete AI-powered workflow was built and running — connecting Gmail, Google Calendar, Google Sheets, OpenWeatherMap, and a local AI agent through a single automated pipeline.

n8n
An automation platform — like a digital employee that connects apps together and performs tasks automatically. Read Gmail, check weather, send emails, update spreadsheets — all without manual work.
🔌
API
Application Programming Interface — a bridge that lets one app talk to another. When your workflow asks "What is Karachi weather?", the weather API replies with real data.
🔐
OAuth
A secure login permission system. Instead of sharing your password, you click "Sign in with Google" — Google safely grants access. Safer, revocable, and limited in scope.
🪪
Credential
The login connection details used by n8n to connect services — API keys, OAuth tokens, Client IDs, and Client Secrets.
🆔
Client ID & Secret
Client ID is the app's identity number (like a National ID card for software). Client Secret is its private password — both required during OAuth flows.
↩️
Redirect URI
After Google login succeeds, the user is sent back to this address:
localhost:5678/rest/oauth2-credential/callback
🗂️
Workflow
A sequence of connected steps — Trigger → Get weather → Ask AI → Send email. That full chain is one workflow.
🧱
Node
The building block of n8n. Each app or tool is one node — Gmail node, Calendar node, AI Agent node. Connect them together to build workflows.
🤖
AI Agent
An AI system that can think AND act — not just chat. It can decide what to do, call APIs, read data, and trigger actions based on reasoning.

🏃 Karachi Running Assistant

An AI agent that runs every morning, checks conditions, and sends a personalized running recommendation via email.

Step 1 — Trigger
Schedule Trigger fires at chosen time every day
Step 2 — AI Agent
Groq-powered LLaMA 3.1 agent activates and starts reasoning
Step 3 — Calendar
Checks Google Calendar for schedule conflicts (checkCalendar)
Step 4 — Weather
Fetches live Karachi weather via OpenWeatherMap (getWeather)
Step 5 — Routes
Reads running routes from Google Sheets database (getHikeList)
Step 6 — Decision
AI decides if conditions are good for running today
Step 7 — Email
Sends personalized Gmail recommendation (sendMessage)
Schedule Trigger
Starts automation at the chosen time — like an alarm clock for workflows.
🧠
Groq Chat Model
AI provider using llama-3.1-8b-instant — fast reasoning model.
💾
Simple Memory
Stores previous conversation context — short-term memory for the agent.
📅
Google Calendar API
Checks schedule for conflicts. Tool name: checkCalendar
🌤️
OpenWeatherMap API
Fetches live Karachi weather. Tool name: getWeather
📊
Google Sheets API
Used as a beginner-friendly database for routes. Tool name: getHikeList
📧
Gmail API
Sends the final email recommendation. Tool name: sendMessage

Start n8n

# Either of these works: n8n npx n8n

Google Cloud Setup

# Project created: n8n Automation # APIs enabled: Google Calendar API Google Sheets API Google Drive API Gmail API # OAuth credentials created via Google Cloud Console # Redirect URI set to: http://localhost:5678/rest/oauth2-credential/callback

Every error encountered during setup — with root cause and fix.

ERR 01
OpenAI Quota Exceeded
Cause: No credits or rate limits hit on OpenAI account.
✓ Fix — Switched to Groq as AI provider
ERR 02
Groq Old Model Deprecated
Cause: Previously specified model no longer available.
✓ Fix — Used llama-3.1-8b-instant
ERR 03
Google App Not Verified
Cause: App is in testing mode and Gmail account wasn't added as a test user.
✓ Fix — Added Gmail as Test User in OAuth consent screen
ERR 04
Invalid JavaScript Origin
Cause: Used callback path as the Authorized JavaScript Origin (wrong field).
Origin: http://localhost:5678 Redirect: http://localhost:5678/rest/oauth2-credential/callback
✓ Fix — Set Origin and Redirect URI to correct separate values
ERR 05
Client Authentication Failed
Cause: Wrong or expired Client Secret entered.
✓ Fix — Generated a new Client Secret from Google Cloud Console
ERR 06
Google Drive API Disabled
Cause: Sheets' file picker internally uses the Drive API — which was not enabled.
✓ Fix — Enabled Google Drive API in Google Cloud Console
ERR 07
Gmail API Disabled
Cause: Gmail API was not activated in the Google Cloud project.
✓ Fix — Enabled Gmail API in Google Cloud Console
ERR 08
sessionId Undefined
Cause: Schedule Trigger has no chat session — memory node couldn't get a sessionId.
✓ Fix — Used a static memory key instead of dynamic session
ERR 09
Tool Name Mismatch
Cause: AI prompt expected tool name checkCalendar but the node had a typo.
✓ Fix — Renamed node to exactly match prompt tool name
ERR 10
Too Many Requests
Cause: API rate limits hit from repeated testing in quick succession.
✓ Fix — Waited and reran the workflow
Final Success

Email was successfully sent automatically. The full AI workflow — from trigger to calendar check to weather to email — worked end to end.

Technically

🔧
APIs need enabling individually Google APIs are separate switches — even related services like Sheets and Drive need to be turned on independently.
🔗
OAuth needs exact URLs One wrong character in a redirect URI breaks the entire login flow. No tolerance for typos.
🏷️
Naming matters AI tool names in the prompt must match node names exactly — case-sensitive, character-perfect.
🐛
Real projects require debugging Errors aren't failures — they're part of the process. Every setup involves struggle and iteration.

Professionally

🔁
Connecting Services
How different APIs and platforms talk to each other through credentials and HTTP calls.
🤖
AI Automation Systems
Building workflows where AI agents reason and act — not just respond to chat.
🔐
OAuth Flows
How secure permission-based login systems work under the hood.
🛠️
Debugging Real Software
Reading error messages, finding root causes, and fixing issues in production-like environments.

Skills built during this journey directly apply to real client work.

AI Receptionist
Booking Bots
CRM Automation
Email Follow-up
Lead Capture
Reminder Systems
WhatsApp Assistant
HR Automation
Reporting Dashboards
Before
Curious Beginner
After
Built a Real Multi-Tool AI Automation System

"This was not just software setup. It was practical engineering experience. I learned how real systems communicate, fail, and get fixed."

📄
Workflow JSON
Export and backup your n8n workflow so you can restore or share it.
📝
Prompt Text
The AI agent system prompt defining tool names and behavior.
🔑
API Keys
Groq API key, OpenWeatherMap key — stored securely.
🏗️
Google Credentials
Client ID, Client Secret from Google Cloud Console project.