{
  "name": "Daily Digest",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "screener",
        "responseMode": "onReceived",
        "options": {}
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const body = $input.first().json.body;\nconst results = body.results || [];\nconst title = body.title || 'Daily Screener';\n\nif (!results.length) return [];\n\nconst lines = results.slice(0, 10).map((r, i) => {\n  const dir = r.direction === 'long' ? '\ud83d\udfe2' : r.direction === 'short' ? '\ud83d\udd34' : '\u26aa';\n  const conf = r.confidence ? ` (${(r.confidence * 100).toFixed(0)}%)` : '';\n  return `${i + 1}. ${dir} *${r.symbol}*${conf} \u2014 score: ${r.score?.toFixed(1) ?? '-'}`;\n}).join('\\n');\n\nreturn [{ json: { text: `\ud83d\udcca *${title}*\\n\\n${lines}` } }];"
      },
      "name": "Format Digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "chatId": "={{$env.TELEGRAM_CHAT_ID}}",
        "text": "={{$json[\"text\"]}}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "name": "Send Telegram",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        680,
        300
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Format Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Digest": {
      "main": [
        [
          {
            "node": "Send Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "tags": [
    "trading",
    "screener"
  ]
}