{
  "name": "Send Local Falcon rank alerts to Telegram",
  "nodes": [
    {
      "parameters": {
        "content": "## Send Local Falcon Rank Alerts to Telegram\n\n**Who is this for:** Teams or individuals using Telegram who want instant ranking notifications on their mobile devices.\n\n**What this workflow does:**\n1. Monitors Local Falcon trend reports daily\n2. Detects ranking changes above threshold\n3. Sends formatted alerts to Telegram chat\n4. Includes quick stats and details\n\n**How to set up:**\n1. Add your Local Falcon API credentials (get your key at https://www.localfalcon.com/api/credentials)\n2. Create a Telegram bot via @BotFather\n3. Get your chat ID (message @userinfobot)\n4. Add Telegram credentials in n8n\n5. Activate the workflow\n\n**Requirements:**\n- Local Falcon account with API access\n- Telegram account with bot set up\n- Existing campaigns with scan data\n\n**How to customize:**\n- Create group chats for team alerts\n- Add inline buttons for actions\n- Set up different bots per client\n- Include chart images",
        "height": 480,
        "width": 460,
        "color": 5
      },
      "id": "sticky-main",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        100,
        -160
      ]
    },
    {
      "parameters": {
        "content": "### Step 1: Schedule\nChecks for changes daily.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        40,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 2: Get Trends\nFetches ranking changes.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step2",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        300,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 3: Process\nFilters significant changes.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        560,
        640
      ]
    },
    {
      "parameters": {
        "content": "### Step 4: Telegram\nSends alert message.",
        "height": 100,
        "width": 200
      },
      "id": "sticky-step4",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        820,
        640
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "schedule",
      "name": "Every Day 8am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        140,
        420
      ]
    },
    {
      "parameters": {
        "resource": "report",
        "operation": "listTrend",
        "additionalFields": {
          "limit": 50
        }
      },
      "id": "get-trends",
      "name": "Get Trend Reports",
      "type": "@local-falcon/n8n-nodes-localfalcon.localFalcon",
      "typeVersion": 1,
      "position": [
        400,
        420
      ],
      "credentials": {
        "localFalconApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "const reports = $input.first().json.reports || [];\nconst threshold = 2;\n\nconst alerts = reports.filter(r => {\n  const change = Math.abs(parseFloat(r.rank_change) || 0);\n  return change >= threshold;\n});\n\nif (alerts.length === 0) return [];\n\nlet message = `\ud83d\udd14 <b>Local Falcon Daily Alert</b>\\n\\n`;\nmessage += `<b>${alerts.length} ranking change(s) detected:</b>\\n\\n`;\n\nfor (const alert of alerts) {\n  const change = parseFloat(alert.rank_change) || 0;\n  const emoji = change < 0 ? '\ud83d\udcc8' : '\ud83d\udcc9';\n  const direction = change < 0 ? 'improved' : 'dropped';\n  \n  message += `${emoji} <b>${alert.location_name || 'Unknown'}</b>\\n`;\n  message += `   Keyword: ${alert.keyword || 'Unknown'}\\n`;\n  message += `   Rank ${direction}: ${alert.previous_avg_rank} \u2192 ${alert.avg_rank}\\n\\n`;\n}\n\nmessage += `<i>Powered by Local Falcon</i>`;\n\nreturn [{\n  json: {\n    message: message,\n    alertCount: alerts.length\n  }\n}];"
      },
      "id": "process",
      "name": "Process Alerts",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        660,
        420
      ]
    },
    {
      "parameters": {
        "chatId": "YOUR_TELEGRAM_CHAT_ID",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "id": "telegram",
      "name": "Send Telegram Alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        920,
        420
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Every Day 8am": {
      "main": [
        [
          {
            "node": "Get Trend Reports",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Trend Reports": {
      "main": [
        [
          {
            "node": "Process Alerts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Alerts": {
      "main": [
        [
          {
            "node": "Send Telegram Alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": true
  }
}