Facebook automation
*SON HUNG

Year: 2026

My Role: Marketing Executive

Year: 2026

My Role: Marketing Executive

  • Graphic Design

    Social Media Design

    Branding

    Graphic Design

    Social Media Design

    Branding

    Graphic Design

    Social Media Design

    Branding

  • Graphic Design

    Social Media Design

    Branding

    Graphic Design

    Social Media Design

    Branding

    Graphic Design

    Social Media Design

    Branding

  • Graphic Design

    Social Media Design

    Branding

    Graphic Design

    Social Media Design

    Branding

    Graphic Design

    Social Media Design

    Branding

Case Study: Engineering a High-Performance AI Agent for Facebook Messenger using n8n & Google Gemini

The Vision: Beyond Basic Automation

In the competitive landscape of digital marketing, response speed and quality are the ultimate differentiators. For a high-traffic driving center, I didn't just want a chatbot: I wanted an AI Agent that feels human, acts intelligently, and operates with enterprise-grade reliability.

The Challenge: The "Bot" Bottlenecks

Standard Facebook integrations often suffer from three critical issues:

  1. Webhook Duplication: Facebook frequently sends duplicate triggers, causing bots to reply twice. This is a major turn-off for users.

  2. Fragmented Context: Users often send multiple short messages. Standard bots reply to each snippet, creating a chaotic and robotic conversation.

  3. The Lack of "Soul": Instantaneous and cold replies immediately flag the interaction as non-human.

The Architecture: A Modular Approach

Using n8n as the primary orchestrator, I engineered a multi-layered workflow to solve these challenges.

1. The Reliability Layer (Deduplication and Storage)

I integrated Supabase to act as a real-time message filter. By checking unique message IDs before processing, the system identifies and kills duplicate webhooks. This ensures each user query is processed exactly once.

2. The Cognitive Layer (Gemini and LangChain)

The "brain" of the agent is powered by Google Gemini 2.5 Flash via LangChain nodes.

  • Persistent Memory: Using Postgres Chat Memory, the AI maintains deep context.N it remembers user preferences and previous questions across sessions.

  • Centralized Knowledge: I used Google Sheets as a headless CMS for Prompt Management. This allows me to update the agent's knowledge or tone instantly without redeploying the code.

3. The UX Layer (Humanizing the Interface)

To make the AI feel like a personal consultant, I implemented specific features:

  • Message Merging: A custom logic that "waits" for the user to finish their thought. It merges fragmented messages into a single coherent prompt for the AI.

  • Visual Cues: The workflow triggers a "typing_on" status followed by a strategic Wait node. This simulates the natural delay of a human staff member typing a response.

The Impact: Measurable Growth

24/7 Availability: Zero missed leads, even during late-night hours.

  • Scalability: The system handles hundreds of concurrent inquiries without performance degradation.

  • Conversion Rate: A 20% increase in qualified leads as students received instant and accurate information regarding licensing categories and exam schedules.

Create a free website with Framer, the website builder loved by startups, designers and agencies.