{
  "name": "VYNDR · Results · Daily 9:00 AM ET",
  "active": false,
  "nodes": [
    {
      "parameters": {
        "rule": { "interval": [{ "field": "cronExpression", "expression": "0 9 * * *" }] }
      },
      "id": "cron-results",
      "name": "Cron · 9:00 AM ET",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [200, 200]
    },
    {
      "parameters": {
        "url": "={{ $env.VYNDR_API_BASE }}/api/briefing",
        "method": "GET",
        "options": { "timeout": 20000 }
      },
      "id": "fetch-results",
      "name": "Fetch results data",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [440, 200]
    },
    {
      "parameters": {
        "url": "={{ $env.VYNDR_API_BASE }}/api/share-card",
        "method": "POST",
        "sendHeaders": true,
        "headerParameters": { "parameters": [{ "name": "Content-Type", "value": "application/json" }] },
        "sendBody": true,
        "bodyParametersJson": "={\n  \"type\": \"recap\",\n  \"format\": \"square\",\n  \"date\": \"={{ $json.results.date }}\",\n  \"accuracy\": \"={{ $json.results.accuracy }}\",\n  \"entries\": \"={{ $json.results.entries }}\"\n}",
        "options": { "response": { "response": { "responseFormat": "file", "outputPropertyName": "card" } }, "timeout": 30000 }
      },
      "id": "generate-card",
      "name": "Generate share card",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [680, 200]
    },
    {
      "parameters": {
        "url": "https://api.telegram.org/bot{{ $env.TELEGRAM_BOT_TOKEN }}/sendPhoto",
        "method": "POST",
        "sendBinaryData": true,
        "binaryPropertyName": "card",
        "sendBody": true,
        "bodyContentType": "multipart-form-data",
        "bodyParameters": { "parameters": [
          { "name": "chat_id", "value": "={{ $env.TELEGRAM_CHANNEL_ID }}" },
          { "name": "caption", "value": "Last night's results → vyndr.app/ledger" }
        ] }
      },
      "id": "push-telegram",
      "name": "Push · Telegram",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [920, 100]
    },
    {
      "parameters": {
        "url": "={{ $env.DISCORD_WEBHOOK_RESULTS }}",
        "method": "POST",
        "sendBinaryData": true,
        "binaryPropertyName": "card",
        "sendBody": true,
        "bodyContentType": "multipart-form-data",
        "bodyParameters": { "parameters": [
          { "name": "payload_json", "value": "={\"username\":\"VYNDR\",\"embeds\":[{\"description\":\"Last night's results — vyndr.app/ledger\",\"color\":56480,\"image\":{\"url\":\"attachment://vyndr.png\"},\"footer\":{\"text\":\"VYNDR · vyndr.app\"}}]}" }
        ] }
      },
      "id": "push-discord",
      "name": "Push · Discord (#results)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [920, 300]
    }
  ],
  "connections": {
    "Cron · 9:00 AM ET":   { "main": [[{ "node": "Fetch results data", "type": "main", "index": 0 }]] },
    "Fetch results data":  { "main": [[{ "node": "Generate share card","type": "main", "index": 0 }]] },
    "Generate share card": { "main": [[
      { "node": "Push · Telegram",         "type": "main", "index": 0 },
      { "node": "Push · Discord (#results)","type": "main", "index": 0 }
    ]] }
  },
  "settings": { "timezone": "America/New_York" }
}
