1 · Start n8n
Free and open source. The editor opens at http://localhost:5678
npx n8n
Monica Academy · Episode 3 · Messenger AI agent
Most Messenger agents are built to answer, not to know. Build one for your own Facebook page with free tools (n8n, a Cloudflare tunnel, Meta for Developers and a Gemini key), then add the four rules that keep it from making up prices and promises.
Seven files: the n8n workflow to import, the agent instructions with the four rules, the Meta setup checklist, every “Make it yours” from the video, the two commands, the PDF and a start-here note. Free. No form, no email. Not affiliated with Valerian Valkin, Meta, n8n or Google.
Or download one file at a time
The episode, the downloads and the copy buttons: immonica.com/academy/messenger-ai-agent
What you build
One n8n workflow you can import, built with four free tools: n8n Community Edition on your own computer, a Cloudflare quick tunnel, Meta for Developers and a Gemini key from Google AI Studio.
The door
The webhook sends Meta's challenge back only when the request says subscribe and the verify token is yours. Anything else is refused.
The filter
Meta gets its answer right away, before the agent thinks. Then only text messages from a person go through: no echoes, no read receipts.
The brain
An AI Agent node with Gemini at a low temperature, so it sticks to its instructions. The memory key is the sender's ID, so two conversations never mix.
The way out
The reply goes back to Messenger through Meta's Send API. If the agent answers HANDOFF, the person gets one line, your team gets an email and the agent goes quiet in that conversation.
One thing to know about the free Gemini tier: Google can use what you send to improve its products. Read the terms before customer data goes through it.
The ten steps
Steps 1 to 6 follow Valerian Valkin's build. Steps 7 to 10 are the four rules it doesn't have. Each step: what to do, what it replaces, and the rule to keep.
Run n8n on your own computer with one command, then open a free Cloudflare quick tunnel so Meta can reach it over https. If you'd rather not install anything, n8n Cloud runs the same editor online. It replaces paying for a platform just to receive your messages. Rule: whatever sends you messages needs a public, secure address.
In Meta for Developers, create an app and add Messenger. It starts in development mode, where it only works with people who have a role on the app. It replaces connecting your page to a tool you can't see inside. Rule: decide who can reach your agent before you connect it.
Paste the webhook's address and a verify token of your choice into Meta. n8n sends the challenge back only if the request says subscribe and the token is yours. The page token goes into an n8n credential, never into a node. It replaces a workflow anyone on the internet could talk to. Rule: only answer requests you can prove are yours.
The webhook takes Meta's check and the messages, which arrive by different methods. Answer Meta right away, before the agent thinks, or Meta sends the same message again. Then let through only a text message, from a person, that isn't an echo. It replaces double replies, and an agent that wakes up for read receipts or answers itself. Rule: your agent answers people, never its own echo.
Create a free API key in Google AI Studio, add the AI Agent node with the Gemini chat model and set the temperature low, so it sticks to its instructions. The memory key is the sender's ID. It replaces one memory where two people's conversations get mixed. Rule: every conversation belongs to one person; never mix two.
Import the Send API example from Meta's documentation into an HTTP Request node. Two swaps: the sender becomes the recipient, and the agent's output becomes the text. It replaces an answer that stays in n8n, where your customer never sees it. Rule: check the reply where the customer sees it, not inside your tool.
Paste your public information into the agent's instructions: what you offer, your hours, how to reach the team. Then one line: if the answer isn't here, say you'll check with the team. It replaces a model that fills the gaps with confident guesses. Rule: if it isn't in your information, the answer is “I'll check with the team,” never an invented price, hour or promise.
Add one instruction: before booking or promising anything, ask for the person's name and a phone number or email. It replaces a “you're booked” that nobody on your team can find. Rule: nothing is booked or promised until you know who you're talking to.
When someone asks for a person, seems upset, or the agent isn't sure, it answers only HANDOFF. An IF node catches it: one line to the customer, an email to your team, and that conversation goes on a pause list. It replaces an agent that keeps talking after someone asks for a human. Rule: a handoff only counts if a person gets it and the agent goes quiet.
In development mode, an account with a role on the app gets answers and an account without one gets nothing. To answer the public, the app has to pass Meta's App Review. It replaces finding out from a real customer that a rule doesn't work. Rule: open the door only after steps 7 to 9 work.
Step 1 · The two commands
Run them in this order, each one in its own terminal. n8n needs Node.js; on a Mac, install cloudflared with Homebrew first (brew install cloudflared).
Free and open source. The editor opens at http://localhost:5678
npx n8n
A free Cloudflare quick tunnel: it gives n8n a public https address.
cloudflared tunnel --url http://localhost:5678
So the webhook shows the right production address. Swap in your tunnel's address.
WEBHOOK_URL=https://<your-tunnel>.trycloudflare.com npx n8n
The address you give Meta
Your tunnel's address followed by /webhook/messenger, with the workflow published in n8n. A quick tunnel gets a new address every time it starts, so if you restart it, update the address in Meta too.
Steps 2, 3 and 4 · In Meta for Developers
Every click is in the Meta setup checklist in the kit. These are the four settings that matter.
Step 2
A new app starts in development mode, where only people with a role on the app get answers. Give a role to yourself, or to one colleague, and nobody else.
Step 3
The callback address is your n8n production webhook on the tunnel. The verify token is any word you choose, the same one you put in n8n.
Step 3
Meta shows the page token once. It goes into an n8n credential that the two reply nodes share, never pasted into a node.
Step 4
Leave read receipts and echoes off. Read receipts wake the agent up with nothing to answer, and echoes make it answer its own replies.
Step 10: to answer people with no role on the app, the app needs Meta's App Review for messaging. Until then, the page's real customers get nothing from the agent.
Steps 7 to 10 · The four rules
Rules 1 to 3 are lines in the agent's instructions, ready to copy. Rule 4 is a setting in your Meta app. The kit's agent-instructions.txt has all four, with a place for your information.
If it isn't in what you pasted, the agent says it will check with the team.
Use only this information. If the answer isn't here, say you'll check with the team. Never invent prices, hours, availability or promises.
Nothing is booked or promised until you know who you're talking to.
Before booking or promising anything, ask for the person's name and a phone number or email.
The workflow catches HANDOFF, emails your team and pauses that conversation.
If they ask for a person, seem upset, or you're not sure, answer only HANDOFF.
Rule 4 · A setting, not a line
In development mode, only people with a role on the app get answers, so you can build on your real page while your customers see nothing. To answer the public, the app has to pass Meta's App Review.
The 24-hour clock: a page can reply freely within 24 hours of the person's last message. After that, Meta doesn't allow standard messages, so your team picks up a handoff the same day.
The workflow · After you import it
In n8n, create a workflow and choose Import from File in its menu. The file has no keys or tokens inside: you add them as credentials, and n8n keeps them out of the workflow.
Credential 1
Your API key from Google AI Studio, for the Gemini node.
Credential 2
A Header Auth credential: name Authorization, value Bearer followed by your page token. The two reply nodes share it.
Credential 3
The mailbox that sends the handoff email. You can swap that node for n8n's Gmail node.
The blanks
YOUR_VERIFY_TOKEN in “Is it Meta's check?”, the two addresses in “Email the team”, and your real information in the AI Agent's instructions. Then publish the workflow, so the production address answers.
Make it yours
The exact “Make it yours” from every step of the video. They're also in prompts.txt in the kit.
Copy the two commands from commands.txt, in this order.
Give a role on the app to yourself, or to one colleague, and nobody else.
If Meta says it can't validate your address, paste the error into Claude and ask: "What's the first thing I should check?"
Subscribe your page only to "messages", and let through only events that have text and are not an echo.
Set the memory key to the sender's ID: {{ $('Get the message').item.json.senderId }}
Import the "Send a basic text" example from Meta's documentation and change only the recipient and the text.
Paste your FAQ and add: "Use only this information. If the answer isn't here, say you'll check with the team. Never invent prices, hours, availability or promises."
Add: "Before booking or promising anything, ask for the person's name and a phone number or email."
Add: "If they ask for a person, seem upset, or you're not sure, answer only HANDOFF."
Then send HANDOFF to your team and pause the agent for that conversation.
Keep the app in development mode until the price, contact and handoff rules all work on your own page.
Steps 7 to 9 add up to one set of instructions: agent-instructions.txt in the kit has them together, with a place for your own information.
Start n8n, open the tunnel and create the Meta app in development mode. Then paste your real information and the four rules, before anyone outside your team can write to the agent.
The first six steps follow Valerian Valkin's tutorial (youtu.be/LdSgAxdi160). Not affiliated with Valerian Valkin, Meta, n8n or Google. The Meta setup follows Meta's public Messenger Platform documentation. AI replies change from run to run.