# Smart message batching AI-powered Facebook Messenger chatbot use: n8n workflow

> Started by another system calling it, and works across n8n data table. It hands the judgement calls to Gemini.

Source: https://millionrounds.com/workflow/smart-message-batching-ai-powered-facebook-messenger-chatbot (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [AI assistants](https://millionrounds.com/workflows?category=AI+assistants#library)

# Smart message batching AI-powered Facebook Messenger chatbot use

Started by another system calling it, and works across n8n data table. It hands the judgement calls to Gemini. 25 steps, 3 branches, 3 loops or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: Gemini

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fsmart-message-batching-ai-powered-facebook-messenger-chatbot)

**25 steps** Large: read it before trusting it with anything live

**3** Branches: places the flow splits

**3** Loops or waits

**1** Service it connects to

## The flow

Starts it 2 Model 2 Logic 12 Service 9

The steps in the order they run, from what starts it.

- 1 **Facebook Webhook** Webhook *Starts it*
- 2 **Google Gemini Chat Model** Lm Chat Google Gemini *Model*
- 3 **Confirm Webhook** Respond To Webhook *Starts it*
- 4 **Is message** If *Logic*
- 5 **Process Merged Message** Agent *Model*
- 6 **Set Context** Set *Logic*
- 7 **Format for Facebook Output** Code *Logic*
- 8 **Is from page?** If *Logic*
- 9 **Loop Over Items** Split In Batches *Logic*
- 10 **User is Sender** Set *Logic*
- 11 **Update FALSE to TRUE** Data Table *Service*
- 12 **Delay Between Messages** Wait *Logic*
- 13 **Seen** Http Request *Service*
- 14 **Insert To Unprocessed** Data Table *Service*
- 15 **Update Page Rep** Data Table *Service*
- 16 **Send Text** Http Request *Service*
- 17 **Wait** Wait *Logic*
- 18 **Clean History** Data Table *Service*
- 19 **Get unprocessed message** Data Table *Service*
- 20 **Get Max ID + Merged Mess** Code *Logic*
- 21 **Is Max ID?** If *Logic*
- 22 **Get history message** Data Table *Service*
- 23 **Get 15 newest rows** Code *Logic*
- 24 **Merge History and Find MinID** Code *Logic*
- 25 **Send Typing** Http Request *Service*

## How it's built

- **Starts on:** Another system calling it
- **Steps:** 25, with 3 branches, 3 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** n8n data table
- **Model:** Gemini

## Questions

What does it need to run?

An n8n account, and a key for Gemini. You connect your own accounts after importing it; none are included.

What starts it?

It starts on another system calling it.

Does it use AI?

Yes. It calls Gemini. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 25 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 25 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fsmart-message-batching-ai-powered-facebook-messenger-chatbot)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[n8n data table](https://millionrounds.com/workflows?service=n8n+data+table#library)

## Workflows like it

Also ai assistants, with the same services where possible, closest in size first.

- [**Analyze and modernize university curricula with OpenAI** 24 steps · calls a model · in-memory vectors, n8n data table](https://millionrounds.com/workflow/analyze-and-modernize-university-curricula-with-openai)
- [**Build a Headless AI Chat API with Memory and History** 26 steps · calls a model · n8n data table](https://millionrounds.com/workflow/build-a-headless-ai-chat-api-with-memory-and-history)
- [**Email-to-task automation with Outlook and Microsoft To Do** 26 steps · calls a model · Gmail, Google Tasks](https://millionrounds.com/workflow/email-to-task-automation-with-outlook-and-microsoft-to-do)
- [**Segment players and predict churn with OpenAI** 23 steps · calls a model · in-memory vectors, n8n data table](https://millionrounds.com/workflow/segment-players-and-predict-churn-with-openai)
- [**Draft dental denial appeal packets from Gmail EOBs with OpenAI** 22 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/draft-dental-denial-appeal-packets-from-gmail-eobs-with-open)
- [**Trip concierge with OpenRouter** 22 steps · calls a model · Email, n8n data table](https://millionrounds.com/workflow/trip-concierge-with-openrouter)
