# Facebook Messenger AI customer service chatbot with Google Gemini + conversation memory - free template

**URL:** <https://community.n8n.io/t/facebook-messenger-ai-customer-service-chatbot-with-google-gemini-conversation-memory-free-template/284379>\
**Category:** Built with n8n\
**Tags:** workflow-building, langchain, ai\
**Created:** [April 3, 2026, 6:22pm UTC](https://community.n8n.io/t/facebook-messenger-ai-customer-service-chatbot-with-google-gemini-conversation-memory-free-template/284379 "2026-04-03T18:22:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nguyenthieutoan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nguyenthieutoan/32/120924_2.png) [@nguyenthieutoan](https://community.n8n.io/u/nguyenthieutoan)\
**Post date:** [April 3, 2026, 6:22pm UTC](https://community.n8n.io/t/facebook-messenger-ai-customer-service-chatbot-with-google-gemini-conversation-memory-free-template/284379/1 "2026-04-03T18:22:14Z")

</div>

Sharing a workflow I built for handling Facebook Messenger customer service with an AI backend. Posting here in case it helps others who are trying to set up Messenger bots on n8n.

**Template:** [Build a Facebook Messenger customer service AI chatbot with Google Gemini | n8n workflow template](https://n8n.io/workflows/13080-build-a-facebook-messenger-customer-service-ai-chatbot-with-google-gemini/)

* * *

**How it works**

The flow has three stages:

1. **Webhook & validation** - Receives both GET (verification handshake) and POST (messages) from Facebook. Filters out non-text events and blocks echo messages (the bot’s own replies coming back through the webhook - this trips up a lot of people).

2. **AI processing** - Extracts user\_id, page\_id, message text and token via Set Context. Sends “seen” + “typing” indicators immediately so users get feedback. Runs the message through Gemini Flash with a 10-message memory window per user.

3. **Format & send** - Strips markdown from the response (Messenger doesn’t render it), truncates at 1900 chars, sends via Graph API.

* * *

**A few things I learned the hard way**

- **Echo filtering is essential.** Facebook sends your bot’s own messages back to your webhook. Without filtering sender ID vs page ID, you get infinite loops.
- **Simple Memory doesn’t persist in queue mode.** Works fine for testing. For stable production you need Redis or Postgres-backed sessions.
- **Gemini Flash is fast enough.** With a tight system prompt, response times stay under 2 seconds - feels natural in Messenger.
- **Token management is a separate problem.** I built a dedicated workflow for long-lived page token refresh: [Get long-lived Facebook Page access tokens and subscribe Messenger webhook fields via Graph API | n8n workflow template](https://n8n.io/workflows/14027)

* * *

**What this template doesn’t cover (upgrade paths)**

- Smart message batching (waits for user to finish typing before responding): [Smart message batching AI-powered Facebook Messenger chatbot use Data Table | n8n workflow template](https://n8n.io/workflows/9192)
- Human takeover detection (bot auto-pauses when admin joins): [Smart human takeover & auto pause AI-powered Facebook Messenger chatbot | n8n workflow template](https://n8n.io/workflows/11920)

Happy to answer questions about setup or any issues you’ve run into with the Facebook Graph API on n8n.

---

<div class="post-metadata">

**Author:** ![nguyenthieutoan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nguyenthieutoan/32/120924_2.png) [@nguyenthieutoan](https://community.n8n.io/u/nguyenthieutoan)\
**Post date:** [April 3, 2026, 6:53pm UTC](https://community.n8n.io/t/facebook-messenger-ai-customer-service-chatbot-with-google-gemini-conversation-memory-free-template/284379/4 "2026-04-03T18:53:12Z")

</div>

This workflow is really just a **learning playground** , since it’s built with **Simple Memory**. But if your n8n is already on **v1.113 or higher** , you’re in luck, you can grab a similar workflow called **“Auto‑reply to Instagram DMs with an AI chatbot and Google Gemini history”** from my official library. And the best part? It’s totally free right here: [nguyenthieutoan | n8n Creator](http://n8n.io/creators/nguyenthieutoan) .

That one is battle‑tested to handle **hundreds of users at the same time** , because each person gets their own **unique ID** and the conversation history is neatly stored in a **data table**.

And if you want to level up, I also offer **premium versions** for just a bit over **$10** , packed with extra goodies like:

- Handling interrupted messages smoothly

- Automatically pausing when an admin jumps in

So you can start with the free template for fun and experiments, and upgrade later if you want more professional features.
