🚀 AI Facebook Post Generator - Complete Setup Guide
Transform your content ideas into viral Facebook posts with AI-powered automation in just 30 minutes!
📋 Prerequisites Checklist
What you'll need before we start:
- ✅ n8n instance (cloud or self-hosted)
- ✅ Facebook Business Page (not personal profile)
- ✅ Google account with Sheets & Gmail access
- ✅ Basic understanding of API credentials
⏱️ Estimated Setup Time: 30-45 minutes
🎯 Difficulty Level: Intermediate
💰 Cost: Free tier available for all services
🎨 What You'll Build
By the end of this guide, you'll have:
- 📝 Smart Content Form - Web form that captures your ideas
- 🤖 AI Content Optimizer - Gemini AI that polishes your writing
- 🖼️ Auto Image Generator - Custom visuals created automatically
- 📊 Content Tracker - Google Sheets logging for analytics
- 📱 Facebook Publisher - Direct posting to your page
- 📧 Success Notifications - Email confirmations with post links
🔧 Step-by-Step Setup
Step 1: 📘 Facebook Integration Setup
🔸 1.1 Create Your Facebook App
Why this matters: This gives your workflow permission to post on your behalf.
- Navigate to Facebook Developers 🌐
- Click "My Apps" → "Create App"
- Select "Business" as your app type
- App Name:
AI-Content-Poster
(or your preferred name)
- Hit "Create App"
💡 Pro Tip: Choose a descriptive name - you'll see this in your Facebook activity logs
🔸 1.2 Configure App Settings
- In your app dashboard: "Add a Product"
- Find "Facebook Login" → "Set Up"
- Navigate to Settings → Basic
- App Domains: Add
app.n8n.cloud
(for n8n cloud users)
- Save changes ✅
🔸 1.3 Generate Your Page Access Token
This is the key that unlocks posting powers! 🔑
- Go to Tools → Graph API Explorer
- Select your newly created app
- Click "Generate Access Token"
- Required Permissions:
pages_manage_posts
pages_read_engagement
pages_show_list
- Select your target Facebook page
- Copy the token (starts with
EAAG...
)
⚠️ Critical Step - Make Token Long-Lived:
- In Graph API Explorer, make a GET request to:
/oauth/access_token?grant_type=fb_exchange_token&client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&fb_exchange_token=YOUR_SHORT_TOKEN
🔸 1.4 Find Your Page ID
Two methods to get your Page ID:
Method 1 - Direct from Facebook:
- Visit your Facebook page
- Click "About" tab
- Scroll to find "Page ID"
Method 2 - API Explorer:
- Use Graph API Explorer
- GET request to:
/me/accounts
- Find your page in the response
Step 2: 🔍 Google Services Setup
🔸 2.1 Enable Required APIs
Setting up your Google Cloud foundation:
- Visit Google Cloud Console ☁️
- Create new project or select existing
- "APIs & Services" → "Library"
- Enable these APIs:
- ✅ Google Sheets API
- ✅ Gmail API
- ✅ Google Drive API (optional)
🔸 2.2 Create Service Account
This creates a "robot" account for automated access:
- "APIs & Services" → "Credentials"
- "Create Credentials" → "Service Account"
- Name:
ai-facebook-automation
- "Create and Continue"
- Skip role assignment → "Continue"
- "Done" ✅
🔸 2.3 Download Credentials File
- Click your service account email
- "Keys" tab → "Add Key" → "Create New Key"
- Choose "JSON" format
- Download and save securely 📁
🔒 Security Note: This file contains sensitive credentials. Store it safely!
🔸 2.4 Prepare Your Google Sheets
Create your data tracking system:
📊 Sheet 1: Content Log
- Purpose: Track all generated content
- Columns:
- A: Date (Ngày)
- B: Short Content (Nội dung ngắn)
- C: Full Content (Nội dung đầy đủ)
📝 Sheet 2: Input Tracking
- Purpose: Log form submissions
- Columns:
- A: Date
- B: Time
- C: Content
🔗 Important: Share both sheets with your service account email (found in the JSON file)
Step 3: 🤖 AI Services Configuration
🔸 3.1 Get Your Gemini API Key
Power up your AI content generation:
- Head to Google AI Studio 🎨
- Sign in with Google account
- "Create API Key"
- Copy the key (starts with
AIza...
)
💰 Cost Info: Gemini offers generous free tier limits - perfect for getting started!
Step 4: ⚙️ n8n Workflow Configuration
🔸 4.1 Import the Magic ✨
- Copy the workflow JSON from the template
- In n8n: "Import from JSON"
- Paste the workflow code
- "Import" to load your new automation
🔸 4.2 Configure Your Credentials
🔑 Facebook Graph API Setup:
- Settings → Credentials → "Add Credential"
- Search: "Facebook Graph API"
- Access Token: Your Page Access Token from Step 1.3
- Test connection → Save as:
Facebook Page Access
🔍 Google Services Setup:
- "Add Credential" → "Google Service Account"
- Upload your JSON file from Step 2.3
- Test connection → Save as:
Google Services
🧠 Gemini AI Setup:
- "Add Credential" → "Google PaLM API"
- Enter your Gemini key from Step 3.1
- Save as:
Gemini AI
🔸 4.3 Customize Node Settings
📱 Update Facebook Configuration:
In "Facebook Graph API" node:
- Replace
"113732581629527"
with your Page ID from Step 1.4
In "Facebook Upload Img" node:
- Replace
"113732581629527"
with your Page ID from Step 1.4
📊 Update Google Sheets:
In "save content" node:
- Replace Document ID with your Content Log Sheet ID
In "Append row in sheet" node:
- Replace Document ID with your Input Tracking Sheet ID
💡 Finding Sheet ID: It's the long string in your Google Sheets URL after /spreadsheets/d/
📧 Update Notification Email:
In "Send a message" node:
Step 5: 🧪 Testing & Validation
🔸 5.1 Component Testing
📊 Test Google Sheets Connection:
- Right-click "Append row in sheet" node
- "Execute Node"
- ✅ Verify test row appears in your sheet
🤖 Test Gemini AI:
- Right-click "Basic LLM Chain" node
- "Edit Input Data" → Add test content
- Execute → ✅ Verify AI response quality
🖼️ Test Image Generation:
- Right-click "HTTP Request" node
- Ensure valid prompt from previous step
- Execute → ✅ Check for base64 image data
📱 Test Facebook Upload:
- Run full workflow with test content
- ✅ Check your Facebook page for new post
- ✅ Verify image uploaded correctly
🔸 5.2 End-to-End Victory Test 🎉
- "Execute Workflow" on trigger node
- Submit test content through the form
- Monitor each node execution
- 🎊 Celebrate your first AI-generated post!
🎯 Success Indicators
Your setup is complete when you see:
- ✅ Form accepts and processes content
- ✅ AI generates optimized text + image prompt
- ✅ Custom image appears in Facebook post
- ✅ Content logged in Google Sheets
- ✅ Success email in your inbox
- ✅ Professional-looking post on your Facebook page
🚨 Troubleshooting Quick Fixes
Facebook Issues
- Token Expired? → Generate new long-lived token
- Permission Denied? → Check page admin rights
- Invalid Page ID? → Double-check Page ID format
Google Sheets Problems
- 403 Forbidden? → Share sheet with service account
- Sheet Not Found? → Verify Sheet ID in URL
- Column Errors? → Match exact column names
AI Content Issues
- Empty Responses? → Check Gemini API quotas
- Poor Quality? → Adjust AI prompts
- JSON Errors? → Validate parsing logic
🎨 Customization Ideas
Make it uniquely yours:
- 🎨 Brand Voice: Adjust AI prompts for your tone
- ⏰ Scheduling: Add time delays for strategic posting
- 📈 Analytics: Connect performance tracking tools
- 🔄 Multi-Platform: Extend to Instagram, LinkedIn
- 👥 Team Features: Add approval workflows
🎉 You Did It!
Congratulations! You've built an AI-powered content machine that will save you hours every week.
What's Next?
- Test with different content types
- Monitor performance in Google Sheets
- Refine AI prompts for better results
- Share your success with the community!
Need Help? 🤝
Ready to revolutionize your content creation? Your AI assistant is waiting! 🚀