by Nguyen Thieu Toan (Jay Nguyen)

A production-ready, enterprise-grade chatbot solution for Facebook Messenger built entirely in n8n. Features intelligent message batching, session-aware conversation tracking, multi-page support, and natural AI-powered responses.
Perfect for:
Requirements: n8n v1.113.0+, Facebook App with Messenger, Google Gemini API key (or compatible LLM)
Facebook Messenger Chatbot – Smart Human Takeover, Auto Pause & Context-Aware
Adds intelligent human agent detection and automatic AI pause. When a human joins, AI pauses for configurable duration, then resumes automatically.
Why combine?

| Feature | Impact |
|---|---|
| 🏢 Multi-Page Support | Manage multiple pages within one workflow |
| ⏱️ Flexible Timing | Adjustable wait times instead of fixed delays |
| 🔒 Improved Detection | More reliable identification of system vs. user messages |
| 📦 Smart Delivery | Sequential message handling to avoid overload |
| 🧹 Automatic Cleanup | Removes outdated records to keep storage efficient |
| 📊 Better Context | Clear separation of past vs. current sessions |
| 🔄 Ordered Updates | Ensures actions run in the right sequence |
| 📝 Simplified Naming | Clearer labels for easier understanding |
Architecture Comparison:
Previous version had fixed timing, parallel updates, no multi-page handling, and no cleanup.
New version introduces flexibility, sequential processing, and scalability for real-world use.
Technical Highlights: Idempotent processing, timezone-aware timestamps (Asia/Ho_Chi_Minh), Facebook API v24.0 compatible, sequential delivery with rate limiting protection, auto cleanup (keeps last 15 rows)
### 🔄 General Flow
Reception & Validation → Batching & Storage → Context Aggregation
↓ ↓ ↓
Identify input Store for later use Combine with history
Filter duplicates Apply short delay Build conversation context
↓
AI Processing → Delivery & Cleanup
↓ ↓
Generate response Format & send
Add signals Maintain records
Ensure continuity Clean old data
Create app, add Messenger, set webhook, get token, subscribe page
Prepare tables for messages batching
Import template, set context, link tables, connect AI
Activate workflow, send test messages, verify pause/resume
Nguyen Thieu Toan (Nguyễn Thiệu Toàn / Jay Nguyen)
AI Automation Specialist | n8n Workflow Expert | Business Optimization Consultant
Services: AI Automation Solutions, n8n Workflow Development, Custom Chatbot Implementation, Training Programs
Contact:
GenStaff Company: genstaff.net | [email protected]
After purchase, use in commercial/personal projects. No redistribution or resale. Keep author attribution when sharing.
Last Updated: December 18, 2025 | Version: 3.0 | n8n Compatibility: v1.123.0+ and v2.0.0+ | Facebook API: v24.0
Ready to transform your Facebook Messenger into an intelligent AI assistant? Import this workflow and start automating today! 🚀