Skip to content

VA-run23/Above_Influence

Repository files navigation

n8n Workflow Setup Guide

This folder contains the n8n workflows for ABOVE_INFLUENCE. Follow this guide to replicate the workflow in your own n8n instance.

📊 Workflow Architecture Diagram

WorkFlowDiagram1

Visual representation of the complete n8n workflow with intelligent model fallback system


📁 Available Workflows

1. ABOVE_INFLUENCE_WORKFLOW.json

  • Basic workflow with environment variables
  • Single Gemini model (2.5 Flash Lite)
  • Recommended for open-source setup

2. ABOVE_INFLUENCE_MODEL_SWITCH.json

  • Advanced workflow with automatic model fallback
  • Handles rate limits by switching between 3 Gemini models:
    • Primary: Gemini 2.5 Flash Lite
    • Fallback 1: Gemini 3 Flash
    • Fallback 2: Gemini 2.5 Flash
  • Recommended for production use

3. ABOVE_INFLUENCE_MODEL_SWITCH_PRODUCTION.json

  • Production version with hardcoded credentials
  • NOT included in GitHub (in .gitignore)
  • For personal use only

🚀 How to Replicate

Step 1: Set Up n8n

Option A: n8n Cloud (Easiest)

  1. Sign up at n8n.io
  2. Choose the free tier or paid plan
  3. Access your n8n instance

Option B: Self-Hosted

# Using Docker
docker run -it --rm \
  --name n8n \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  n8nio/n8n

# Using npm
npm install n8n -g
n8n start

Step 2: Get Required API Keys

Google Gemini API Key

  1. Visit Google AI Studio
  2. Create a new API key
  3. Copy the key (starts with AI...)

Gmail OAuth2 Credentials

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable Gmail API
  4. Go to "Credentials" → "Create Credentials" → "OAuth 2.0 Client ID"
  5. Choose "Web application"
  6. Add authorized redirect URIs:
    • For n8n Cloud: https://your-instance.app.n8n.cloud/rest/oauth2-credential/callback
    • For self-hosted: http://localhost:5678/rest/oauth2-credential/callback
  7. Copy Client ID and Client Secret

YouTube Data API

  1. In the same Google Cloud project
  2. Enable "YouTube Data API v3"
  3. Use the same OAuth credentials

Step 3: Configure n8n Credentials

Add Google Gemini Credentials

  1. In n8n, go to "Credentials" → "New"
  2. Search for "Google PaLM API" (used for Gemini)
  3. Enter your API key
  4. Save as "Google Gemini API"

Add Gmail OAuth2 Credentials

  1. Go to "Credentials" → "New"
  2. Search for "Gmail OAuth2"
  3. Enter Client ID and Client Secret
  4. Click "Connect my account"
  5. Authorize access
  6. Save as "Gmail OAuth2"

Step 4: Set Up Environment Variables in n8n

n8n supports environment variables in two ways:

Option A: Using n8n Environment Variables (Recommended)

  1. Go to your n8n settings
  2. Add environment variables:
    GOOGLE_GEMINI_API_KEY=your_api_key_here
    GMAIL_CLIENT_ID=your_gmail_client_id_here
    N8N_WEBHOOK_ID=auto_generated_on_import
    

Option B: Using .env File (Self-Hosted Only)

Create a .env file in your n8n directory:

# Google Gemini API Credentials
GOOGLE_GEMINI_API_KEY=your_api_key_here

# Gmail OAuth2 Credentials
GMAIL_CLIENT_ID=your_gmail_client_id_here

# N8N Webhook Configuration
N8N_WEBHOOK_ID=auto_generated_on_import

Step 5: Import the Workflow

  1. In n8n, click "Workflows" → "Import from File"
  2. Choose ABOVE_INFLUENCE_MODEL_SWITCH.json (recommended)
  3. The workflow will be imported with all nodes

Step 6: Configure Workflow Nodes

Update Webhook Node

  1. Open the "Webhook" node
  2. The webhook ID will be auto-generated
  3. Copy the webhook URL (e.g., https://your-instance.app.n8n.cloud/webhook/analyze-influence)
  4. Save this URL for your frontend .env file

Configure Gemini Model Nodes

  1. Open each "Gemini" model node (3 nodes if using model switch)
  2. Select your "Google Gemini API" credential
  3. Verify the model names:
    • models/gemini-2.5-flash-lite
    • models/gemini-3-flash
    • models/gemini-2.5-flash

Configure Gmail Node

  1. Open the "Send a message" node
  2. Select your "Gmail OAuth2" credential
  3. Verify the email settings

Step 7: Test the Workflow

  1. Click "Execute Workflow" in n8n
  2. Or use the webhook URL with a test payload:
curl -X POST https://your-instance.app.n8n.cloud/webhook/analyze-influence \
  -H "Content-Type: application/json" \
  -d '{
    "accessToken": "your_youtube_access_token",
    "userEmail": "your_email@example.com",
    "userGoals": "Test goals"
  }'

Step 8: Activate the Workflow

  1. Toggle the "Active" switch in the top-right corner
  2. The workflow is now live and ready to receive requests

Step 9: Update Frontend Environment Variables

Update your frontend .env file with the webhook URL:

VITE_N8N_WEBHOOK_URL=https://your-instance.app.n8n.cloud/webhook/analyze-influence

🔧 Workflow Architecture

Visual Flow Diagram

The diagram above shows the complete workflow with 13 interconnected nodes. Below is the execution flow:

1. Webhook (Entry Point)
   ↓
2. Fetch YouTube Subscriptions (HTTP Request)
   ↓
3. Fetch Liked Videos (HTTP Request)
   ↓
4. Basic LLM Chain - Primary (Gemini 2.5 Flash Lite)
   ↓
5. Check Error - Primary (Conditional)
   ├─ No Error → Skip to Step 11 (Markdown)
   └─ Error Detected → Continue to Step 6
       ↓
6. Basic LLM Chain - Fallback 1 (Gemini 3 Flash)
   ↓
7. Check Error - Fallback 1 (Conditional)
   ├─ No Error → Skip to Step 11 (Markdown)
   └─ Error Detected → Continue to Step 8
       ↓
8. Basic LLM Chain - Fallback 2 (Gemini 2.5 Flash)
   ↓
9. (Always proceeds to Markdown - final fallback)
   ↓
10. Markdown Conversion (Markdown to HTML)
   ↓
11. Send Email (Gmail)

Why 3-Tier Fallback System?

The intelligent model switching ensures 99%+ success rate by:

  • Primary Model (Gemini 2.5 Flash Lite): Fast and cost-effective for most requests
  • Fallback 1 (Gemini 3 Flash): Activates if primary hits rate limits
  • Fallback 2 (Gemini 2.5 Flash): Final safety net for maximum reliability

This architecture handles API rate limits gracefully without user intervention.

📊 Understanding the Workflow Nodes

Node-by-Node Breakdown

1. Webhook Node (Entry Point)

  • Type: n8n-nodes-base.webhook
  • Method: POST
  • Path: /analyze-influence
  • CORS: Enabled (allowedOrigins: "*")
  • Receives:
    {
      "accessToken": "user_youtube_oauth_token",
      "userEmail": "user@example.com",
      "userGoals": "User's stated life goals"
    }

2. Generic_Fetch_YT (Subscriptions)

  • Type: n8n-nodes-base.httpRequest
  • API: YouTube Data API v3 - Subscriptions
  • Endpoint: https://www.googleapis.com/youtube/v3/subscriptions
  • Parameters:
    • mine=true (user's subscriptions)
    • part=snippet (channel details)
    • maxResults=50 (latest 50 subscriptions)
  • Authentication: Bearer token from webhook
  • Output: Array of subscribed channels with titles

3. Fetch_Liked_Videos (Liked Videos)

  • Type: n8n-nodes-base.httpRequest
  • API: YouTube Data API v3 - Videos
  • Endpoint: https://www.googleapis.com/youtube/v3/videos
  • Parameters:
    • myRating=like (only liked videos)
    • part=snippet (video details)
    • maxResults=50 (latest 50 likes)
  • Authentication: Bearer token from webhook
  • Output: Array of liked videos with titles

4-8. LLM Chain Nodes (AI Analysis)

  • Type: @n8n/n8n-nodes-langchain.chainLlm
  • Models Used:
    • Primary: models/gemini-2.5-flash-lite
    • Fallback 1: models/gemini-3-flash
    • Fallback 2: models/gemini-2.5-flash
  • Configuration: continueOnFail: true (enables fallback)
  • Prompt Engineering:
    • Analyzes latest 30 subscriptions + 30 likes
    • Compares against user's stated goals
    • Evaluates influence tactics (fear, FOMO, clickbait)
    • Generates 5-step analysis report
  • Output: Detailed markdown-formatted analysis

5, 7. Error Check Nodes (Conditional Routing)

  • Type: n8n-nodes-base.if
  • Logic: Checks if $json.error exists
  • Routes:
    • No Error: Proceeds to Markdown conversion
    • Error Detected: Routes to next fallback model
  • Purpose: Handles rate limits and API failures

9. Markdown Node (Formatting)

  • Type: n8n-nodes-base.markdown
  • Mode: markdownToHtml
  • Function:
    • Converts AI analysis from Markdown to HTML
    • Prepends user's stated goals
    • Formats for email delivery
  • Output: HTML-formatted report

10. Send a Message (Email Delivery)

  • Type: n8n-nodes-base.gmail
  • API: Gmail API v2.2
  • Authentication: Gmail OAuth2
  • Configuration:
    • To: Dynamic from webhook (userEmail)
    • Subject: "YT Content Consumption Report"
    • Body: HTML from Markdown node
  • Output: Email sent confirmation

⚠️ Important Notes

Rate Limits & Performance

  • Google Gemini Free Tier:
    • 15 requests per minute
    • 1,500 requests per day
    • Model switching automatically handles rate limits
  • YouTube Data API:
    • 10,000 quota units per day
    • Each subscription fetch: ~1 unit
    • Each video fetch: ~1 unit
  • Gmail API:
    • 1 billion quota units per day (effectively unlimited for this use case)
  • Recommendation: For production, upgrade to paid tiers

Workflow Execution Time

  • Average: 15-30 seconds per analysis
  • Breakdown:
    • YouTube API calls: 2-5 seconds
    • AI analysis: 10-20 seconds
    • Email delivery: 1-3 seconds
  • Timeout: Set to 60 seconds (configurable)

Webhook Security

  • Current: Public webhook (no authentication)
  • Risk: Anyone with URL can trigger workflow
  • Production Recommendations:
    • Add API key authentication
    • Implement rate limiting
    • Use n8n's built-in authentication
    • Monitor execution logs for abuse

Data Privacy & Compliance

  • Zero Storage: No data persisted in n8n or databases
  • Real-Time Processing: Data processed and immediately discarded
  • Email Only: Reports sent directly to user's email
  • OAuth Scopes: Read-only access to YouTube data
  • GDPR Compliant: No personal data retention

Cost Breakdown (Free Tier)

Service Free Tier Limit Cost After Limit
n8n Cloud 5,000 executions/month $20/month (Starter)
Google Gemini 1,500 requests/day Pay-as-you-go
YouTube API 10,000 units/day $0 (rarely exceeded)
Gmail API Unlimited (reasonable use) $0
Vercel (Frontend) Unlimited $0

Estimated Monthly Cost for 1,000 Users: $20-50 (n8n + Gemini overages)

🐛 Troubleshooting

Common Issues & Solutions

"Invalid API Key" Error

Symptoms: Workflow fails at LLM Chain node with authentication error

Solutions:

  • Verify Gemini API key is correct in n8n credentials
  • Check if key is active at Google AI Studio
  • Ensure credential is properly linked to all 3 Gemini nodes
  • Try regenerating the API key

"Gmail Authentication Failed"

Symptoms: Email not sent, OAuth error in logs

Solutions:

  • Re-authenticate Gmail credentials in n8n
  • Ensure Gmail API is enabled in Google Cloud Console
  • Verify OAuth redirect URIs match your n8n instance URL
  • Check if OAuth consent screen is configured
  • Try revoking and re-granting access

"Webhook Not Found" (404 Error)

Symptoms: Frontend receives 404 when calling webhook

Solutions:

  • Ensure workflow is activated (toggle in top-right)
  • Verify webhook URL matches frontend .env file
  • Check n8n instance is running and accessible
  • Test webhook directly with curl command
  • Clear browser cache and retry

"Rate Limit Exceeded"

Symptoms: All 3 models fail with rate limit errors

Solutions:

  • Wait 1 minute for rate limit to reset
  • Check daily quota at Google AI Studio
  • Upgrade to Gemini paid tier for higher limits
  • Implement request queuing in frontend
  • Monitor usage patterns to avoid peak times

"No Email Received"

Symptoms: Workflow succeeds but user doesn't get email

Solutions:

  • Check spam/junk/promotions folder
  • Verify email address is correct in webhook payload
  • Review n8n execution logs for Gmail node errors
  • Test with a different email address
  • Check Gmail API quota hasn't been exceeded
  • Ensure Gmail OAuth token hasn't expired

"YouTube API Error: Insufficient Permissions"

Symptoms: Cannot fetch subscriptions or liked videos

Solutions:

  • Verify OAuth scope includes youtube.readonly
  • Re-authenticate in frontend with correct scopes
  • Check if YouTube Data API v3 is enabled
  • Ensure access token is valid and not expired

"Workflow Timeout"

Symptoms: Execution stops after 60 seconds

Solutions:

  • Increase timeout in workflow settings
  • Check if AI models are responding slowly
  • Verify network connectivity to Google APIs
  • Consider using faster Gemini models

"Markdown Conversion Failed"

Symptoms: Email sent but formatting is broken

Solutions:

  • Check if AI response is valid markdown
  • Review Markdown node configuration
  • Test with sample markdown input
  • Ensure special characters are properly escaped

Debugging Tips

  1. Check Execution Logs:

    • Go to "Executions" in n8n
    • Click on failed execution
    • Review each node's input/output
  2. Test Individual Nodes:

    • Use "Execute Node" to test one node at a time
    • Verify data flow between nodes
    • Check for missing or malformed data
  3. Monitor API Quotas:

  4. Enable Verbose Logging:

    • Set N8N_LOG_LEVEL=debug in environment variables
    • Review detailed logs for errors
    • Check network requests/responses

📚 Additional Resources

Official Documentation

Helpful Tutorials

Video Resources

API Playgrounds

Related Projects

🤝 Need Help?

Getting Support

If you encounter issues not covered in the troubleshooting section:

  1. Check Execution Logs: Review n8n execution history for detailed error messages
  2. Search Community Forum: Visit n8n Community for similar issues
  3. GitHub Issues: Open an issue at ABOVE_INFLUENCE Issues
  4. Documentation: Review the official docs linked above

Contributing

Found a bug or have an improvement? Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Project Context

This workflow was built as part of a one-week skill development workshop (Feb 23-28, 2026) to demonstrate:

  • Rapid application development with no-code tools
  • AI integration and prompt engineering
  • Intelligent error handling and fallback systems
  • Privacy-first architecture

Development Time: 8 hours (4 hours initial build + 4 hours refinement)

Learning Outcome: Transformed a months-old idea into a production-ready application using modern tools.


Built with ❤️ by the ABOVE_INFLUENCE team

"INFLUENCE FROM THE GOOD IDEAS, NOT FROM THE PERSON - BECAUSE PERSON MAY CHANGE BUT YOU CAN SHAPE THE IDEA TOO"


Happy automating! 🚀

About

Above_Influence is a privacy-first app that uses React, Vite, and Google Gemini AI to analyze your YouTube subscriptions and likes, revealing influencer impact without storing data.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors