diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..f82a731 --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +# LogWhisperer AI - Environment Variables + +# Telegram Bot Configuration +# Ottieni questi valori seguendo le istruzioni in docs/telegram_setup.md +TELEGRAM_BOT_TOKEN=your_bot_token_here +TELEGRAM_CHAT_ID=your_chat_id_here + +# n8n Configuration +N8N_WEBHOOK_URL=https://your-n8n-instance.com/webhook/logwhisperer + +# AI Provider Configuration +OPENAI_API_KEY=your_openai_api_key_here +# oppure +ANTHROPIC_API_KEY=your_anthropic_api_key_here + +# Supabase Configuration (per autenticazione e database) +SUPABASE_URL=https://your-project.supabase.co +SUPABASE_ANON_KEY=your_anon_key_here + +# Stripe Configuration (per pagamenti) +STRIPE_SECRET_KEY=sk_test_your_key_here +STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret_here diff --git a/.gitignore b/.gitignore index 0f33f9c..ad3393e 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ Thumbs.db # OpenCode configuration with sensitive data .opencode/opencode.json + +# Telegram bot configuration (contains sensitive tokens) +docs/telegram_setup.md diff --git a/docs/prd.md b/docs/prd.md index 3d7f706..49c44d1 100644 --- a/docs/prd.md +++ b/docs/prd.md @@ -9,7 +9,10 @@ **Sprint Progress:** - āœ… Sprint 1: Log Ingestion Script (Completed) -- šŸ”„ Sprint 2: AI Processing Pipeline (Planning) +- šŸ”„ Sprint 2: AI Processing Pipeline (In Progress) + - āœ… Feature 2.1: LLM System Prompt (Metodo Sacchi) + - āœ… Feature 2.2: Telegram Bot Configuration + - ā³ Feature 2.3: n8n Workflow Integration - ā³ Sprint 3: Alerting & Onboarding - ā³ Sprint 4: Landing Page & Payments diff --git a/workflows/logwhisperer_ingest.json b/workflows/logwhisperer_ingest.json index d3956af..433e1d9 100644 --- a/workflows/logwhisperer_ingest.json +++ b/workflows/logwhisperer_ingest.json @@ -140,6 +140,31 @@ 100 ] }, + { + "parameters": { + "chatId": "={{ process.env.TELEGRAM_CHAT_ID }}", + "text": "={{ '🚨 *LogWhisperer Alert* \\n\\nšŸ“ *Server:* ' + $json.hostname + '\\nāš ļø *Severity:* ' + $json.severity.toUpperCase() + '\\n\\nšŸ“ *Problema:*\\n' + $json.ai_analysis.sintesi + '\\n\\nšŸ’” *Comando suggerito:*\\n```bash\\n' + ($json.ai_analysis.comando || 'Nessun comando disponibile') + '\\n```\\n\\nāš ļø *Richiede conferma:* ' + ($json.ai_analysis.richiede_conferma ? 'SÌ' : 'NO') + '\\nšŸ“ *Note:* ' + ($json.ai_analysis.note || 'Nessuna nota') + '\\n\\nšŸ“Š *Analisi AI:* ' + $json.ai_status + '\\nšŸ¤– *Modello:* ' + ($json.ai_model || 'N/A') + '\\n\\nā° ' + new Date().toLocaleString('it-IT') }}", + "parseMode": "MarkdownV2", + "options": { + "disable_notification": false + } + }, + "id": "telegram-notification-node", + "name": "Send Telegram Notification", + "type": "n8n-nodes-base.telegram", + "typeVersion": 1, + "position": [ + 1650, + 100 + ], + "continueOnFail": true, + "credentials": { + "telegramApi": { + "id": "telegram-credentials", + "name": "Telegram Bot" + } + } + }, { "parameters": { "jsCode": "// AI Processing - Enhanced with OpenRouter Analysis\n// Riceve i dati elaborati da OpenRouter con analisi AI\n\nconst logData = $input.first().json;\n\n// Log di sicurezza: non esporre raw_log completo nei log\nconsole.log('AI Processing completed for log ID:', logData.client_id);\nconsole.log('Client:', logData.client_id);\nconsole.log('Severity:', logData.severity);\nconsole.log('AI Status:', logData.ai_status);\nconsole.log('AI Model:', logData.ai_model || 'N/A');\n\n// Se c'\u00e8 l'analisi AI, logga la sintesi\nif (logData.ai_analysis) {\n console.log('AI Sintesi:', logData.ai_analysis.sintesi);\n console.log('AI Comando suggerito:', logData.ai_analysis.comando || 'Nessuno');\n}\n\nreturn [{\n json: {\n status: 'ai_processing_complete',\n client_id: logData.client_id,\n hostname: logData.hostname,\n severity: logData.severity,\n ai_analysis: logData.ai_analysis,\n ai_status: logData.ai_status,\n ai_model: logData.ai_model,\n timestamp: logData.ai_timestamp || new Date().toISOString()\n }\n}];" @@ -149,8 +174,8 @@ "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1650, - 50 + 1850, + 100 ] }, { @@ -331,7 +356,7 @@ "main": [ [ { - "node": "AI Processing", + "node": "Send Telegram Notification", "type": "main", "index": 0 } @@ -345,6 +370,17 @@ ] ] }, + "Send Telegram Notification": { + "main": [ + [ + { + "node": "AI Processing", + "type": "main", + "index": 0 + } + ] + ] + }, "Ensure Table SQL": { "main": [ [