Find Top-Performing Instagram Reels & Save Insights to Notion with Gemini & Apify

⚡ Find Top-Performing Instagram Reels & Save Insights to Notion with Gemini & Apify

This workflow enables social media managers, marketers, and content creators to automatically discover top-performing Instagram Reels, extract engagement insights, and save structured data directly to Notion. By combining Gemini’s AI analytics with Apify’s web automation, users can track trends, benchmark content, and optimize strategies for maximum reach and engagement.

Overview

The system monitors Instagram Reels based on selected hashtags, creators, or niches. Gemini analyzes performance metrics including likes, comments, shares, and growth trends. Apify scrapes this data, structures it, and pushes it to a Notion database, providing an organized dashboard of insights for easy decision-making and content strategy optimization.

Key Features

  • Automatic discovery of trending Instagram Reels by niche or hashtag.
  • AI-powered analysis of engagement metrics with Gemini.
  • Web scraping automation with Apify for structured data extraction.
  • Direct integration with Notion databases for insight storage.
  • Customizable dashboards for tracking performance over time.
  • Supports multi-account monitoring for agencies or large teams.

How It Works

The workflow uses Gemini to detect high-performing Instagram Reels and extract key metrics. Apify automatically scrapes this data and formats it into structured records. These records are then pushed into Notion, where users can view engagement trends, compare content, and make data-driven decisions. Scheduling and automation allow continuous monitoring without manual intervention.

Benefits

  • Track trending content automatically without manual search.
  • Gain insights into top-performing Reels for smarter content strategy.
  • Centralized tracking in Notion for easy reference and reporting.
  • Save time and increase productivity for social media managers.
  • Leverage AI and automation to stay ahead of Instagram trends.

Example Outcomes

• Discover 20–50 trending Reels per day within your target niche.
• Structured insights including likes, comments, shares, and growth metrics in Notion.
• Automated content monitoring with historical trend comparison.
• Smarter content planning and data-driven engagement optimization.


{
  "nodes": [
    {
      "parameters": {},
      "id": "e9aad9c8-d2ad-4e17-93cd-a7faa215a06f",
      "name": "When clicking ‘Execute workflow’",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        1056,
        1120
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "cachedResultName": "Sources"
        },
        "returnAll": true,
        "options": {}
      },
      "id": "81d68000-b6bd-42bf-8335-78e753c1f68e",
      "name": "Get Sources",
      "type": "n8n-nodes-base.notion",
      "position": [
        1488,
        1120
      ],
      "typeVersion": 2.2,
      "credentials": {}
    },
    {
      "parameters": {
        "jsCode": "const variables = {\n  // https://apify.com/apify/instagram-scraper \n  // Instagram Scraper = apify/instagram-scraper, \n  \"scrapingActorId\" : \"shu8hvrXbJbY3Eb9W\", // ID of Apify scraper\n  \"daysLimit\" : 7, // Date limit \n  \"resultsLimit\" : 3, // Results per account\n  \"maxDays\" : 2, // Sleeping || Active\n  \"translationLang\" : \"German\",\n}\n\n\nreturn [{json : variables}]"
      },
      "id": "d59e57be-ae56-4853-aa56-c0839b5fd6c1",
      "name": "Variables",
      "type": "n8n-nodes-base.code",
      "position": [
        1280,
        1120
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "jsCode": "// required Simplify = true\n\nconst query = {\n    \"addParentData\": false,\n    \"directUrls\": [],\n    \"enhanceUserSearchWithFacebookPage\": false,\n    \"isUserReelFeedURL\": false,\n    \"isUserTaggedFeedURL\": false,\n    \"onlyPostsNewerThan\": ($('Variables').first().json.daysLimit ?? 10) + ' days',\n    \"resultsLimit\": $('Variables').first().json.resultsLimit ?? 5,\n    \"resultsType\": \"stories\"\n};\n\nconst urls = [];\nconst map = {};\n\nitems.forEach(item => {\n  const username = item.json.property_username || '';\n  if (username) {\n    urls.push('https://www.instagram.com/' + username + '/');\n    map[username.toLowerCase()] = item.json.id;   // Notion pageId\n  }\n});\n\nquery.directUrls = urls;\n\nreturn [\n  {\n    json: {\n      query,\n      urls,\n      map     \n    }\n  }\n];\n"
      },
      "id": "9dc6b692-015d-4749-bd77-a91cace88f73",
      "name": "Apify Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        1712,
        1120
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "96d0046b-c9ab-429e-b35c-3d7518564c1b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "SUCCEEDED"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Done"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "5b1c311d-10cf-4e6f-a55c-f311c75ef444",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Get Status').item.json.status }}",
                    "rightValue": "RUNNING"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Running"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "8376a12a-87c9-4878-b654-1c91fdfb31a2",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Get Status').item.json.status }}",
                    "rightValue": "READY"
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Ready"
            }
          ]
        },
        "options": {}
      },
      "id": "70cb78f1-bbc9-4dca-91a6-3d54444689ec",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        2368,
        1072
      ],
      "typeVersion": 3.2
    },
    {
      "parameters": {
        "amount": 1,
        "unit": "minutes"
      },
      "id": "43b693cd-9c70-4b2c-a30b-9ec3d01fe809",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        2592,
        1232
      ],
      "webhookId": "6a6311dc-42d5-4329-93a2-ccd76057b31d",
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "limit": null,
        "resource": "Datasets",
        "datasetId": "={{ $json.defaultDatasetId }}",
        "operation": "Get items"
      },
      "id": "8114cefb-bf4e-4ccd-9d27-b5858bfa4ca9",
      "name": "Get dataset items",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        2592,
        1008
      ],
      "typeVersion": 1,
      "credentials": {}
    },
    {
      "parameters": {
        "runId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "resource": "Actor runs",
        "operation": "Get run"
      },
      "id": "2045d552-7cc9-4670-8729-faec32a2bb49",
      "name": "Get Status",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        2160,
        1120
      ],
      "typeVersion": 1,
      "credentials": {}
    },
    {
      "parameters": {
        "actorId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Variables').first().json.scrapingActorId }}"
        },
        "operation": "Run actor",
        "customBody": "={{ $json.query.toJsonString() }}",
        "actorSource": "store"
      },
      "id": "e3288a62-aae7-4b7d-9081-63daac01219a",
      "name": "Run an Actor",
      "type": "@apify/n8n-nodes-apify.apify",
      "position": [
        1936,
        1120
      ],
      "typeVersion": 1,
      "credentials": {}
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "update",
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.notionPageId }}"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Status|select",
              "selectValue": "={{ $json.publishingStatus }}"
            },
            {
              "key": "Title|title",
              "title": "={{ $json.ownerFullName }}"
            },
            {
              "key": "URL|url",
              "urlValue": "={{ $json.inputUrl }}"
            }
          ]
        },
        "options": {}
      },
      "id": "cb8d08e4-d245-4f6f-a5e3-98860dc4e04d",
      "name": "Update Accounts",
      "type": "n8n-nodes-base.notion",
      "position": [
        3248,
        1008
      ],
      "typeVersion": 2,
      "credentials": {}
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "getAll",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "cachedResultName": "Reels"
        },
        "returnAll": true,
        "filterType": "manual",
        "filters": {
          "conditions": [
            {
              "key": "Date|date",
              "condition": "after",
              "date": "={{ new Date(Date.now() - $('Variables').first().json.daysLimit * 24 * 60 * 60 * 1000).toISOString().split('T')[0] }}"
            }
          ]
        },
        "options": {}
      },
      "id": "950f0ac1-11d9-4673-b751-feea0b623dc9",
      "name": "Get Reels",
      "type": "n8n-nodes-base.notion",
      "position": [
        3696,
        1008
      ],
      "executeOnce": false,
      "typeVersion": 2.2,
      "alwaysOutputData": true,
      "credentials": {}
    },
    {
      "parameters": {
        "jsCode": "const accountsMap = {};\n\nitems.forEach(item => {\n  const username = item.json.property_username || '';\n  if (username) {\n    accountsMap[username.toLowerCase()] = item.json.id;   // Notion pageId\n  }\n});\n\nreturn [\n  {\n    json: {\n      accountsMap,\n      items\n    }\n  }\n];\n"
      },
      "id": "52d274fb-3b99-48c7-8338-83ed7537568e",
      "name": "Many to One",
      "type": "n8n-nodes-base.code",
      "position": [
        3472,
        1008
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "jsCode": "const existingPages = {};\nfor (const page of $items('Get Reels')) {\n  const source = page.json.property_url ?? '';\n  if (source) existingPages[source] = page.json;\n}\n\nconst output = [];\nconst accountsMap = $('Many to One').first().json.accountsMap;\n\nfor (const reel of $items('Map Reels')) {\n\n  const source   = reel.json.url;          \n\n  const views = reel.json.videoViewCount;\n  var update = {\n    \"Code\": reel.json.shortCode,\n    \"SignedCode\": reel.json.shortCode + '-' + Math.random(),\n    \"IsCreated\" : false,\n    \"notionAccountPageId\" : accountsMap[ reel.json.ownerUsername.toLowerCase() ],\n          \"Views\"       : views ? views : reel.json.videoPlayCount,\n          \"Likes\"       : reel.json.likesCount,\n          \"Comments\"    : reel.json.commentsCount,\n          \"Saves\"       : reel.json.savesCount ?? 0,\n          \"Shares\"      : reel.json.sharesCount ?? 0,\n          \"Updated\"   : new Date().toISOString()\n  };\n\n  /* ------------------------------------------------- */\n  if (existingPages[source]) {\n    \n    update.notionPageId = existingPages[source].id;\n\n  } else {\n    update['IsCreated'] = true;\n    update['Caption'] = reel.json.caption;\n    update['URL'] = reel.json.url;\n    update['Hashtags'] = reel.json.hashtags.join(', ');\n    update['Duration'] = reel.json.videoDuration;\n    update['Date'] = reel.json.timestamp;\n    update['videoUrl'] = reel.json.videoUrl;\n    \n  }\n\n  output.push({json: update});\n}\n\nreturn output;   // n8n continues with one array containing both kinds of items\n"
      },
      "id": "6e9b25fe-e3ce-4cd4-91f6-4accd65f532b",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        3920,
        1008
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "jsCode": "const maxDays = $('Variables').first()?.json?.maxDays ?? 3;  \nconst now     = new Date();\n\n\nvar results = items;                             \nconst map   = $('Apify Payload').first().json.map;\n\n\nconst acctStatus = {};   // { username: 'Active' | 'Sleeping' }\n\nfor (const itm of results) {\n  const owner = itm.json.ownerUsername.toLowerCase();\n  const ts    = new Date(itm.json.timestamp);\n  const diff  = (now - ts) / 86_400_000;    \n\n  \n  if (!acctStatus[owner] || acctStatus[owner] === 'Sleeping') {\n    acctStatus[owner] = diff <= maxDays ? 'Active' : 'Sleeping';\n  }\n}\n\nfor (const k in results) {\n  const item   = results[k];\n  const owner  = item.json.ownerUsername.toLowerCase();\n\n  // coauthorProducers - !notionPageId\n  item.json.notionPageId     = map[owner];\n  item.json.publishingStatus = acctStatus[owner];\n\n  results[k] = item;\n}\n\nreturn results;\n"
      },
      "id": "242b65f6-a180-4795-b18f-c0b3278dbc3d",
      "name": "Map Reels",
      "type": "n8n-nodes-base.code",
      "position": [
        2816,
        1008
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "list",
          "cachedResultName": "Reels"
        },
        "title": "={{ ($json.response.hook ?? $json.Caption).substring(0, 50) }}",
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Date|date",
              "date": "={{ $json.Date }}"
            },
            {
              "key": "Caption|rich_text",
              "textContent": "={{ $json.Caption.substring(0, 1995) }}"
            },
            {
              "key": "Duration|number",
              "numberValue": "={{ $json.Duration }}"
            },
            {
              "key": "Likes|number",
              "numberValue": "={{ $json.Likes }}"
            },
            {
              "key": "Parsed Date|date",
              "date": "={{ $now }}"
            },
            {
              "key": "URL|url",
              "urlValue": "={{ $json.URL }}"
            },
            {
              "key": "Views|number",
              "numberValue": "={{ $json.Views }}"
            },
            {
              "key": "Comments|number",
              "numberValue": "={{ $json.Comments }}"
            },
            {
              "key": "Author|relation",
              "relationValue": [
                "={{ $json.notionAccountPageId }}"
              ]
            },
            {
              "key": "Content|rich_text",
              "textContent": "=### HOOK ###\n{{ $json.response.hook }}\n\n### CONTENT ###\n{{ $json.response.transcription.substring(0, 1800) }}"
            },
            {
              "key": "Translation|rich_text",
              "textContent": "=### HOOK ###\n{{ $json.response.translation_hook }}\n\n### CONTENT ###\n{{ $json.response.translation.substring(0, 1800) }}"
            },
            {
              "key": "Type|select",
              "selectValue": "={{ $json.response.format }}"
            },
            {
              "key": "Category|select",
              "selectValue": "={{ $json.response.category }}"
            }
          ]
        },
        "options": {}
      },
      "id": "f6ce6734-6bbf-451b-bc8b-e73fcad9eaac",
      "name": "Create",
      "type": "n8n-nodes-base.notion",
      "position": [
        3488,
        1824
      ],
      "typeVersion": 2.2,
      "credentials": {},
      "onError": "continueRegularOutput"
    },
    {
      "parameters": {
        "resource": "databasePage",
        "operation": "update",
        "pageId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.notionPageId }}"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Comments|number",
              "numberValue": "={{ $json.Comments }}"
            },
            {
              "key": "Likes|number",
              "numberValue": "={{ $json.Likes }}"
            },
            {
              "key": "Views|number",
              "numberValue": "={{ $json.Views }}"
            }
          ]
        },
        "options": {}
      },
      "id": "4f840157-aa84-4e1d-bc01-743b2846e733",
      "name": "Update",
      "type": "n8n-nodes-base.notion",
      "position": [
        1760,
        2080
      ],
      "typeVersion": 2.2,
      "credentials": {}
    },
    {
      "parameters": {
        "url": "={{ $json.videoUrl }}",
        "options": {}
      },
      "id": "3cf91952-47b1-4bd9-9b3d-95a0b847a4cc",
      "name": "Download Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1728,
        1680
      ],
      "typeVersion": 4.2
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://generativelanguage.googleapis.com/upload/v1beta/files",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi",
        "sendBody": true,
        "contentType": "binaryData",
        "inputDataFieldName": "data",
        "options": {}
      },
      "id": "4afd4b50-bb64-4135-9d7a-b4e2da533370",
      "name": "Upload to Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1952,
        1680
      ],
      "typeVersion": 4.2,
      "credentials": {}
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n\t\"contents\": [{\n\t\t\"parts\": [{\n\t\t\t\"file_data\": {\n\t\t\t\t\"file_uri\": \"{{ $('Is Uploaded And Active?').item.json.uri }}\",\n\t\t\t\t\"mime_type\": \"{{ $('Is Uploaded And Active?').item.json.mimeType }}\"\n\t\t\t}\n\t\t}, {\n\t\t\t\"text\": \"{{ $('Set Prompt').first().json.AnalyzePrompt.replaceAll(\"\\n\", '\\\\n').replaceAll('\"', '\\\"\"') }}\"\n\t\t}]\n\t}]\n}",
        "options": {}
      },
      "id": "be95f2a7-fd68-472d-b1e9-e7f47e16f61d",
      "name": "Gemini Analyze",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3056,
        1680
      ],
      "typeVersion": 4.2,
      "credentials": {}
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "8cf67b24-2993-4aed-be9d-00b88a1c5701",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.state }}",
              "rightValue": "ACTIVE"
            }
          ]
        },
        "options": {}
      },
      "id": "d8a3b6c8-dfab-4d12-ac66-dacf23c379f5",
      "name": "Is Uploaded And Active?",
      "type": "n8n-nodes-base.if",
      "position": [
        2608,
        1680
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "url": "={{ $json.file.uri }}",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googlePalmApi",
        "options": {}
      },
      "id": "849c07c0-c0c9-42bf-94a7-0bb794a8bbdc",
      "name": "Get File State",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2400,
        1632
      ],
      "typeVersion": 4.2,
      "credentials": {}
    },
    {
      "parameters": {
        "amount": 1,
        "unit": "minutes"
      },
      "id": "bd77d983-4f7a-4330-b461-dd0ebc6223e8",
      "name": "Processing Delay",
      "type": "n8n-nodes-base.wait",
      "position": [
        2176,
        1680
      ],
      "webhookId": "3df7acce-81fc-4341-a091-fa1427977cb4",
      "typeVersion": 1.1
    },
    {
      "parameters": {
        "jsCode": "\nconst rawText = $input.first().json.candidates[0].content.parts[0].text;\n\nconst cleaned = rawText\n  .replace(/^```json\\s*/, '')      \n  .replace(/\\s*```$/, '')          \n  .trim();\n\nlet parsed;\ntry {\n  parsed = JSON.parse(cleaned);\n} catch (e) {\n  return [{ json: { error: 'Invalid JSON', message: e.message } }];\n}\n\nlet item = $('Is Created?').first().json;\n\nparsed.transcription = parsed.transcription ?? '';\nparsed.hook = parsed.hook ?? '';\nparsed.category = parsed.category ?? '';\nparsed.format = parsed.format ?? '';\nparsed.translation = parsed.translation ?? '';\nparsed.translation_hook = parsed.translation_hook ?? '';\n\nitem.response = parsed;\n\n\nreturn [{ json: item }];\n"
      },
      "id": "36dce35b-d983-4a45-9617-ac1254f5c77c",
      "name": "Format Response",
      "type": "n8n-nodes-base.code",
      "position": [
        3280,
        1680
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "01c3ca92-795f-4528-8df5-204c324c352b",
              "name": "AnalyzePrompt",
              "type": "string",
              "value": "=Perform the following tasks based on the video/audio content:\n\n1. Create a full transcription of the audio — convert speech to text exactly as spoken, without interpretation or summarization, so it can be easily read or re-voiced later.\n\n2. Identify a strong hook from the first few seconds of the content that can grab attention.\n\n3. Determine the category of the content using the following rules:\n- Business: if the video shares business advice\n- Marketing: if the video shares marketing advice\n- Cooking: if the video shares cooking advice\n- Interview: if the video is an interview with a guest\n- Unknown: if the category cannot be determined\n\n4. Identify the video format using the following options:\n- Head: if it's a talking-head video\n- Animation: if it's animated or presented with drawings\n- Unknown: if the format is unclear\n\n5. Translate the full transcription and the hook into {{ $('Variables').first().json.translationLang }}.\n\nReturn the result in **pure JSON format** with the following fields:  \n`transcription`, `hook`, `category`, `format`, `translation`, `translation_hook`.\n\n**Do not include any commentary or explanations. Only return the JSON.**"
            }
          ]
        },
        "options": {}
      },
      "id": "913daa8b-e3c5-48d9-8f1c-16746a847564",
      "name": "Set Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        2848,
        1712
      ],
      "typeVersion": 3.4
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7b88be8b-60c6-47b1-8a6a-4f5b97d71234",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.notionPageId }}",
              "rightValue": ""
            }
          ]
        },
        "options": {}
      },
      "id": "f623358c-c051-4cf6-9922-1cbf1f944d7b",
      "name": "Owner?",
      "type": "n8n-nodes-base.if",
      "position": [
        3040,
        1008
      ],
      "typeVersion": 2.2
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "bed205cb-cc58-4f99-af5e-7565257ea7c4",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.IsCreated && $json.notionAccountPageId != null }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Create"
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "042c2e67-6f4d-4909-a73d-eb43864203dd",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ !$json.IsCreated && $json.notionAccountPageId != null }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true,
              "outputKey": "Update"
            }
          ]
        },
        "options": {}
      },
      "id": "6ef695e9-6e2d-4bea-bfb8-ba559e6a803e",
      "name": "Is Created?",
      "type": "n8n-nodes-base.switch",
      "position": [
        1520,
        1760
      ],
      "typeVersion": 3.2
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "5b97e7c8-9637-4763-ad8c-53a086ddc8fd",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1296,
        1872
      ],
      "typeVersion": 3
    },
    {
      "parameters": {
        "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nfor (const item of $input.all()) {\n  item.json.myNewField = 1;\n}\n\nreturn $input.all();"
      },
      "id": "635e329a-dda0-40d6-96d1-e7b384ec841b",
      "name": "Stats",
      "type": "n8n-nodes-base.code",
      "position": [
        1520,
        1568
      ],
      "typeVersion": 2
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 4
            }
          ]
        }
      },
      "id": "261dc20e-b593-440b-b002-f6d1cbfbfcc0",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        1056,
        912
      ],
      "typeVersion": 1.2
    },
    {
      "parameters": {
        "content": "### šŸ“ŗ How It Works – Watch the Video  \nI've recorded a video walkthrough to show you how the system works in detail.\nšŸ‘‰ [https://www.youtube.com/watch?v=rdfRNHpHX8o](https://www.youtube.com/watch?v=rdfRNHpHX8o)\n\n\n### šŸ“„ Download Notion Database Structure  \nYou can download the Notion table structure (with all required columns and formats) here:  \nšŸ‘‰ [https://drive.google.com/file/d/1FVaS_-ztp6PDAJbETUb1dkg8IqE4qHqp/view?usp=sharing](https://drive.google.com/file/d/1FVaS_-ztp6PDAJbETUb1dkg8IqE4qHqp/view?usp=sharing)\n\n### ☕ Support the Project  \nIf you'd like to support my work, there's a version with tips available here:\nšŸ‘‰ [Coffee + Sandwich Version](https://gr.egrnkvch.com/l/InstagramReelsTrendWatcher)\n",
        "height": 360,
        "width": 520,
        "color": 7
      },
      "id": "5d8a6022-16bc-4211-b596-089655921209",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        240
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "## ⚙️ How to Install the Template\n\n1. **Create the databases in Notion.**  \n   Make sure to use the exact column names and formats as shown in the provided structure.\n\n2. **Import the workflow template into n8n.**\n\n3. **Add your Credentials:**\n   - **Notion**: Standard Notion integration  \n   - **Apify**: Create and connect your Apify API key\n\n4. **Gemini API is used via HTTP Request node.**  \n   Use the following settings:  \n   - `Authentication`: **Predefined Credential Type**  \n   - `Credential Type`: **Google Gemini (PaLM) API**  \n   - `Host`: `https://generativelanguage.googleapis.com`  \n   - API key: your personal Gemini API key\n\n5. **Assign these credentials** in the corresponding nodes inside the workflow.\n\n6. **Configure the Variables node** to set parsing parameters.  \n   Test the process with 3–5 accounts, each with 3–5 Reels.  \n   Once everything works, update the Variables with your full settings.\n",
        "height": 580,
        "width": 520,
        "color": 7
      },
      "id": "b7c81e9f-5d71-4ce1-b6b0-585245e0eb90",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        240
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "### šŸ“ŗ Video Guide\nšŸ‘‰ [https://www.youtube.com/watch?v=rdfRNHpHX8o](https://www.youtube.com/watch?v=rdfRNHpHX8o)\n\n@[youtube](rdfRNHpHX8o)",
        "height": 140,
        "width": 520,
        "color": 7
      },
      "id": "af4c205f-6a9c-493f-861d-bda18d346cf5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        672
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "Database = Sources",
        "height": 80,
        "width": 180
      },
      "id": "5acb33a7-5bc2-439f-a648-450fe97073eb",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        1024
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "Database = Reels",
        "height": 80,
        "width": 180
      },
      "id": "aa226eb7-84f5-41cc-87dd-a18d163ddf8b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3648,
        880
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "Database = Reels",
        "height": 80,
        "width": 180
      },
      "id": "4efaf2ee-ef7a-4f72-88cc-12eae7210b1b",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3472,
        1728
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "content": "This is the prompt used to process video content and classify its category and type. Customize it based on your logic.",
        "height": 100,
        "width": 300
      },
      "id": "c641b324-a620-4cf8-a8ec-1b821b942425",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2768,
        1552
      ],
      "typeVersion": 1
    }
  ],
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Sources": {
      "main": [
        [
          {
            "node": "Apify Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Variables": {
      "main": [
        [
          {
            "node": "Get Sources",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apify Payload": {
      "main": [
        [
          {
            "node": "Run an Actor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [
          {
            "node": "Get dataset items",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get dataset items": {
      "main": [
        [
          {
            "node": "Map Reels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Status": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run an Actor": {
      "main": [
        [
          {
            "node": "Get Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Accounts": {
      "main": [
        [
          {
            "node": "Many to One",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Reels": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Many to One": {
      "main": [
        [
          {
            "node": "Get Reels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Reels": {
      "main": [
        [
          {
            "node": "Owner?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Update": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Video": {
      "main": [
        [
          {
            "node": "Upload to Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Gemini": {
      "main": [
        [
          {
            "node": "Processing Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini Analyze": {
      "main": [
        [
          {
            "node": "Format Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Uploaded And Active?": {
      "main": [
        [
          {
            "node": "Set Prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Processing Delay",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File State": {
      "main": [
        [
          {
            "node": "Is Uploaded And Active?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Processing Delay": {
      "main": [
        [
          {
            "node": "Get File State",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Response": {
      "main": [
        [
          {
            "node": "Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Prompt": {
      "main": [
        [
          {
            "node": "Gemini Analyze",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Owner?": {
      "main": [
        [
          {
            "node": "Update Accounts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Created?": {
      "main": [
        [
          {
            "node": "Download Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Stats",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Is Created?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        []
      ]
    }
  },
  "pinData": {},
  "meta": {
    "instanceId": "75abd48bc57d25714aa960bb88d4b2adecc422dfb024e5b5e89c730044230c39"
  }
}
    

Comments