{
  "name": "Competitor Monitor",
  "nodes": [
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "mode": "specificTime",
              "time": "09:00"
            }
          ]
        }
      },
      "id": "Daily_Schedule",
      "name": "Daily Schedule",
      "type": "n8n-nodes-base.schedule",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{$env[\"COMPETITOR_WEBSITE_URL\"]}}",
        "authentication": "none",
        "options": {
          "fullResponse": false
        }
      },
      "id": "Fetch_Competitor_Website",
      "name": "Fetch Competitor Website",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        450,
        200
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.producthunt.com/v2/posts?search={{$env[\"COMPETITOR_NAME\"]}}",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{$env[\"PRODUCT_HUNT_API_TOKEN\"]}}"
            }
          ]
        }
      },
      "id": "Fetch_ProductHunt_Data",
      "name": "Fetch ProductHunt Data",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        450,
        400
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "=https://api.twitter.com/2/tweets/search/recent?query={{encodeURIComponent($env[\"COMPETITOR_TWITTER\"])}}%20-is:retweet&max_results=100&tweet.fields=created_at,public_metrics",
        "authentication": "oAuth2",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer {{$env[\"TWITTER_BEARER_TOKEN\"]}}"
            }
          ]
        }
      },
      "id": "Fetch_Twitter_Data",
      "name": "Fetch Twitter Data",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        450,
        600
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.anthropic.com/v1/messages",
        "authentication": "none",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "x-api-key",
              "value": "={{$env[\"ANTHROPIC_API_KEY\"]}}"
            },
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            }
          ]
        },
        "contentType": "application/json",
        "body": "={\n  \"model\": \"claude-3-5-sonnet-20241022\",\n  \"max_tokens\": 2000,\n  \"system\": \"You are a competitive intelligence analyst. Analyze the following competitor data and provide actionable insights. Focus on: 1) Product changes/updates 2) Market positioning shifts 3) Customer sentiment 4) Pricing/feature changes 5) Threats and opportunities. Format as a bulleted summary.\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"Analyze this competitor intelligence:\\n\\nWebsite Data:\\n{{$node[\\\"Fetch_Competitor_Website\\\"].json.body}}\\n\\nProduct Hunt:\\n{{JSON.stringify($node[\\\"Fetch_ProductHunt_Data\\\"].json.data)}}\\n\\nTwitter Activity:\\n{{JSON.stringify($node[\\\"Fetch_Twitter_Data\\\"].json.data)}}\\n\\nProvide a structured competitive analysis.\"\n    }\n  ]\n}"
      },
      "id": "Claude_Analysis",
      "name": "Claude Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        750,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://hooks.slack.com/services/YOUR/WEBHOOK/URL",
        "authentication": "none",
        "contentType": "application/json",
        "body": "={\n  \"text\": \"\ud83d\udcca Daily Competitor Report: {{$env[\\\"COMPETITOR_NAME\\\"]}}\",\n  \"blocks\": [\n    {\n      \"type\": \"header\",\n      \"text\": {\n        \"type\": \"plain_text\",\n        \"text\": \"\ud83d\udcca {{$env[\\\"COMPETITOR_NAME\\\"]}} - Competitor Intel\"\n      }\n    },\n    {\n      \"type\": \"section\",\n      \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \"{{$node[\\\"Claude_Analysis\\\"].json.content[0].text}}\"\n      }\n    },\n    {\n      \"type\": \"divider\"\n    },\n    {\n      \"type\": \"section\",\n      \"fields\": [\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Generated:*\\n{{new Date().toLocaleString()}}\"\n        },\n        {\n          \"type\": \"mrkdwn\",\n          \"text\": \"*Frequency:*\\nDaily @ 9:00 AM\"\n        }\n      ]\n    }\n  ]\n}"
      },
      "id": "Slack_Report",
      "name": "Slack Report",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        950,
        200
      ]
    },
    {
      "parameters": {
        "resource": "message",
        "operation": "send",
        "chatId": "={{$env[\"TELEGRAM_CHAT_ID\"]}}",
        "text": "\ud83d\udcca <b>{{$env[\\\"COMPETITOR_NAME\\\"]}} Competitive Alert</b>\\n\\n{{$node[\\\"Claude_Analysis\\\"].json.content[0].text}}\\n\\n\ud83d\udd50 Generated: {{new Date().toLocaleString()}}",
        "parseMode": "html"
      },
      "id": "Telegram_Report",
      "name": "Telegram Report",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        950,
        400
      ]
    },
    {
      "parameters": {
        "fromEmail": "={{$env[\"SENDER_EMAIL\"]}}",
        "toEmail": "={{$env[\"RECIPIENT_EMAIL\"]}}",
        "subject": "\ud83d\udcca Daily Competitor Report: {{$env[\"COMPETITOR_NAME\"]}}",
        "emailBody": "=<html><body style='font-family: Arial, sans-serif; line-height: 1.6;'><h2>{{$env[\"COMPETITOR_NAME\"]}} - Daily Competitive Intelligence</h2><p>{{$node[\"Claude_Analysis\"].json.content[0].text}}</p><hr><p><small>Generated: {{new Date().toLocaleString()}}<br>This is an automated report from your Competitor Monitor workflow.</small></p></body></html>",
        "fromName": "Competitor Monitor Bot"
      },
      "id": "Email_Report",
      "name": "Email Report",
      "type": "n8n-nodes-base.sendGrid",
      "typeVersion": 1,
      "position": [
        950,
        600
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env[\"AIRTABLE_WEBHOOK_URL\"]}}",
        "authentication": "none",
        "contentType": "application/json",
        "body": "={\n  \"date\": \"{{new Date().toISOString()}}\",\n  \"competitor\": \"{{$env[\\\"COMPETITOR_NAME\\\"]}}\",\n  \"analysis\": \"{{$node[\\\"Claude_Analysis\\\"].json.content[0].text}}\",\n  \"source_count\": \"{{$node[\\\"Fetch_Twitter_Data\\\"].json.data.length || 0}}\"\n}"
      },
      "id": "Store_Analysis",
      "name": "Store Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1150,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "=https://api.telegram.org/bot{{$env[\"TELEGRAM_BOT_TOKEN\"]}}/sendMessage",
        "authentication": "none",
        "contentType": "application/json",
        "body": "={\n  \"chat_id\": \"={{$env[\\\"TELEGRAM_CHAT_ID\\\"]}}\",\n  \"text\": \"\u274c <b>Competitor Monitor Error</b>\\n{{$error.message}}\\n\\nCompetitor: {{$env[\\\"COMPETITOR_NAME\\\"]}}\",\n  \"parse_mode\": \"HTML\"\n}"
      },
      "id": "Error_Handler",
      "name": "Error Handler",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1150,
        600
      ]
    }
  ],
  "connections": {
    "Daily_Schedule": {
      "main": [
        [
          {
            "node": "Fetch_Competitor_Website",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch_ProductHunt_Data",
            "type": "main",
            "index": 0
          },
          {
            "node": "Fetch_Twitter_Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_Competitor_Website": {
      "main": [
        [
          {
            "node": "Claude_Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_ProductHunt_Data": {
      "main": [
        [
          {
            "node": "Claude_Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch_Twitter_Data": {
      "main": [
        [
          {
            "node": "Claude_Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Claude_Analysis": {
      "main": [
        [
          {
            "node": "Slack_Report",
            "type": "main",
            "index": 0
          },
          {
            "node": "Telegram_Report",
            "type": "main",
            "index": 0
          },
          {
            "node": "Email_Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Slack_Report": {
      "main": [
        [
          {
            "node": "Store_Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram_Report": {
      "main": [
        [
          {
            "node": "Store_Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email_Report": {
      "main": [
        [
          {
            "node": "Store_Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1"
  },
  "id": "3"
}