Let AI Work for You: A Beginner's Guide to Automation with n8n

This post is a beginner's guide to deploying n8n for the first time.

Why Let AI Work for You?

In recent years, “AI agent” has become a hot topic. Many companies have invested in development, such as MTK’s Dago project and ChatGPT’s former Operator feature. Although we are still some distance from true general-purpose AI agents, we can start with more practical tasks—like letting AI regularly send out tech news summaries as your personal assistant.

This article will guide you through the first step: using n8n to create your own AI automation workflow. From fetching news via RSS, summarizing with OpenAI, to sending emails through Gmail—all automatically.


Introduction to the Automation Tool: What is n8n?

Although there are already many comparison articles online, I won’t repeat the features and theories here. However, I’ll briefly show you a simple comparison chart to quickly highlight the differences.

n8n homepage


Key Implementation: Quickly Deploying n8n with Docker

Let’s get started right away!

We’ll deploy n8n using Docker, which is ideal for quickly getting the environment up and running and grasping the big picture.

n8n homepage

Step 1: Make Sure Docker is Installed

If you haven’t installed Docker yet, download and install it from the Docker website.

Step 2: Create a Folder for n8n Configuration

1
2
mkdir -p ~/n8n
cd ~/n8n

Step 3: Create docker-compose.yml

Create a new file in the same directory with the following content (you can use your own Gmail OAuth or basic auth):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
version: "3"
services:
  n8n:
    image: n8nio/n8n
    restart: always
    ports:
      - "6666:6666"
    environment:
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=admin
      - N8N_BASIC_AUTH_PASSWORD=admin123
      - N8N_HOST=localhost
      - N8N_PORT=6666
      - N8N_PROTOCOL=http
    volumes:
      - ./n8n_data:/home/node/.n8n

Step 4: Start the Service

In the terminal, run:

1
docker compose up -d

Once started, go to http://localhost:6666 to access the n8n interface.

If you see the following screen, congratulations—you’ve taken the first step!

n8n homepage


Apply the AI Tech Newsletter Template

Next, we’ll apply a pre-made AI tech news summary template to save time from designing from scratch.

Import the Official Workflow Templates

After registering your n8n account, click “Templates” at the bottom left of the site.

There are over 2300+ templates available for immediate use.

n8n homepage n8n homepage

Find the template “Personalized AI Tech Newsletter.”

Click “Use for free,” then “Copy template to clipboard.”

n8n homepage n8n homepage

Go back to your environment, create a new file and paste the template:

1
2
3
4
Create a file with .json extension
Paste the copied content
In n8n, click + → Import from File
Paste the JSON and click Import

After successfully importing the template, you’ll see a complete workflow. However, many nodes will show a red triangle, indicating missing credentials or configuration.

n8n homepage

Don’t worry—you only need to configure two key parts:

Configure OpenAI and Gmail

OpenAI API Key Configuration

The workflow sends RSS tech articles to ChatGPT for summarization, so you need a valid OpenAI API key.

Click the triangle next to the OpenAI node and select credentials.

n8n homepage

To obtain an API key:

1
2
3
4
Go to https://auth.openai.com/log-in and log in or register
Then visit https://platform.openai.com/account/api-keys
Click "Create new secret key"
Copy the key and paste it into the OpenAI node in n8n

n8n homepage

P.S. API key usage requires payment—it’s billed separately from the ChatGPT subscription.

Gmail API Integration

After the AI summary is complete, Gmail will send the newsletter to your inbox. You need to set up Gmail API through Google.

If it’s your first time using Google API, it can be a bit complex. I recommend the following tutorials:

1
2
3
4
5
* 🧾 Official n8n tutorial (English):
  How to connect Gmail with n8n

* 🧑‍💻 Recommended tutorial (Traditional Chinese):
  RaymondHouch: Full Guide on Connecting Google Credentials with n8n

Follow the same triangle click method for setup.

n8n homepage


Common Issues with Google OAuth Verification

If you’ve followed all the steps and reached the Gmail API authentication, but got stuck—don’t worry, you’re not alone.

It took me about 8–9 hours to get everything working. The main issue lies in Google OAuth 2.0 verification.

Why the Problem?

Google OAuth requires a Redirect URI, a publicly accessible URL where Google will redirect you after authentication.

However, most people deploy n8n locally (localhost) or in an internal Docker network, which is not publicly accessible.

So Google can’t “see” your n8n. Here are some solutions:


Solutions:

MethodProsCons
Use Cloud VPSStable, production-readyMaintenance required, not free
n8n.cloud official hostingVery simple, plug-and-playFree version limits to 200 executions
Cloudflare Tunnel (best)Free, flexible, exposes localhostRequires cloudflared installation

I chose the Cloudflare Tunnel solution.

Cloudflare Tunnel Setup

1. Install cloudflared

1
2
3
4
5
# macOS
brew install cloudflared

# Ubuntu / Debian
sudo apt install cloudflared

2. Login and Create Tunnel

1
2
cloudflared tunnel login
cloudflared tunnel create n8n-tunnel

3. Create Config File ~/.cloudflared/n8n.yaml

1
2
3
4
5
6
7
tunnel: <your tunnel id>
credentials-file: /root/.cloudflared/<your tunnel id>.json

ingress:
  - hostname: n8n.swarkdoit.com
    service: http://localhost:6996
  - service: http_status:404

4. Adjust docker-compose.yml Port

1
2
3
4
5
ports:
  - "6996:6996"
environment:
  - N8N_PORT=6996
  - WEBHOOK_URL=https://swarkdoit.com

Use the port you set for n8n inside Docker. The WEBHOOK_URL must be your Cloudflare domain for OAuth redirection.

5. Start Service and Tunnel

1
2
docker compose up -d
cloudflared tunnel run n8n-tunnel

Final Check: Running the Automation

Open the n8n editor, click “Execute Workflow,” and verify each node:

If successful, you’ll see green checkmarks: n8n homepage

If failed, you’ll see red triangles: n8n homepage

Start debugging if needed 😢

Once all nodes are checked off, congratulations! You should receive your personalized AI-generated tech newsletter via Gmail within seconds.

n8n homepage

Lastly, don’t forget to activate the workflow to make it fully automatic:

n8n homepage

comments powered by Disqus
Built with Hugo Stack | © Swark
Built with Hugo
Theme Stack designed by Jimmy