# Optimize Instagram hashtags with OpenAI and Graph API: n8n workflow

> Started by an event in a connected app, and works across Google Sheets. It hands the judgement calls to OpenAI.

Source: https://millionrounds.com/workflow/optimize-instagram-hashtags-with-openai-and-graph-api (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Data collection](https://millionrounds.com/workflows?category=Data+collection#library)

# Optimize Instagram hashtags with OpenAI and Graph API

Started by an event in a connected app, and works across Google Sheets. It hands the judgement calls to OpenAI. 23 steps, 2 branches, 2 loops or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Foptimize-instagram-hashtags-with-openai-and-graph-api)

**23 steps** Large: read it before trusting it with anything live

**2** Branches: places the flow splits

**2** Loops or waits

**1** Service it connects to

## The flow

Starts it 2 Model 4 Logic 13 Service 4

The steps in the order they run, from what starts it.

- 1 **Manual Trigger** Manual trigger *Starts it*
- 2 **OpenAI Chat Model** Lm Chat Open Ai *Model*
- 3 **AI Model Selector** Lm Chat Open Ai *Model*
- 4 **Workflow Trigger** Execute Workflow trigger *Starts it*
- 5 **Set Dummy Caption** Set *Logic*
- 6 **Generate Initial Hashtags** Chain Llm *Model*
- 7 **Select Top 5 Hashtags** Chain Llm *Model*
- 8 **Fetch Cached Hashtags** Google Sheets *Service*
- 9 **Parse & Clean Tags** Code *Logic*
- 10 **Format Output** Set *Logic*
- 11 **Merge Input** Merge *Logic*
- 12 **Check Cache Status** Code *Logic*
- 13 **Route Cached vs New** If *Logic*
- 14 **Merge Cache & Fresh** Merge *Logic*
- 15 **Split In Batches** Split In Batches *Logic*
- 16 **Aggregate & Rank Candidates** Code *Logic*
- 17 **Get Hashtag Info** Facebook Graph Api *Service*
- 18 **Check if Tag Exists** If *Logic*
- 19 **Rate Limit Wait** Wait *Logic*
- 20 **Get Hashtag Metrics** Facebook Graph Api *Service*
- 21 **Calculate Average Metrics** Code *Logic*
- 22 **Format New Hashtag Data** Set *Logic*
- 23 **Save to Cache** Google Sheets *Service*

## How it's built

- **Starts on:** An event in a connected app
- **Steps:** 23, with 2 branches, 2 loops or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Google Sheets
- **Model:** OpenAI

## Questions

What does it need to run?

An n8n account, plus your own Google Sheets account, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an event in a connected app.

Does it use AI?

Yes. It calls OpenAI. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 23 steps it is large: read it before trusting it with anything live.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 23 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Foptimize-instagram-hashtags-with-openai-and-graph-api)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Google Sheets](https://millionrounds.com/workflows?service=Google+Sheets#library)

## Workflows like it

Also data collection, with the same services where possible, closest in size first.

- [**Analyze Amazon review friction and revenue impact** 23 steps · calls a model · Google Sheets](https://millionrounds.com/workflow/analyze-amazon-review-friction-and-revenue-impact)
- [**Extracts and organizes academic publications with OpenAI** 23 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/extracts-and-organizes-academic-publications-with-openai)
- [**Log meal nutrition from LINE food photos to Google Sheets** 23 steps · calls a model · Google Sheets](https://millionrounds.com/workflow/log-meal-nutrition-from-line-food-photos-to-google-sheets)
- [**Track menu cost ratios from delivery-note photos with Gemini** 23 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/track-menu-cost-ratios-from-delivery-note-photos-with-gemini)
- [**Manage client onboarding and project handoff** 23 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/manage-client-onboarding-and-project-handoff)
- [**Track customer email commitments with Gmail and OpenRouter** 23 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/track-customer-email-commitments-with-gmail-and-openrouter)
