Automation library · Data collection

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.

LargeCalls a model: OpenAI

23 stepsLarge: read it before trusting it with anything live
2Branches: places the flow splits
2Loops or waits
1Service it connects to

The flow

Starts it 2Model 4Logic 13Service 4

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

  1. 1Manual TriggerManual triggerStarts it
  2. 2OpenAI Chat ModelLm Chat Open AiModel
  3. 3AI Model SelectorLm Chat Open AiModel
  4. 4Workflow TriggerExecute Workflow triggerStarts it
  5. 5Set Dummy CaptionSetLogic
  6. 6Generate Initial HashtagsChain LlmModel
  7. 7Select Top 5 HashtagsChain LlmModel
  8. 8Fetch Cached HashtagsGoogle SheetsService
  9. 9Parse & Clean TagsCodeLogic
  10. 10Format OutputSetLogic
  11. 11Merge InputMergeLogic
  12. 12Check Cache StatusCodeLogic
  13. 13Route Cached vs NewIfLogic
  14. 14Merge Cache & FreshMergeLogic
  15. 15Split In BatchesSplit In BatchesLogic
  16. 16Aggregate & Rank CandidatesCodeLogic
  17. 17Get Hashtag InfoFacebook Graph ApiService
  18. 18Check if Tag ExistsIfLogic
  19. 19Rate Limit WaitWaitLogic
  20. 20Get Hashtag MetricsFacebook Graph ApiService
  21. 21Calculate Average MetricsCodeLogic
  22. 22Format New Hashtag DataSetLogic
  23. 23Save to CacheGoogle SheetsService

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.