💬 Build a Facebook Messenger customer service AI chatbot with Google Gemini

733 views · 💬 Support Chatbots

💡 Pro Tip — If you’ve run into Facebook’s Graph API permission restrictions, ScraperNode is a community node that scrapes pages, groups, posts, and comments directly — no app review needed.

View All Scrapers

Description

🤖 Build a customer service AI chatbot for Facebook Messenger with Google Gemini


📌 Overview

A streamlined Facebook Messenger chatbot powered by AI with conversation memory.
This is a simplified version designed for quick deployment, learning, and testing — not suitable for production environments.

Base workflows:


🎯 What This Workflow Does

Core Features:

🔹 Simplified Approach:

⚠️ Limitations & Trade-offs:

  1. No Smart Batching → fragmented user messages cause spam-like replies
  2. No Human Takeover Detection → bot continues even when admin joins
  3. Basic Memory Management → no persistence, not reliable in production
  4. Basic Text Formatting → strips markdown, truncates brutally, no smart splitting

🚀 When to Upgrade

Upgrade to full workflows when you need:

Key upgrades available:


⚙️ Setup Requirements

Facebook Setup

  1. Create Facebook App at developers.facebook.com
  2. Add Messenger product
  3. Configure webhook:
    • URL: https://your-domain.com/webhook/your-path
    • Verify token: secure string
    • Subscribe to: messages, messaging_postbacks
  4. Generate Page Access Token
  5. Copy token to “Set Context” node

n8n Setup

  1. Import workflow
  2. Edit “Set Context” node → update page_access_token
  3. Configure “Gemini Flash” node credentials
  4. Deploy workflow (must be publicly accessible)

🔄 How It Works

User Message → Facebook Webhook → Validation

Set Context (extract user_id, message, token)

Mark Seen → Show Typing

AI Agent (Gemini + 10-message memory)

Format Output (remove markdown, truncate)

Send Response via Facebook API

🏗️ Architecture Overview

Section 1: Webhook & Initial Processing

Section 2: AI Processing with Memory

Section 3: Format & Delivery


🎨 Customisation Guide


📌 Important Notes

⚠️ Production Warning: testing only, memory lost on n8n restart in queue mode
📊 No Analytics: no history storage, no reporting
🔧 Format Limitations: responses ≤1800 chars, markdown stripped, no complex formatting


🛠️ Troubleshooting


📜 License & Credits

Created by: Nguyễn Thiệu Toàn (Jay Nguyen)

🔗 Nodes Used

HTTP Request, Webhook, AI Agent, Simple Memory, Structured Output Parser, Google Gemini Chat Model

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup