{
  "id": "KPZVe958MUDKpdb5",
  "name": "Generate audio documentaries from web articles with ElevenLabs & BrowserAct",
  "tags": [],
  "nodes": [
    {
      "id": "09cea8e1-cb2e-4e89-ade5-f116d826d3a8",
      "name": "Convert text to speech",
      "type": "@elevenlabs/n8n-nodes-elevenlabs.elevenLabs",
      "position": [
        1184,
        96
      ],
      "parameters": {
        "text": "={{ $json.output[0].elevenlabtext }}",
        "voice": {
          "__rl": true,
          "mode": "list",
          "value": "TX3LPaxmHKxFdv7VOQHJ",
          "cachedResultName": "Liam - Energetic, Social Media Creator"
        },
        "resource": "speech",
        "requestOptions": {},
        "additionalOptions": {
          "model": {
            "__rl": true,
            "mode": "list",
            "value": "eleven_flash_v2_5",
            "cachedResultName": "Eleven Flash v2.5"
          },
          "languageCode": "en"
        }
      },
      "credentials": {
        "elevenLabsApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1b93468c-ef4b-4acf-a641-b7f0cf3fcfe9",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -352,
        272
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "{\"Type\": \"Article_Request\", \"Link\": \"extracted_link\"}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "17590514-6226-4d8e-a5f7-3c59c047f1a0",
      "name": "Validate user Input",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -448,
        96
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "You are an input classification engine. Your sole purpose is to analyze user text and output a JSON object based on specific criteria. Do not generate conversational text; only output the raw JSON.\n\nRules for Classification (evaluated in order of priority):\n\n1. ARTICLE & LINK PROCESSING (Priority 1):\n   If the user asks to generate, summarize, or read an article, blog post, or specific content (e.g., \"Summarize this page,\" \"Write an article based on this link,\" \"Analyze this\").\n   - CRITICAL CHECK: Does the input contain a valid URL or web link?\n     - IF YES (Link is present):\n       - Set \"Type\" to \"Article_Request\".\n       - Extract the URL as \"Link\".\n       - Output format: {\"Type\": \"Article_Request\", \"Link\": \"extracted_link\"}\n     \n     - IF NO (Link is missing):\n       - Treat this strictly as \"NoData\".\n       - Output format: {\"Type\": \"NoData\", \"Link\": \"Null\"}\n\n2. REGULAR CHAT (Priority 2):\n   If the user input is a greeting, small talk, or general conversational filler (e.g., \"Hello,\" \"How are you?\", \"Tell me a joke\") without asking for link processing.\n   - Output format: {\"Type\": \"Chat\", \"Link\": \"Null\"}\n\n3. INSUFFICIENT DATA (Priority 3):\n   If the user input is gibberish, vague, or if it matched the \"Article\" intent but lacked a link (as per Rule 1).\n   - Output format: {\"Type\": \"NoData\", \"Link\": \"Null\"}\n\nOutput Constraint:\nReturn ONLY the raw JSON object. Do not wrap it in markdown code blocks. Do not add explanations."
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    },
    {
      "id": "9db82843-ee96-4987-93af-c44f354d1cd8",
      "name": "OpenRouter",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        512,
        128
      ],
      "parameters": {
        "model": "anthropic/claude-haiku-4.5",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8c1ba184-4f91-468e-941b-15b77dd1e0bf",
      "name": "Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        224,
        736
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "bcc683cf-73de-47eb-ae20-cbaa7cdef94f",
      "name": "Google Gemini1",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -464,
        288
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1b308edc-7dc8-402c-8365-1378c685cc13",
      "name": "Structured Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        640,
        144
      ],
      "parameters": {
        "autoFix": true,
        "jsonSchemaExample": "[{\"elevenlabtext\": \"...\", \"Telegram\": \"...\", \"Audioname\": \"...\"}]"
      },
      "typeVersion": 1.3
    },
    {
      "id": "44cc33ff-dffd-4253-88ff-88a1e55831c5",
      "name": "Notify User",
      "type": "n8n-nodes-base.telegram",
      "position": [
        224,
        -192
      ],
      "parameters": {
        "text": "=Understood. Please give me a moment to complete that.",
        "chatId": "=parameters.chatId=={{ $('User Sends Message to Bot').item.json.message.chat.id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c57ddf8a-2d5f-45d1-bac9-a27882d9f445",
      "name": "Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        -560
      ],
      "parameters": {
        "width": 380,
        "height": 516,
        "content": "## \u26a1 Workflow Overview & Setup\n\n**Summary:** This automation converts web articles sent via Telegram into engaging audio documentaries by scraping text with BrowserAct, rewriting it into a narrative script with AI, and generating voiceovers via ElevenLabs.\n\n### Requirements\n* **Credentials:** Telegram, BrowserAct, Google Gemini, OpenRouter (Claude), ElevenLabs.\n* **Mandatory:** BrowserAct API (Template: **AI Summarization & Eleven Labs Podcast Generation**)\n\n### How to Use\n1. **Credentials:** Set up all required service credentials in n8n.\n2. **BrowserAct Template:** Ensure you have the **AI Summarization & Eleven Labs Podcast Generation** template saved in your BrowserAct account.\n3. **Usage:** Send any article URL to the connected Telegram bot to receive an audio summary.\n\n### Need Help?\n[How to Find Your BrowserAct 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": "6e886a42-49d0-40a1-9127-3c195237a811",
      "name": "Step 1 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 664,
        "height": 156,
        "content": "### \ud83e\udde0 Step 1: Intent Recognition\n\nThe system analyzes incoming Telegram messages to distinguish between general conversation and content requests. If a valid URL is detected, it routes the process to the extraction flow; otherwise, it handles the input as a standard chat interaction."
      },
      "typeVersion": 1
    },
    {
      "id": "f9db7f9e-b335-4259-99cb-72d2f825e0ec",
      "name": "Step 2 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        -352
      ],
      "parameters": {
        "color": 7,
        "width": 688,
        "height": 148,
        "content": "### \u270d\ufe0f Step 2: Scraping & Scripting\n\nBrowserAct extract the full text from the provided link. An AI agent then transforming raw research data into an emotional, high-stakes audio documentary script, while also generating a formatted Telegram caption and filename."
      },
      "typeVersion": 1
    },
    {
      "id": "6c20f625-a10f-426f-aace-046c51335a4a",
      "name": "Step 3 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1152,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 584,
        "height": 140,
        "content": "### \ud83c\udf99\ufe0f Step 3: Production & Delivery\n\nThe generated script is sent to ElevenLabs to create a voiceover. The final file is then uploaded to Telegram, accompanied by the AI-generated caption."
      },
      "typeVersion": 1
    },
    {
      "id": "841a630e-6ffa-43f7-937b-b7749416957e",
      "name": "Step 4 Explanation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        400
      ],
      "parameters": {
        "color": 7,
        "width": 564,
        "height": 136,
        "content": "### \ud83d\udcac Step 2-2: Conversational Fallback\n\nIf no link is present in the user's message, this branch engages the user in natural conversation or prompts them to provide a URL for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "a275592a-8599-4eb2-ba73-76a16b2327f3",
      "name": "User Sends Message to Bot",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -656,
        96
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "714420d7-0c71-48ac-aaf6-9329db72f945",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -560
      ],
      "parameters": {
        "color": 6,
        "width": 624,
        "height": 368,
        "content": "@[youtube](YuxjfB87F0E)"
      },
      "typeVersion": 1
    },
    {
      "id": "d3c731e7-e1bc-4489-a6f6-873f5b6552c2",
      "name": "Get Article Data from BrowserAct",
      "type": "n8n-nodes-browseract.browserAct",
      "position": [
        224,
        -48
      ],
      "parameters": {
        "type": "WORKFLOW",
        "timeout": 7200,
        "workflowId": "69338962262095598",
        "workflowConfig": {
          "value": {
            "input-Target_link": "={{ $json.output.Link }}"
          },
          "schema": [
            {
              "id": "input-Target_link",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "description": "If left blank, the default value defined in BrowserAct will be used.",
              "displayName": "Target_link",
              "defaultMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "input-Target_link"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "open_incognito_mode": false
      },
      "credentials": {
        "browserActApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "96de8726-e5f5-4217-a2e5-568a1ce8f42e",
      "name": "Check For Input Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        -96,
        80
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9e003f66-d011-459a-a313-b603c0e14551",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.Type }}",
                    "rightValue": "Article_Request"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "2ebb24ec-bd32-4e96-a022-93d066fda17f",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.Type }}",
                    "rightValue": "Chat"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 3,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "24d355dd-efec-4946-96fe-3d82f3ee4d71",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.output.Type }}",
                    "rightValue": "NoData"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "fa7912ad-6561-4f84-bd26-d7e9dd19bf78",
      "name": "Chatting With User",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        224,
        576
      ],
      "parameters": {
        "text": "=Input type : {{ $json.output.Type }} | User Input : {{ $('User Sends Message to Bot').item.json.message.text }}",
        "options": {
          "systemMessage": "if the input type is \"Nodata\" ask the user to provide the Link to the article or story.\n\nif the input type is chat, analyze the user input and generate single response\n\nsend the result out as a raw text.\navoid using any tags or notations like ```text ```"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "8d217a0b-2662-4f9b-ab87-d033d9e6adda",
      "name": "Answer the User",
      "type": "n8n-nodes-base.telegram",
      "position": [
        608,
        576
      ],
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "=parameters.chatId=={{ $('User Sends Message to Bot').item.json.message.chat.id }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b71a4ea8-d867-48d9-9bc2-b2fe1437fb9c",
      "name": "Send an audio file To User",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1568,
        96
      ],
      "parameters": {
        "chatId": "=parameters.chatId=={{ $('User Sends Message to Bot').item.json.message.chat.id }}",
        "operation": "sendAudio",
        "binaryData": true,
        "additionalFields": {
          "caption": "={{ $('Write Script for ElevenLabs').first().json.output[0].Telegram }}",
          "fileName": "={{ $('Write Script for ElevenLabs').first().json.output[0].Audioname }}",
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "9e77b86a-4fdb-4116-8e6e-80f0894d675f",
      "name": "Write Script for ElevenLabs",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        512,
        -48
      ],
      "parameters": {
        "text": "=Article or Story Data :  {{ $json.output.string }}",
        "options": {
          "systemMessage": "You are a World-Class Narrative Scriptwriter, Audio Engineer, and Automation Specialist. Your expertise is in converting complex scientific data into emotional, high-stakes audio documentaries optimized for ElevenLabs and Telegram distribution.\n\nObjective: Take the provided raw JSON research data and transform it into a high-production-value experience. You are not just summarizing an article; you are telling a story about the future of human survival and the secret wars happening at a microscopic level.\n\n1. The ElevenLabs Audio Script (elevenlabtext)\n\nThe Narrative Arc:\n\nThe Hook: Open with the terrifying reality of the year 2050\u2014where drug-resistant infections claim 10 million lives annually. Establish high stakes immediately.\n\nThe Hero: Introduce the 'Bacteriophage' (or Phage) as the ultimate microscopic hunter.\n\nThe Discovery: Detail the 'PreS' RNA switch. Use vivid metaphors: call it a 'master key', a 'molecular manager', or a 'Trojan Horse' that hijacks the bacterial factory.\n\nThe Mechanism: Describe how the virus unfolds the bacteria's genetic code to force it to replicate the virus.\n\nThe Resolution: Close with a powerful, hopeful vision of how this discovery paves the way for smarter, personalized medicine.\n\nAudio Optimization Cues:\n\nPacing: Use ellipses (...) for 1-second dramatic pauses. Use em-dashes (\u2014) for mid-sentence shifts in emphasis or parenthetical thoughts.\n\nPhonetics: Ensure complex terms are introduced naturally so a listener can follow without a dictionary.\n\nStrict TTS Guardrails:\n\nABSOLUTELY NO MARKDOWN. Do not use **bolding**, ## headers, or * bullet points. ElevenLabs will read these symbols aloud (e.g., saying 'star star'). Use only plain text.\n\nCharacter Count: The script must be between 1,500 and 3,500 characters to ensure deep engagement without exceeding API limits.\n\n2. The Telegram Caption (Telegram)\n\nUser Experience: Design a punchy, professional, and emoji-rich summary for a mobile user.\n\nHTML Formatting: You MUST use valid Telegram HTML tags to make the post look premium. Only use:\n\n<b>Bold for headlines</b>\n\n<i>Italics for scientific terms</i>\n\n<code>Code for the names of molecules like PreS</code>\n\n<a href=\"URL\">Hyperlinks for the source</a>\n\nStructure: Use a '\ud83d\udea8 Headline', a '\ud83e\uddec The Discovery' section, and a '\ud83c\udfa7 Call to Action' (e.g., 'Listen to the audio above').\n\nConstraint: Keep this under 900 characters total to stay safely within Telegram's media caption limit of 1024 characters.\n\n3. The Audio Filename (Audioname)\n\nRequirement: Create a catchy, descriptive filename for the mp3 file.\n\nFormatting: No spaces allowed. Use underscores to separate words.\n\nExample: Superbug_Killer_The_PreS_Switch.mp3\n\nStrict Technical Constraints for JSON Output:\n\nValid JSON Only: Your entire response must be a single, valid JSON array containing one object.\n\nQuote Handling: To prevent breaking the JSON structure, DO NOT use double quotes (\") inside your text values. If you need to use quotes for speech or emphasis, use single quotes (').\n\nNo Filler: Do not include any intro text like \"Here is your JSON.\" Start with [ and end with ].\n\nFinal Output Structure: [{\"elevenlabtext\": \"...\", \"Telegram\": \"...\", \"Audioname\": \"...\"}]"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 3
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1cdc2a42-ce18-412b-8889-c94347f48c5e",
  "connections": {
    "OpenRouter": {
      "ai_languageModel": [
        [
          {
            "node": "Write Script for ElevenLabs",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Structured Output",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini": {
      "ai_languageModel": [
        [
          {
            "node": "Chatting With User",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini1": {
      "ai_languageModel": [
        [
          {
            "node": "Validate user Input",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Structured Output Parser",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Write Script for ElevenLabs",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Chatting With User": {
      "main": [
        [
          {
            "node": "Answer the User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate user Input": {
      "main": [
        [
          {
            "node": "Check For Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check For Input Type": {
      "main": [
        [
          {
            "node": "Notify User",
            "type": "main",
            "index": 0
          },
          {
            "node": "Get Article Data from BrowserAct",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chatting With User",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Chatting With User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert text to speech": {
      "main": [
        [
          {
            "node": "Send an audio file To User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Validate user Input",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "User Sends Message to Bot": {
      "main": [
        [
          {
            "node": "Validate user Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Script for ElevenLabs": {
      "main": [
        [
          {
            "node": "Convert text to speech",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Article Data from BrowserAct": {
      "main": [
        [
          {
            "node": "Write Script for ElevenLabs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}