{
  "id": "IFUOMVnun2Yuo9qx",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Track new box office releases from BrowserAct to Google Sheets & Telegram",
  "tags": [],
  "nodes": [
    {
      "id": "681cc6ce-091f-469b-8163-9c50b2c8f0cc",
      "name": "OpenRouter",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        1520,
        368
      ],
      "parameters": {
        "model": "google/gemini-3-pro-preview",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "521552f2-cc40-4fc3-b15c-054c5a464148",
      "name": "Structured Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1648,
        368
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "[\n  {\n    \"movie_name\": \"Avatar: Fire and Ash\",\n    \"telegram_message_html\": \"<b>Avatar: Fire and Ash</b> \ud83d\udd25\\n\\nThe Na'vi face a new threat: the Ash People.\\n\\n<b>Cast:</b> <i>Sam Worthington, Zoe Salda\u00f1a, Sigourney Weaver</i>\\n<b>Opening:</b> $88,000,000\\n\\n<a href=\\\"[https://imdb.com/](https://imdb.com/)...\\\">\ud83c\udfac Watch Trailer</a>\\n\\n#Avatar #NewMovie\",\n    \"sheet_data\": {\n      \"Name\": \"Avatar: Fire and Ash\",\n      \"Budget\": \"$400,000,000\",\n      \"Opening_Weekend\": \"$88,000,000\",\n      \"Gross_Worldwide\": \"$345,000,000\",\n      \"Cast\": \"Sam Worthington, Zoe Salda\u00f1a...\",\n      \"Link\": \"[https://imdb.com/](https://imdb.com/)...\",\n      \"Summary\": \"Jake and Neytiri's family faces new challenges...\"\n    }\n  }\n]"
      },
      "typeVersion": 1.3
    },
    {
      "id": "b3b36419-5bc7-47fe-81c5-7a7808af78e9",
      "name": "Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -400
      ],
      "parameters": {
        "width": 380,
        "height": 500,
        "content": "## \u26a1 Workflow Overview & Setup\n\n**Summary:** This automation scrapes movie box office data using BrowserAct, filters out duplicates against a Google Sheet, and posts new movie updates to Telegram while archiving data.\n\n### Requirements\n* **Credentials:** BrowserAct, OpenRouter (Google Gemini), Google Sheets, Telegram.\n* **Mandatory:** BrowserAct API (Template: **Box Office Trifecta**)\n\n### How to Use\n1. **Credentials:** Set up all required API keys in n8n.\n2. **BrowserAct Template:** Ensure you have the **Box Office Trifecta** template saved in your BrowserAct account.\n3. **Google Sheet:** Create a sheet named \"Movie history\" with headers: `Name`, `Budget`, `Opening_Weekend`, `Gross_Worldwide`, `Cast`, `Link`, `Summary`.\n\n### Need Help?\n[How to Find Your BrowseAct API Key & Workflow ID](https://docs.browseract.com)\n[How to Connect n8n to Browseract](https://docs.browseract.com)\n[How to Use & Customize BrowserAct Templates](https://docs.browseract.com)"
      },
      "typeVersion": 1
    },
    {
      "id": "8514a550-fcf4-4727-aade-1586d8215bd8",
      "name": "Step 1 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 652,
        "height": 128,
        "content": "### \ud83d\udd75\ufe0f Step 1: Scrape & Retrieve\n\nThis process triggers a BrowserAct scraper to fetch box office data while simultaneously pulling existing records from Google Sheets for data aggregation."
      },
      "typeVersion": 1
    },
    {
      "id": "db9b08c0-5992-4d6f-bbbf-9274cc892022",
      "name": "Step 2 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        -16
      ],
      "parameters": {
        "color": 7,
        "width": 620,
        "height": 128,
        "content": "### \ud83e\udde0 Step 2: AI Processing & Filtering\n\nAn AI agent compares the new scraped data against the existing database to filter out duplicates. It then parses the raw data into structured JSON (extracting budget, cast, etc.) and generates a formatted HTML message for Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "771dfa45-5cda-4a91-a3f2-83f5704c33e5",
      "name": "Step 3 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2112,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 600,
        "height": 124,
        "content": "### \ud83d\udcbe Step 3: Archive & Notify\n\nValid new movie entries are appended to the Google Sheet archive. Finally, the AI-generated HTML update is posted to the designated Telegram channel."
      },
      "typeVersion": 1
    },
    {
      "id": "bc3bf15f-03fb-4f31-9f53-fac2ef0744ff",
      "name": "Retrieve Stored Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        992,
        160
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "specifyRange"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/159A6tH0vMfwE4w9upGD4C-pZB7P8E8-okS3itzuPP-M/edit#gid=0",
          "cachedResultName": "Movie history"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "159A6tH0vMfwE4w9upGD4C-pZB7P8E8-okS3itzuPP-M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/159A6tH0vMfwE4w9upGD4C-pZB7P8E8-okS3itzuPP-M/edit?usp=drivesdk",
          "cachedResultName": "Box Office Trifecta"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7,
      "alwaysOutputData": true
    },
    {
      "id": "4b5c66c3-04f1-48d5-834d-4e89ad8d749e",
      "name": "Extract From IMDB Box Office",
      "type": "n8n-nodes-browseract.browserAct",
      "position": [
        800,
        160
      ],
      "parameters": {
        "type": "WORKFLOW",
        "workflowId": "7+1234567890",
        "workflowConfig": {
          "value": {},
          "schema": [
            {
              "id": "input-BoxOffice",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "description": "If left blank, the default value defined in BrowserAct will be used.",
              "displayName": "BoxOffice",
              "defaultMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "input-BoxOffice"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "open_incognito_mode": false
      },
      "credentials": {
        "browserActApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bb3f0936-97c3-4c53-a592-6aa4738f3568",
      "name": "Run Weekly",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        608,
        160
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "7bb34639-f55a-4ba6-9017-df87a6cf5660",
      "name": "Merge All Data",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1152,
        160
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "23b4a321-dc70-4fbd-96a1-b0950240fe69",
      "name": "Create posts for Telegram",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1520,
        160
      ],
      "parameters": {
        "text": "=Movies Data :   {{ $('Extract From IMDB Box Office').first().json.output.string }},,\nGoogle sheet Data : {{ $json.data }}",
        "options": {
          "systemMessage": "You are an advanced Data Processing and Content Generation Agent for a movie tracking workflow.\n\n**Your Goal:**\nProcess a raw JSON list of incoming movie data (`input_movies`), filter out duplicates found in the provided database (`existing_movies`), and generate formatted outputs for the remaining new movies.\n\n**Inputs provided to you:**\n1. `input_movies`: A JSON list of movie objects.\n2. `existing_movies`: A list/string of movie names already in the Google Sheet.\n\n**Step-by-Step Instructions:**\n\n1.  **Deduplication (Filter):**\n    * Compare the \"Name\" of each movie in `input_movies` against `existing_movies`.\n    * **IF** the name matches (case-insensitive), **DISCARD** it.\n    * **IF** the name is unique, process it as a new movie.\n\n2.  **Process New Movies:**\n    For each valid new movie, generate a JSON object with two keys:\n\n    * **`telegram_message_html`**: Create a post using **Telegram-supported HTML** only (`<b>`, `<i>`, `<a href>`).\n        * **Header:** The Movie Name in `<b>` bold.\n        * **Genre/Vibe:** An emoji and short description.\n        * **Details:** `<i>` for the Cast list (limit to top 3 names).\n        * **Stats:** \"Opening Weekend\" value (if available).\n        * **Call to Action:** A clean HTML hyperlink: `<a href=\"[Link]\">\ud83c\udfac Watch Trailer / View Details</a>`.\n        * **Tags:** Hashtags at the bottom.\n        * *Constraint:* Ensure all HTML tags are closed properly. Do not use Markdown (`**`).\n\n    * **`sheet_data`**: Extract clean data for the Google Sheet.\n        * **Parsing:** Extract \"Budget\", \"Opening Weekend\", and \"Gross Worldwide\" from the \"BoxOffice\" string. Use \"N/A\" if missing.\n        * **Structure:** Return specific keys: Name, Budget, Opening_Weekend, Gross_Worldwide, Cast, Link, Summary.\n\n3.  **Final Output Format:**\n    * Return **ONLY** a single valid JSON array containing the processed objects.\n    * You have 3000 Max char limitation for telegram API.\n    * No conversational text or code block formatting (```json).\n\n**Example Output Structure:**\n[\n  {\n    \"movie_name\": \"Avatar: Fire and Ash\",\n    \"telegram_message_html\": \"<b>Avatar: Fire and Ash</b> \ud83d\udd25\\n\\nThe Na'vi face a new threat: the Ash People.\\n\\n<b>Cast:</b> <i>Sam Worthington, Zoe Salda\u00f1a, Sigourney Weaver</i>\\n<b>Opening:</b> $88,000,000\\n\\n<a href=\\\"[https://imdb.com/](https://imdb.com/)...\\\">\ud83c\udfac Watch Trailer</a>\\n\\n#Avatar #NewMovie\",\n    \"sheet_data\": {\n      \"Name\": \"Avatar: Fire and Ash\",\n      \"Budget\": \"$400,000,000\",\n      \"Opening_Weekend\": \"$88,000,000\",\n      \"Gross_Worldwide\": \"$345,000,000\",\n      \"Cast\": \"Sam Worthington, Zoe Salda\u00f1a...\",\n      \"Link\": \"[https://imdb.com/](https://imdb.com/)...\",\n      \"Summary\": \"Jake and Neytiri's family faces new challenges...\"\n    }\n  }\n]"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "0f587503-9ad4-44e0-8608-a745be9b24ce",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        576,
        -400
      ],
      "parameters": {
        "color": 6,
        "width": 640,
        "height": 368,
        "content": "@[youtube](OFuBm6epqdY)"
      },
      "typeVersion": 1
    },
    {
      "id": "3184e58a-5843-4948-812d-7dc672b7eaca",
      "name": "Split Telegram Post",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2144,
        160
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "83ce6710-7079-472e-9b2a-61eb7f1ef9bc",
      "name": "Store Extracted Data",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2368,
        160
      ],
      "parameters": {
        "columns": {
          "value": {
            "Cast": "={{ $json.sheet_data.Cast }}",
            "Link": "={{ $json.sheet_data.Link }}",
            "Budget": "={{ $json.sheet_data.Budget }}",
            "Summary": "={{ $json.sheet_data.Summary }}",
            "movie_name": "={{ $json.sheet_data.Name }}",
            "telegram_post": "={{ $json.telegram_message_html }}",
            "Gross_Worldwide": "={{ $json.sheet_data.Gross_Worldwide }}",
            "Opening_Weekend": "={{ $json.sheet_data.Opening_Weekend }}"
          },
          "schema": [
            {
              "id": "movie_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "movie_name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "telegram_post",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "telegram_post",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Budget",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Budget",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Opening_Weekend",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Opening_Weekend",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Gross_Worldwide",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Gross_Worldwide",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Cast",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Cast",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Link",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Summary",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Summary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/159A6tH0vMfwE4w9upGD4C-pZB7P8E8-okS3itzuPP-M/edit#gid=0",
          "cachedResultName": "Movie history"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "159A6tH0vMfwE4w9upGD4C-pZB7P8E8-okS3itzuPP-M",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/159A6tH0vMfwE4w9upGD4C-pZB7P8E8-okS3itzuPP-M/edit?usp=drivesdk",
          "cachedResultName": "Box Office Trifecta"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "19b529c6-c2fd-48ce-ab35-03957d755632",
      "name": "Send Post to Telegram Channel",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2592,
        160
      ],
      "parameters": {
        "text": "={{ $('Split Telegram Post').first().json.telegram_post }}",
        "chatId": "chatId==\"@Your_Telegram_Channel_ID\"",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7b2b1f63-afc1-425d-835c-8231793d9d98",
  "connections": {
    "OpenRouter": {
      "ai_languageModel": [
        [
          {
            "node": "Create posts for Telegram",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Structured Output",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Run Weekly": {
      "main": [
        [
          {
            "node": "Extract From IMDB Box Office",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Data": {
      "main": [
        [
          {
            "node": "Create posts for Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Create posts for Telegram",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Split Telegram Post": {
      "main": [
        [
          {
            "node": "Store Extracted Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Stored Data": {
      "main": [
        [
          {
            "node": "Merge All Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Extracted Data": {
      "main": [
        [
          {
            "node": "Send Post to Telegram Channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create posts for Telegram": {
      "main": [
        [
          {
            "node": "Split Telegram Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract From IMDB Box Office": {
      "main": [
        [
          {
            "node": "Retrieve Stored Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}