AI-Powered Instagram DM Chatbot with Gemini & Chat Memory
A production-ready n8n workflow that connects Instagram Direct Messages (DMs) via the Meta Graph API to Google Gemini. It features conversational memory and handles both text messages and image uploads (multimodal AI).
This template provides a comprehensive and scalable solution for automating your Instagram DMs. Built on n8n, it uses LangChain nodes to integrate powerful Google Gemini models (Gemini 2.5 Flash) to respond intelligently and contextually to your customers.
✨ Key Features:
-
Real-time Instagram Webhook: Instantly processes incoming DMs via the Meta Graph API.
-
Conversational Memory (Simple Memory Node): Tracks the history of the conversation (per user) to ensure the AI’s responses are contextually relevant and engaging.
-
Multimodal AI Support (Image Analysis): Automatically detects image attachments, downloads them, and uses Gemini to analyze the content, allowing the bot to respond to photo-based inquiries.
-
Smart Routing: Separates text, image, and (optionally) audio messages for specialized processing. It also filters out echo messages (the bot’s own replies) to prevent infinite loops.
-
Custom Persona & Sales Goals: The included System Prompt gives the AI a friendly, professional personality (“Instant Reply Bot”) and integrates a secondary sales goal to offer your service to interested users.
-
Built-in Truncation: Prevents API errors by automatically limiting the outgoing message size to stay within Instagram’s 1000-character limit.
⚙️ Technical Requirements:
-
n8n Instance (Self-Hosted or Cloud)
-
Meta/Instagram App Credentials (Webhook URL, Access Token)
-
Google Gemini API Key (or PaLM API Key, as used in the original flow)
Related Products
AI-Powered B2B Lead Generation & Personalization Engine n8n template
An automated n8n workflow that turns a simple chat query (e.g., "SaaS Marketing Directors in London") into a Google Sheet full of enriched B2B leads, complete with AI-written personalized openers for outreach.
Free n8n Template: AI Agent for Facebook Page Messaging with Calendar Booking and Lead Capture
A comprehensive, intelligent workflow that connects your Facebook Page messaging to an advanced AI model. It instantly handles customer inquiries, performs lead qualification, books appointments, and sends internal notifications, ensuring 24/7 personalized customer service.
