{
  "id": "rXRUNJLmiUjUyaZK",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Telegram Cryptocurrency Price Updates",
  "tags": [],
  "nodes": [
    {
      "id": "7c94b011-e478-449a-bd5a-2626a6a96274",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -688
      ],
      "parameters": {
        "width": 928,
        "height": 768,
        "content": "## Automated Telegram Cryptocurrency Price Updates\n\n### This template automatically tracks cryptocurrency prices and sends a formatted summary to your Telegram channel.\n\n## How it works\n* The workflow triggers every hour (adjustable) and defines a list of assets to track.\n* Real-time market data (price and change) is fetched via the **CoinGecko Public API**.\n* Individual coin data is aggregated into a single dataset.\n* A JavaScript node transforms the raw data into a clean, human-readable HTML report.\n* The final report is pushed to your Telegram destination using the Telegram node.\n\n## Requirements\n* A Telegram Bot token.\n* A Telegram Chat ID (Group or Channel).\n\n## How to set up\n* **CoinGecko Node:** \n    * No credentials required (Public API).\n* **Telegram Node:** \n    * Create a bot via [BotFather](https://t.me/botfather) and get your API Token.\n    * Create a new Telegram Credential and paste your token.\n    * Add your bot to a channel or group as an admin and get the Chat ID.\n    * Set the Chat ID parameter in the Telegram node.\n* **Schedule Trigger:**\n    * Default is set to 1 hour. Adjust the interval to your preference.\n\n## How to customize\n* **Edit tracked coins:** Open the **'Define Coins'** node and edit tracked assets in the `coinIds` object using CoinGecko slugs.\n* **Styling:** Edit the **'Generate Telegram Message'** node to change emojis, currency formatting, or the report language.\n\n## See it in action\n* [Check this channel](https://t.me/HourlyCryptoPrices) to see live workflow"
      },
      "typeVersion": 1
    },
    {
      "id": "3c0ea8bb-55de-4d4e-a994-60b505b015da",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -464
      ],
      "parameters": {
        "color": "#3B3B3B",
        "width": 416,
        "height": 304,
        "content": "## 1. Data Preparation\nSetting up the schedule and defining which cryptocurrencies to track via API slugs."
      },
      "typeVersion": 1
    },
    {
      "id": "1dc8200e-4a54-4e8d-abd2-e0773b98e17d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        400,
        -464
      ],
      "parameters": {
        "color": "#3B3B3B",
        "width": 416,
        "height": 304,
        "content": "## 2. Fetching & Processing\nRetrieving live data from CoinGecko and merging individual items into a single dataset."
      },
      "typeVersion": 1
    },
    {
      "id": "44055ebe-b715-49b0-abaf-cbdfe750cbc5",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -464
      ],
      "parameters": {
        "color": "#3B3B3B",
        "width": 416,
        "height": 304,
        "content": "## 3. Formatting & Sending\nGenerating an HTML-formatted summary and sending it to the Telegram destination."
      },
      "typeVersion": 1
    },
    {
      "id": "cf2bdce1-5ada-417e-8c2d-5b7fa03632bd",
      "name": "Run Hourly",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        0,
        -320
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours"
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "00c8795c-d6d6-4f13-8bfd-c8a2e47d0f83",
      "name": "Define Coins",
      "type": "n8n-nodes-base.code",
      "position": [
        224,
        -320
      ],
      "parameters": {
        "jsCode": "/**\n * Configuration node: Define assets to track.\n * This node maps human-readable names to CoinGecko API IDs (slugs).\n */\n\n// List of assets to be fetched from the API\nconst coinIds = {\n  Bitcoin: \"bitcoin\",\n  Ethereum: \"ethereum\",\n  BNB: \"binancecoin\",\n  Solana: \"solana\",\n  Hyperliquid: \"hyperliquid\",\n  Cardano: \"cardano\",\n  Chainlink: \"chainlink\",\n  TON: \"the-open-network\",\n  Avalanche: \"avalanche-2\",\n  Sui: \"sui\",\n  Polkadot: \"polkadot\",\n  Uniswap: \"uniswap\"\n};\n\n// Extract API slugs from the configuration object and join them into a comma-separated string for the API request.\nreturn {\n  ids: Object.values(coinIds).join(',')\n};"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "67976fbc-8709-4ee0-939c-271e1ff2733a",
      "name": "Fetch Market Data",
      "type": "n8n-nodes-base.coinGecko",
      "position": [
        448,
        -320
      ],
      "parameters": {
        "options": {
          "ids": "={{ $json.ids }}"
        },
        "operation": "market",
        "baseCurrency": "usd"
      },
      "typeVersion": 1
    },
    {
      "id": "9e4013cb-9664-4dc5-8055-6603220006d6",
      "name": "Merge Results",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        672,
        -320
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "848ef6d8-b78d-4665-a93f-1cd82284dca2",
      "name": "Generate Telegram Message",
      "type": "n8n-nodes-base.code",
      "position": [
        896,
        -320
      ],
      "parameters": {
        "jsCode": "/**\n * Processes cryptocurrency market data and generates \n * a formatted HTML message for Telegram.\n */\n\n// Extract the raw data array from the preceding Aggregate node\nconst coins = $input.first().json.data;\n\n// Initialize message with a concise header\nlet message = \"<b>\ud83d\udcc8 Current Crypto Prices</b>\\n\\n\";\n\n/**\n * Iterate through the dataset to build the report lines.\n * Prices and 24h percentage changes are formatted for readability.\n */\nfor (const coin of coins) {\n  const currentPrice = coin.current_price;\n  const changePercentage = coin.price_change_percentage_24h || 0;\n  \n  // Set directional indicator based on the price movement\n  const trendIndicator = changePercentage >= 0 ? \"\ud83d\udd3c\" : \"\ud83d\udd3b\";\n\n  // Dynamic price formatting: \n  // Use 4 decimal places for low-value assets and 2 for major assets\n  const formattedPrice = currentPrice < 1 \n    ? currentPrice.toFixed(4) \n    : currentPrice.toLocaleString('en-US', { \n        minimumFractionDigits: 2, \n        maximumFractionDigits: 2 \n      });\n\n  const formattedChange = changePercentage.toFixed(2);\n\n  // Build the message line using HTML tags for Telegram ParseMode compatibility\n  message += `${coin.name}: <i>$${formattedPrice} (${formattedChange}%)</i> ${trendIndicator}\\n`;\n}\n\nreturn { message };"
      },
      "typeVersion": 2
    },
    {
      "id": "7f7ffdf2-b757-4f0f-86ee-369f3f44b979",
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1120,
        -320
      ],
      "parameters": {
        "text": "={{ $json.message }}",
        "chatId": "REPLACE_WITH_YOUR_CHAT_ID",
        "forceReply": {},
        "replyMarkup": "=",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        },
        "replyKeyboardRemove": {},
        "replyKeyboardOptions": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "timezone": "Europe/Prague",
    "binaryMode": "separate",
    "callerPolicy": "workflowsFromSameOwner",
    "timeSavedMode": "dynamic",
    "availableInMCP": false,
    "executionOrder": "v1"
  },
  "versionId": "5bbed0d7-ab22-438d-8b60-dba78cee9d92",
  "connections": {
    "Run Hourly": {
      "main": [
        [
          {
            "node": "Define Coins",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Define Coins": {
      "main": [
        [
          {
            "node": "Fetch Market Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Results": {
      "main": [
        [
          {
            "node": "Generate Telegram Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Market Data": {
      "main": [
        [
          {
            "node": "Merge Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Telegram Message": {
      "main": [
        [
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}