Skip to main content

Generate Instagram captions from hashtag analysis using Apify + GPT-4o-mini

Workflow preview

Workflow preview
100%
Generate Instagram captions from hashtag analysis using Apify + GPT-4o-mini preview
Open on n8n.io

Important notice

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

1. Workflow Overview

This n8n workflow scrapes recent Instagram posts by hashtag and generates new, relevant caption ideas using OpenAI. It avoids making up suggestions by analyzing real world content and surfacing com...

Best for

  • Content Creation automation workflows
  • Multimodal AI automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.httprequest, n8n-nodes-base.set, n8n-nodes-base.stickynote, n8n-nodes-base.aggregate

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Robert Breen.

Original n8n.io source

1.1 Workflow description

Title
Generate Instagram captions from hashtag analysis using Apify + GPT-4o-mini
Workflow name
Generate Instagram captions from hashtag analysis using Apify + GPT-4o-mini

This n8n workflow scrapes recent Instagram posts by hashtag and generates new, relevant caption ideas using OpenAI. It avoids making up suggestions by analyzing real-world content and surfacing common patterns.


✅ Use Case

Marketing teams, content creators, or social media managers can:

  • Discover what’s trending for a specific topic
  • Automatically generate Instagram captions based on real posts
  • Understand common caption styles for a niche
  • Save time brainstorming ideas while staying on-brand

🧠 How It Works

1️⃣ Manual Trigger

🧩 Node: When clicking ‘Execute workflow’
  • Manually starts the workflow for testing or single-run execution.

2️⃣ Define the Hashtag

🧩 Node: Create Search Term
  • Sets the value of the hashtag you'd like to scan.
  • Default is n8n, but you can modify it to anything.
{
  "Search_Term": "yourCustomHashtag"
}

3️⃣ Scrape Instagram Posts

🧩 Node: Find Recent Posts

JSON Body:

{
  "hashtags": ["{{ $json.Search_Term }}"],
  "resultsLimit": 20,
  "resultsType": "posts"
}

4️⃣ Extract Captions

🧩 Node: Set bio and follower count
  • Extracts just the caption from each post and stores it in a clean variable for the AI agent to use.

5️⃣ Aggregate Captions

🧩 Node: Aggregate
  • Gathers all captions into one list before processing.
  • Useful for passing a large text block into the AI.

6️⃣ Convert to Single Text Block

🧩 Node: Convert table names and columns into single text for agent
  • Uses a Code node to combine all captions into a single string for OpenAI to read:
return [
  {
    json: {
      text: items
        .map(item => `- ${JSON.stringify(item.json)}`)
        .join('\n\n'),
    },
  },
];

7️⃣ Generate Caption Ideas with AI

🧩 Node: AI Agent
  • Takes the combined post text and sends it to GPT-4o-mini.
  • Includes this system message:
I'm looking for ideas for posts about {{ $('Create Search Term').item.json.Search_Term }}.
Here’s the last 5 posts on Instagram about the topic. Use those to help me generate a list of relevant captions.

Do not make up ideas that are not like the others in the list.

Output like this:
{
  "Post Idea": ["Idea1", "Idea2"],
  "Most Common Post": ["common post 1", "common post 2"]
}

8️⃣ Choose Language Model

🧩 Node: OpenAI Chat Model
  • Model: gpt-4o-mini
  • Credential: Use your OpenAI API key.

9️⃣ Parse the AI Output

🧩 Node: Structured Output Parser
  • Parses the GPT response into structured JSON:
{
  "Post Idea": ["Idea1", "Idea2"],
  "Most Common Post": ["common post 1", "common post 2"]
}

🔟 Split the Outputs

🧩 Nodes: Split Out, Split Out1
  • Separates the Post Idea list and Most Common Post list into individual items.

🔁 Merge for Final Output

🧩 Node: Merge
  • Combines the two split lists into one output stream.

👤 Need More Help?

Robert Breen
Automation Consultant | AI Workflow Designer | n8n Expert
📧 [email protected]
🔗 LinkedIn

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 - When clicking ‘Execute workflow’

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

Block 2 - AI Agent

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

Block 3 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 4 - Structured Output Parser

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

Block 5 - Find Recent Posts

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 6 - Create Search Term

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

Block 7 - Set bio and follower count

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

Block 8 - Sticky Note

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

Block 9 - Sticky Note1

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

Block 10 - Sticky Note2

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

Block 11 - Sticky Note3

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

Block 12 - Aggregate

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

Block 13 - Convert table names and columns into single text for agent

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

Block 14 - Split Out

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

Block 15 - Split Out1

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

Block 16 - Merge

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

Block 17 - Sticky Note4

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

3. Summary Table

Workflow Generate Instagram captions from hashtag analysis using Apify + GPT-4o-mini
Complexity advanced
Nodes 17
Categories Content Creation, Multimodal AI
Author Robert Breen
Published 05 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/7025/7025.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 Generate Instagram captions from hashtag analysis using Apify + GPT-4o-mini do?

This n8n workflow scrapes recent Instagram posts by hashtag and generates new, relevant caption ideas using OpenAI. It avoids making up suggestions by analyzing real world content and surfacing com...

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 Content Creation, Multimodal AI use case.