{
  "name": "Earnings Alert Summarizer",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "minutesInterval": 1
            }
          ]
        }
      },
      "id": "trigger-001",
      "name": "Every Hour",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.polygon.io/v2/reference/news",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "ticker",
              "value": "={{ $vars.WATCHLIST_TICKERS || 'AAPL,MSFT,GOOGL,AMZN,META,NVDA' }}"
            },
            {
              "name": "published_utc.gte",
              "value": "={{ $now.minus(1, 'hour').toISO() }}"
            },
            {
              "name": "limit",
              "value": "10"
            },
            {
              "name": "apiKey",
              "value": "={{ $vars.POLYGON_API_KEY }}"
            }
          ]
        },
        "options": {}
      },
      "id": "fetch-news-001",
      "name": "Fetch Earnings News",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        470,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "leftValue": "={{ $json.resultsCount }}",
              "rightValue": 0,
              "operator": {
                "type": "number",
                "operation": "gt"
              }
            }
          ],
          "combinator": "and"
        }
      },
      "id": "check-results-001",
      "name": "Has Results?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        690,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const results = $input.item.json.results || [];\nconst earningsKeywords = ['earnings', 'revenue', 'profit', 'EPS', 'quarterly', 'guidance', 'beat', 'miss', 'forecast'];\n\nconst filtered = results.filter(article => {\n  const text = (article.title + ' ' + (article.description || '')).toLowerCase();\n  return earningsKeywords.some(kw => text.toLowerCase().includes(kw.toLowerCase()));\n});\n\nreturn filtered.map(article => ({\n  json: {\n    title: article.title,\n    description: article.description || '',\n    published_utc: article.published_utc,\n    tickers: article.tickers || [],\n    article_url: article.article_url,\n    full_text: `${article.title}\\n\\n${article.description || ''}`\n  }\n}));"
      },
      "id": "filter-earnings-001",
      "name": "Filter Earnings Articles",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        910,
        200
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $vars.FASTAPI_BASE_URL || 'http://fastapi-service:8000' }}/summarize",
        "sendBody": true,
        "contentType": "json",
        "body": {
          "text": "={{ $json.full_text }}",
          "context_type": "earnings",
          "ticker": "={{ $json.tickers[0] || 'UNKNOWN' }}",
          "source_url": "={{ $json.article_url }}"
        },
        "options": {
          "timeout": 30000
        }
      },
      "id": "summarize-001",
      "name": "Summarize with Claude",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1130,
        200
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "slack-msg-001",
              "name": "slack_message",
              "value": "={{ '*' + $json.headline + '*\\n\\n' + '\ud83d\udcca *Key Points:*\\n' + ($json.key_points || []).map(p => '\u2022 ' + p).join('\\n') + '\\n\\n' + '\ud83c\udfaf *Sentiment:* ' + ($json.sentiment || 'neutral').toUpperCase() + '\\n' + '\u26a1 *Action Items:*\\n' + ($json.action_items || []).map(a => '\u2192 ' + a).join('\\n') + '\\n\\n' + '\ud83d\udd17 ' + $('Filter Earnings Articles').item.json.article_url }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "format-slack-001",
      "name": "Format Slack Message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1350,
        200
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "={{ $vars.SLACK_EARNINGS_CHANNEL || '#earnings-alerts' }}",
          "mode": "name"
        },
        "text": "={{ $json.slack_message }}",
        "otherOptions": {
          "includeLinkToWorkflow": false,
          "mrkdwn": true
        }
      },
      "id": "slack-notify-001",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.2,
      "position": [
        1570,
        200
      ],
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "noop-001",
              "name": "status",
              "value": "no_earnings_news",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "no-news-001",
      "name": "No News \u2014 Skip",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        910,
        420
      ]
    }
  ],
  "connections": {
    "Every Hour": {
      "main": [
        [
          {
            "node": "Fetch Earnings News",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Earnings News": {
      "main": [
        [
          {
            "node": "Has Results?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Has Results?": {
      "main": [
        [
          {
            "node": "Filter Earnings Articles",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No News \u2014 Skip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Earnings Articles": {
      "main": [
        [
          {
            "node": "Summarize with Claude",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize with Claude": {
      "main": [
        [
          {
            "node": "Format Slack Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Slack Message": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": ""
  },
  "staticData": null,
  "tags": [
    "fintech",
    "earnings",
    "claude",
    "slack"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-06-15T00:00:00.000Z",
  "versionId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}