Automation library · AI assistants

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.

LargeCalls a model: Gemini

25 stepsLarge: read it before trusting it with anything live
3Branches: places the flow splits
3Loops or waits
1Service it connects to

The flow

Starts it 2Model 2Logic 12Service 9

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

  1. 1Facebook WebhookWebhookStarts it
  2. 2Google Gemini Chat ModelLm Chat Google GeminiModel
  3. 3Confirm WebhookRespond To WebhookStarts it
  4. 4Is messageIfLogic
  5. 5Process Merged MessageAgentModel
  6. 6Set ContextSetLogic
  7. 7Format for Facebook OutputCodeLogic
  8. 8Is from page?IfLogic
  9. 9Loop Over ItemsSplit In BatchesLogic
  10. 10User is SenderSetLogic
  11. 11Update FALSE to TRUEData TableService
  12. 12Delay Between MessagesWaitLogic
  13. 13SeenHttp RequestService
  14. 14Insert To UnprocessedData TableService
  15. 15Update Page RepData TableService
  16. 16Send TextHttp RequestService
  17. 17WaitWaitLogic
  18. 18Clean HistoryData TableService
  19. 19Get unprocessed messageData TableService
  20. 20Get Max ID + Merged MessCodeLogic
  21. 21Is Max ID?IfLogic
  22. 22Get history messageData TableService
  23. 23Get 15 newest rowsCodeLogic
  24. 24Merge History and Find MinIDCodeLogic
  25. 25Send TypingHttp RequestService

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.