{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "98497668-c61b-499b-92a1-a62d2390f662",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        48,
        256
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 8 * * *"
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1f14c403-ead3-43a8-a975-110cbb213c64",
      "name": "Format Top 5",
      "type": "n8n-nodes-base.code",
      "position": [
        736,
        256
      ],
      "parameters": {
        "jsCode": "const results = $input.first().json.results || [];\n\nif (results.length === 0) {\n  throw new Error('Brave Search returned no results. Check your API key or query.');\n}\n\nconst top5 = results.slice(0, 5).map((item, i) => ({\n  index: i + 1,\n  title: item.title || 'No title',\n  description: item.description || 'No description available.',\n  url: item.url || '',\n  source: item.meta_url?.hostname || 'unknown',\n  published: item.age || ''\n}));\n\nreturn [{ json: { articles: top5 } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "cea423ec-63fa-4afe-90ca-a719d8f1ad4e",
      "name": "Build Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        912,
        256
      ],
      "parameters": {
        "jsCode": "const articles = $input.first().json.articles;\n\nconst formatted = articles.map(a =>\n  `${a.index}. ${a.title}\\nDescription: ${a.description}\\nSource: ${a.source} | ${a.published}\\nURL: ${a.url}`\n).join('\\n\\n');\n\nreturn [{ json: { prompt: formatted } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "b6be2767-9e4d-4664-a1f1-ecaca2987c5c",
      "name": "Send to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1680,
        256
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "chatId": "YOUR CHAT ID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "79f58a05-f56d-496e-bc08-4eabdb66b400",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1184,
        448
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini",
          "cachedResultName": "gpt-4.1-mini"
        },
        "options": {},
        "builtInTools": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0ebdb1d0-87ab-4ccd-85ff-3374c547cfb0",
      "name": "Make sumarry",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1184,
        256
      ],
      "parameters": {
        "text": "=Here are today's top crypto news stories. Write a clean daily digest with:\\n- A short punchy headline for each story (prefixed with the number)\\n- 2-3 sentence summary per story\\n- One final line labeled 'Market Mood:' summarizing the overall tone\\n\\nNews:\\n{{ $json.prompt }}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "You are a crypto news analyst. Write a concise daily digest for a crypto-savvy audience. Be sharp, factual, and brief. No fluff. No markdown headers. Use plain text only \u2014 no asterisks, no bold, no hashtags. Use numbering and line breaks for structure."
            }
          ]
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "070d3b04-17af-4f9f-8049-85269d6d85cf",
      "name": "Brave Search",
      "type": "@brave/n8n-nodes-brave-search.braveSearch",
      "position": [
        432,
        256
      ],
      "parameters": {
        "query": "crypto cryptocurrency bitcoin news",
        "operation": "news",
        "additionalParameters": {
          "country": "US",
          "safesearch": "moderate",
          "search_lang": "en"
        }
      },
      "credentials": {
        "braveSearchApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ae586dad-45d2-458b-9195-0251cf3aaf33",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -96,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 592,
        "content": "## Scheduled trigger\n\nFires automatically every day at 08:00 UTC via cron expression (0 8 * * *). Adjust the time to match your timezone."
      },
      "typeVersion": 1
    },
    {
      "id": "63d3d0ac-8bdf-492a-8f74-28edf200b91c",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 592,
        "content": "## News fetch\n\nQueries the Brave Search News API for recent crypto headlines. Returns up to 10 results filtered to English-language US sources."
      },
      "typeVersion": 1
    },
    {
      "id": "ab980fc6-07a6-461b-9fc3-166ec5655b3e",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        688,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 592,
        "content": "## Data processing\n\nSelects the top 5 articles and normalizes each entry. Assembles them into a single formatted prompt string for the language model."
      },
      "typeVersion": 1
    },
    {
      "id": "18476ed3-4d16-4315-a5ac-c374cee329a8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1104,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 720,
        "content": "## AI summary\n\nGPT-4.1-mini generates a plain-text daily digest \u2014 numbered headlines, 2\u20133 sentence summaries, and a Market Mood line at the end."
      },
      "typeVersion": 1
    },
    {
      "id": "0d184c1e-6bd2-4d88-8a0a-c78e01bea6f2",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1520,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 592,
        "content": "## Telegram delivery\n\nSends the completed digest to the configured chat. Ensure the bot is added to the target chat before activating."
      },
      "typeVersion": 1
    },
    {
      "id": "cf9d3e1a-97d0-412e-8384-72d30955d4bd",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -192
      ],
      "parameters": {
        "width": 832,
        "height": 752,
        "content": "## Daily crypto news digest\n\n### How it works\n\n1. Schedule Trigger fires every day at 08:00 UTC.\n2. Brave Search queries the News API for the latest cryptocurrency headlines from the past 24 hours.\n3. Format Top 5 selects the five most relevant results and normalizes each into a structured object.\n4. Build Prompt assembles the articles into a formatted string ready for the language model.\n5. Make summary uses GPT-4.1-mini to generate a plain-text digest \u2014 one headline and a 2\u20133 sentence summary per story, followed by a Market Mood line.\n6. The completed digest is sent to a configured Telegram chat.\n\n### Setup\n\n- [ ] Connect your Brave Search API credential. News search must be enabled on your plan.\n- [ ] Connect your OpenAI API credential to the OpenAI Chat Model node.\n- [ ] In Send to Telegram, replace YOUR CHAT ID with your actual Telegram chat ID.\n- [ ] Connect your Telegram Bot credential and ensure the bot is added to the target chat.\n- [ ] Adjust the cron expression in Schedule Trigger to match your preferred timezone.\n\n### Customization\n\nChange the search query in Brave Search to switch topics. Update the system prompt in Make summary to match the new subject and audience."
      },
      "typeVersion": 1
    },
    {
      "id": "64a353e6-ab21-43c5-9c9f-b0e52b8d3f11",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1600,
        192
      ],
      "parameters": {
        "color": 3,
        "height": 256,
        "content": "Warning"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Brave Search": {
      "main": [
        [
          {
            "node": "Format Top 5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Prompt": {
      "main": [
        [
          {
            "node": "Make sumarry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Top 5": {
      "main": [
        [
          {
            "node": "Build Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Make sumarry": {
      "main": [
        [
          {
            "node": "Send to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Brave Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Make sumarry",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}