{
  "name": "Telegram channel monitor: new posts to Slack (Apify node)",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      },
      "id": "dae32202-7d37-44cd-9168-10f5b16d8f45",
      "name": "Every hour",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [0, 0]
    },
    {
      "parameters": {
        "resource": "Actors",
        "operation": "Run actor and get dataset",
        "actorId": {
          "__rl": true,
          "value": "SnsRmhv8v6cFTcLe4",
          "mode": "id"
        },
        "actorInputMode": "json",
        "customBody": "{\n  \"channels\": [\"telegram\", \"durov\"],\n  \"maxPostsPerChannel\": 50,\n  \"onlyNewPosts\": true,\n  \"monitorName\": \"n8n-telegram-to-slack\",\n  \"includeChannelInfo\": false\n}",
        "timeout": 600,
        "memory": 512,
        "maxTotalChargeUsd": 0.1,
        "authentication": "apifyApi"
      },
      "id": "4389c599-516f-4431-884e-1ee2572c75df",
      "name": "Run Telegram Channel Scraper",
      "type": "@apify/n8n-nodes-apify.apify",
      "typeVersion": 1,
      "position": [240, 0]
    },
    {
      "parameters": {
        "jsCode": "// Keep only readable post rows; channel and diagnostic rows are dropped.\n// Escape &, < and > so post text cannot trigger Slack mentions (<!channel>, <@U...>) or fake links.\nconst esc = s => String(s ?? '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\nreturn $input.all()\n  .filter(item => item.json.type === 'post' && item.json.status === 'ok')\n  .map(item => ({\n    json: {\n      postKey: `${item.json.channel}/${item.json.postId}`,\n      channel: esc(item.json.channel),\n      postId: item.json.postId,\n      date: item.json.date,\n      text: esc((item.json.text || '').slice(0, 2500)),\n      url: esc(item.json.url),\n      views: item.json.views,\n      matchedKeywords: (item.json.matchedKeywords || []).join(', '),\n      cashtags: (item.json.cashtags || []).join(', ')\n    }\n  }));"
      },
      "id": "2e8997c0-ff0f-407e-8f78-db697a88b821",
      "name": "Keep post rows",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [480, 0]
    },
    {
      "parameters": {
        "authentication": "accessToken",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "#telegram-alerts",
          "mode": "name"
        },
        "messageType": "text",
        "text": "=*{{ $json.channel }}* {{ $json.date }}\n{{ $json.text }}\n{{ $json.url }}",
        "otherOptions": {
          "includeLinkToWorkflow": false,
          "unfurl_links": false
        }
      },
      "id": "0c4519ea-2e58-428e-bdb0-9ed0a1ec0d8c",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [720, 0]
    },
    {
      "parameters": {
        "content": "## Setup (3 fields)\n1. Install the Apify node: Settings > Community Nodes > `@apify/n8n-nodes-apify` (self-hosted), or search Apify in the nodes panel (Cloud, verified node).\n2. **Run Telegram Channel Scraper**: create an *Apify API* credential with your Apify API token. Edit `channels` in Input JSON.\n3. **Post to Slack**: select your Slack credential and the channel to post in (default `#telegram-alerts`).\n\n`onlyNewPosts` + `monitorName` make each run return only posts not returned before, so Slack gets each post once. Give each separate workflow its own `monitorName`.\n\nKeyword alerts: add `\"searchQueries\": [\"bitcoin\", \"#update\"]` to Input JSON. Changing filters starts a new watch whose first run returns only the newest posts.\n\nCost: $0.30 per 1,000 posts (Apify Free plan) + $0.00005 per run. `maxTotalChargeUsd` caps one run at $0.10.",
        "height": 420,
        "width": 520,
        "color": 7
      },
      "id": "bba9e5bc-9b21-4a6b-8b0a-4e4c5d2ac951",
      "name": "Setup",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [0, 200]
    }
  ],
  "connections": {
    "Every hour": {
      "main": [
        [
          {
            "node": "Run Telegram Channel Scraper",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Telegram Channel Scraper": {
      "main": [
        [
          {
            "node": "Keep post rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep post rows": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "pinData": {}
}
