Skip to main content

Smart message batching AI-powered Facebook Messenger chatbot

Workflow preview

Workflow preview
100%
Smart message batching AI-powered Facebook Messenger chatbot preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Facebook Messenger Smart Chatbot Smart Batch, Format & History with n8n Data Table v3 Version 2026 Adaptable to n8n v1.113+ and v2.x by Nguyen Thieu Toan (Jay Nguyen) ![bananapro20251218T1020417...

Best for

  • Support Chatbot automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.webhook, n8n-nodes-base.set, n8n-nodes-base.code, @n8n/n8n-nodes-langchain.lmchatgooglegemini, n8n-nodes-base.wait, n8n-nodes-base.splitinbatches, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Nguyễn Thiệu Toàn (Jay Nguyen).

Original n8n.io source

1.1 Workflow description

Title
Smart message batching AI-powered Facebook Messenger chatbot
Workflow name
Smart message batching AI-powered Facebook Messenger chatbot

🤖 Facebook Messenger Smart Chatbot - Smart Batch, Format & History with n8n Data Table v3

Version 2026 - Adaptable to n8n v1.113+ and v2.x

by Nguyen Thieu Toan (Jay Nguyen)


📖 Overview

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:

  • 💼 Customer support automation
  • 🛒 E-commerce product inquiries
  • 📅 Appointment scheduling & consultation booking
  • 🎓 Educational assistants & training
  • 🤝 Lead qualification & sales automation

Requirements: n8n v1.113.0+, Facebook App with Messenger, Google Gemini API key (or compatible LLM)

🔗 Complementary Workflow

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?

  • Smart Batch (v3): Multi-message batching, spam reduction
  • Human Takeover: AI pauses for humans, smooth collaboration

👉 Access workflow


⚡ What's New in Version 3

Major Upgrades

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.


🎯 Key Features

  • 🔄 Smart Batching: Groups consecutive messages within configurable window (default 7s)
  • 🧠 Session-Aware Context: Distinguishes old vs. current sessions for temporal awareness
  • 📋 Full History: Stores complete chat logs with both user and page responses
  • 👀 Natural UX: "Seen" marker and "Typing..." indicator for human-like feel
  • 🎯 AI Integration: Extensible prompts for domain-specific consulting (Gemini, Groq, or any LLM)
  • 🌐 Multi-Language: Handles Vietnamese (anh/chị/em) with customizable settings
  • 🏢 Multi-Page Ready: Single workflow serves multiple Facebook Pages simultaneously

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)


🏗️ How It Works

### 🔄 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  

🛠️ Setup Guide

Step 1: Facebook App

Create app, add Messenger, set webhook, get token, subscribe page

Step 2: Data Table

Prepare tables for messages batching

Step 3: Workflow

Import template, set context, link tables, connect AI

Step 4: Test

Activate workflow, send test messages, verify pause/resume


👤 About the Author

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]


📄 License

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! 🚀

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 2 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Facebook Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2.1

Block 8 - Set Context

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 9 - Format for Facebook Output

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Google Gemini Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatGoogleGemini - lmChatGoogleGemini
Config choices
Version 1

Block 11 - Get 15 newest rows

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 12 - Delay Between Messages

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 13 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 14 - Confirm Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.5

Block 15 - Is from page?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 16 - Seen

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 17 - Get history message

Type / Role
n8n-nodes-base.dataTable - dataTable
Config choices
Version 1.1

Block 18 - Send Typing

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 19 - Process Merged Message

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3.1

Block 20 - Send Text

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.3

Block 21 - Update Page Rep

Type / Role
n8n-nodes-base.dataTable - dataTable
Config choices
Version 1.1

Block 22 - Update FALSE to TRUE

Type / Role
n8n-nodes-base.dataTable - dataTable
Config choices
Version 1.1

Block 23 - Is message

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 24 - User is Sender

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Showing the first 24 of 33 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Smart message batching AI-powered Facebook Messenger chatbot
Complexity advanced
Nodes 33
Categories Support Chatbot, AI Chatbot
Author Nguyễn Thiệu Toàn (Jay Nguyen)
Published 02 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9192/9192.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Smart message batching AI-powered Facebook Messenger chatbot do?

Facebook Messenger Smart Chatbot Smart Batch, Format & History with n8n Data Table v3 Version 2026 Adaptable to n8n v1.113+ and v2.x by Nguyen Thieu Toan (Jay Nguyen) ![bananapro20251218T1020417...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI Chatbot use case.