Skip to main content

Instagram content & DM automation with Gemini, Telegram, and Apify

Workflow preview

Workflow preview
100%
Instagram content & DM automation with Gemini, Telegram, and Apify preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Instagram Automation Suite: AI Chatbot & Content Powerhouse Workflow Overview This cutting edge n8n workflow is a comprehensive automation solution designed to streamline various Instagram opera...

Best for

  • Social Media automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.scheduletrigger, n8n-nodes-base.stickynote, n8n-nodes-base.switch, n8n-nodes-base.set, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenrouter, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.telegram

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Msaid Mohamed el hadi.

Original n8n.io source

1.1 Workflow description

Title
Instagram content & DM automation with Gemini, Telegram, and Apify
Workflow name
Instagram content & DM automation with Gemini, Telegram, and Apify

πŸ€– Instagram Automation Suite: AI Chatbot & Content Powerhouse

Workflow Overview

This cutting-edge n8n workflow is a comprehensive automation solution designed to streamline various Instagram operations. It combines an intelligent AI chatbot for direct message management, automated user following, and an advanced content generation system, all integrated to enhance your Instagram presence and efficiency.

This workflow automatically:

  • Manages Instagram Direct Messages via Telegram Chatbot:
    • Listens for new messages on Telegram.
    • Routes messages from a specific Instagram user (Wolf23000) for processing.
    • Utilizes an AI agent (powered by OpenRouter's cutting-edge models) to determine the intent of the message (e.g., chat back, run an Instagram-related action like getting profile info, posting, or following).
    • Sends AI-generated responses back to the user via Telegram.
  • Automates Instagram User Following:
    • Scheduled to run at regular intervals (hourly).
    • Processes a list of usernames (likely from a Google Sheet, though not explicitly shown in the provided JSON, it's a common pattern for "Auto Follow users from sheet" sticky note).
    • Initiates following actions on Instagram for the specified users.
  • Generates & Schedules Instagram Posts:
    • Scheduled to run monthly.
    • Leverages an AI agent (powered by OpenRouter) to generate 30 or 31 Instagram post ideas for the current month, based on a predefined "Instagram personality profile."
    • Each post idea includes an imagePrompt (for AI image generation), a caption with emojis and hashtags, and a scheduledDate.
    • Refines these post ideas by enhancing the imagePrompt to be more vivid and detailed for AI image generation, and polishing the caption for optimal engagement.
    • Updates a Google Sheet ("posts generation plan") with the generated content, including the enhanced image prompts and the resulting image URLs (presumably from a separate image generation step not fully detailed in the provided JSON, but implied by image_url updates).

Key Benefits

  • Intelligent DM Management: Automate responses and actions for Instagram direct messages, ensuring timely and relevant interactions without manual effort.
  • Effortless Audience Growth: Automatically follow target users, expanding your reach and potential engagement on Instagram.
  • AI-Powered Content Creation: Generate a full month's worth of diverse, engaging Instagram post ideas tailored to a specific personality, complete with image prompts and captions.
  • Content Optimization: Automatically enhance image prompts for better AI image generation and refine captions for maximum impact.
  • Time-Saving: Significantly reduce the manual workload associated with Instagram management, from direct messages to content planning and execution.
  • Consistent Brand Voice: Maintain a consistent and engaging presence on Instagram with AI-generated content aligned with your defined personality.

Setup Requirements

To set up and run this workflow, you'll need the following:

  • n8n Installation:
    • Install n8n (cloud or self-hosted). The latest stable version, as of July 2025, is v1.101.1.
    • Import the workflow configuration.
    • Configure API credentials for all integrated services.
    • Set up scheduling preferences for continuous operation.
    • System Requirements for Self-Hosting: A modern multi-core processor (2 cores minimum, 4 recommended), 2 GB RAM (4 GB or more recommended), and 20 GB of free SSD storage. Node.js version 16 or later (18.x LTS recommended) is required. PostgreSQL is the recommended database for production.
  • Telegram API Access:
    • Create a Telegram bot via BotFather and obtain your API token.
    • Configure the Telegram Trigger node with your bot's API credentials to receive messages.
    • Pricing: Telegram's API is free to use.
  • OpenRouter API Access:
    • Create an OpenRouter account and generate an API key.
    • This key ({{your open router api key }} as seen in the code) is used to access their chat models (e.g., google/gemini-2.5-flash-preview) for AI agent operations.
    • Pricing: OpenRouter offers a variety of models with different pricing structures, including some free models like DeepSeek R1. Most models operate on a pay-per-usage basis, with costs clearly displayed for each model and prompt.
  • Instagram Session ID:
    • You'll need a valid Instagram session ID ({{ your instagram session ID }} as seen in the code) for the workflow to interact with Instagram. This usually involves extracting it from your browser's cookies after logging into Instagram.
    • Caution: Instagram's terms of service generally prohibit automated interactions, and using session IDs for scraping or automation can lead to account suspension. Use with extreme caution and at your own risk.
  • Apify token setup: *You'll need to replace {{ your apify token }} with you apify token in https requests
  • Google Sheets Credentials:
  • Predefined Instagram Personality JSON:
    • The workflow relies on a detailed JSON object defining an "Instagram personality" (e.g., user_id, username, full_name, bio, content_preferences, personality_traits, unfulancer_attributes). This JSON needs to be correctly set within the Code nodes (Variables, Variables1, Variables2) to guide the AI content generation.

Workflow Architecture

[Telegram New Message Trigger]
    ⬇️
[Variables (Set OpenRouter API Key, Instagram Personality, Session ID)]
    ⬇️
[Switch (Filter messages from 'Wolf23000' and ensure message text exists)]
    ⬇️
[Edit Fields (Extract message text)]
    ⬇️
[AI Agent (Determine action based on message intent)]
    ⬇️
[Structured Output Parser (Parse AI agent's JSON output)]
    ⬇️
[Switch1 (Route based on AI agent's determined action: chat_back, run_agent, get_instagram_profile)]
    ⬇️
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚             β”‚             β”‚             β”‚
    β–Ό             β–Ό             β–Ό             β–Ό
[Send a text message1 (Chat back)] [Send a text message (Run agent confirmation)] [Send a text message2 (Get profile confirmation)]
    β–²
    β”‚
[Schedule Trigger (Hourly for Instagram follow)]
    ⬇️
[Variables (Set OpenRouter API Key, Instagram Personality, Session ID)]
    ⬇️
[Code (Prepare usernames for following)]
    ⬇️
[Code1 (Process followed usernames)]
    ⬇️
[Schedule Trigger2 (Monthly for Instagram post generation)]
    ⬇️
[AI Agent1 (Generate monthly Instagram post ideas)]
    ⬇️
[OpenRouter Chat Model (AI Model for content generation)]
    ⬇️
[Code2 (Parse AI agent's JSON output)]
    ⬇️
[Schedule Trigger3 (Daily for post generation refinement and auto-posting)]
    ⬇️
[AI Agent2 (Enhance image prompts and captions)]
    ⬇️
[OpenRouter Chat Model2 (AI Model for prompt refinement)]
    ⬇️
[Update row in sheet1 (Update Google Sheet with enhanced content)]
    ⬇️
[Get row(s) in sheet2 (Retrieve data from Google Sheet)]

Connect With Me

Exploring AI-Powered Social Media Automation? πŸ“§ Email: [email protected] πŸ’Ό LinkedIn: Mohamed el Hadi Msaid

Supercharge your Instagram presence with intelligent automation and AI-driven content! πŸš€

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 2 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 4 - Edit Fields

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 5 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 6 - OpenRouter Chat Model1

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 7 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 8 - Switch1

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 9 - Send a text message

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 10 - Send a text message1

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 11 - Send a text message2

Type / Role
n8n-nodes-base.telegram - telegram
Config choices
Version 1.2

Block 12 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Schedule Trigger1

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 14 - Code

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Code1

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 16 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Schedule Trigger2

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 18 - AI Agent1

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 19 - OpenRouter Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Block 20 - Code2

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 21 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Schedule Trigger3

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 23 - AI Agent2

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 24 - OpenRouter Chat Model2

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenRouter - lmChatOpenRouter
Config choices
Version 1

Showing the first 24 of 47 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Instagram content & DM automation with Gemini, Telegram, and Apify
Complexity advanced
Nodes 47
Categories Social Media, AI Chatbot
Author Msaid Mohamed el hadi
Published 16 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6070/6070.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Instagram content & DM automation with Gemini, Telegram, and Apify do?

Instagram Automation Suite: AI Chatbot & Content Powerhouse Workflow Overview This cutting edge n8n workflow is a comprehensive automation solution designed to streamline various Instagram opera...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Social Media, AI Chatbot use case.