diff --git a/mstfyldz Journal - Full Telegram & AI Automation.json b/mstfyldz Journal - Full Telegram & AI Automation.json index 86482ce..d87c7f0 100644 --- a/mstfyldz Journal - Full Telegram & AI Automation.json +++ b/mstfyldz Journal - Full Telegram & AI Automation.json @@ -8,13 +8,13 @@ ], "additionalFields": {} }, - "id": "4b63c60c-a0e6-4395-829b-9cc003280df5", + "id": "13ae8c1e-3cd2-4365-a6b2-8f3301a7f9db", "name": "Telegram Trigger", "type": "n8n-nodes-base.telegramTrigger", "typeVersion": 1.1, "position": [ - -352, - 144 + -304, + 320 ], "webhookId": "ede016a9-34a3-4fc8-8725-291bd02403a2", "credentials": { @@ -26,99 +26,105 @@ }, { "parameters": { - "modelId": { - "__rl": true, - "value": "gpt-4o-mini", - "mode": "list", - "cachedResultName": "GPT-4O-MINI" - }, - "messages": { + "rules": { "values": [ { - "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen ham düşünceleri, kod kırıntılarını veya ses transkriptlerini analiz ederek günlüğün tasarım diline ve ruhuna uygun biçimlendirmek.\n\nGörevin sonucunda SADECE ve SADECE aşağıdaki JSON formatında yanıt ver (Markdown kod bloğu veya ekstra metin yazma):\n\n{\n \"type\": \"sticky\" | \"notebook\" | \"code\" | \"polaroid\" | \"audio\",\n \"mood\": \"spark\" | \"focus\" | \"night\" | \"calm\" | \"visual\",\n \"moodLabel\": \"Fikir Patlaması\" | \"Aşırı Odak & Kaos\" | \"Gece Melankolisi\" | \"Sakin & Karalama\" | \"Polaroid & Kırıntılar\",\n \"title\": \"İlgi çekici kısa başlık veya null\",\n \"stampedText\": \"ONAYLANDI\" | \"COMPILED\" | \"DOĞRU TESPİT\" | \"SUÇLU\" | \"KARALAMA\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu 1\", \"not 2\"],\n \"tags\": [\"etiket1\", \"etiket2\"]\n}\n\nKurallar:\n1. Mood Seçimi:\n - \"spark\": Ani fikirler, heyecanlı projeler, aydınlanmalar.\n - \"focus\": Kod yazma, teknik konular, karmaşık mimariler, kahve.\n - \"night\": Saat 03:00 kafası, derin felsefe, varoluşsal sorgular.\n - \"calm\": Çay anları, yürüyüş, doğa, dinginlik, nostalji.\n - \"visual\": Fotoğraf altı yazıları, görsel kırıntılar.\n2. Kenar Notları (Margin Notes): Mustafa'nın tarzında esprili, samimi, el yazısı havasında 1 veya 2 not türet (Örn: \"← tam olarak bu!\", \"çayı tazelemeyi unutma ☕\", \"derleyici yine haklı çıktı\").\n3. Etiketler: Metnin özünden 2-4 adet küçük harfli etiket çıkar.\n", - "role": "system" + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ $json.message.voice }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + }, + "id": "e71bb63b-56de-4030-a1e1-18bc62a5fd57" + } + ], + "combinator": "and" + } }, { - "content": "=Analiz Edilecek Telegram İçeriği:\n\"{{ $json.message.text || $json.message.caption || '' }}\"\n" - } - ] - }, - "options": { - "temperature": 0.7 - } - }, - "id": "41a71e40-b584-48e1-a3f1-f9dc9c3728bd", - "name": "OpenAI Mood & Curator", - "type": "@n8n/n8n-nodes-langchain.openAi", - "typeVersion": 1, - "position": [ - 592, - -224 - ], - "credentials": { - "openAiApi": { - "id": "dkfTY90eMiE7rE6q", - "name": "OpenAi account 2" - } - } - }, - { - "parameters": { - "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\n// 1. Photo (Polaroid) Tespiti & Caption\nconst hasPhoto = Array.isArray(msg?.photo) && msg.photo.length > 0;\nlet imageUrl = undefined;\nlet imageCaption = undefined;\n\nif (hasPhoto) {\n imageCaption = msg.caption || aiParsed.imageCaption || undefined;\n const photoFilePath = $(\"Get a file\")?.first()?.json?.result?.file_path || $(\"Get File\")?.first()?.json?.result?.file_path;\n if (photoFilePath) {\n audioUrl = undefined;\n imageUrl = `https://api.telegram.org/file/bot[YOUR_BOT_TOKEN]/${photoFilePath}`;\n }\n}\n\n// 2. Ses Kaydı (Voice / Audio) Tespiti ve Süre Hesabı\nconst audioObj = msg?.voice || msg?.audio;\nlet audioDuration = undefined;\nlet audioTitle = undefined;\nlet audioUrl = undefined;\n\nif (audioObj) {\n const durSec = audioObj.duration || 0;\n const mins = Math.floor(durSec / 60).toString().padStart(2, '0');\n const secs = (durSec % 60).toString().padStart(2, '0');\n audioDuration = `${mins}:${secs}`;\n audioTitle = msg.audio?.file_name || `Telegram_Voice_Note_${durSec}s.m4a`;\n \n const filePath = $(\"Get a file\")?.first()?.json?.result?.file_path || $(\"Get File\")?.first()?.json?.result?.file_path;\n if (filePath) {\n audioUrl = `https://api.telegram.org/file/bot[YOUR_BOT_TOKEN]/${filePath}`;\n }\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nlet postType = aiParsed.type || 'sticky';\nif (hasPhoto) postType = 'polaroid';\nif (audioObj) postType = 'audio';\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: postType,\n date: dateStr,\n timestamp: timeStr,\n mood: hasPhoto ? 'visual' : (audioObj ? 'spark' : (aiParsed.mood || 'spark')),\n moodLabel: hasPhoto ? 'Polaroid & Kırıntılar' : (audioObj ? 'Fikir Patlaması' : (aiParsed.moodLabel || 'Fikir Patlaması')),\n title: aiParsed.title || (audioObj ? 'Telegram Ses Kaydı' : (hasPhoto ? (imageCaption || 'Polaroid Anı') : undefined)),\n content: $(\"Transcribe a recording\")?.first()?.json?.text || msg.text || msg.caption || (hasPhoto ? 'Fotoğraf gönderildi' : 'Telegram Notu'),\n marginNotes: aiParsed.marginNotes || [hasPhoto ? '← Telegram fotoğrafı 📸' : (audioObj ? '← Telegram ses kaydı 🎙️' : '← Telegram ile atıldı 📱')],\n tags: aiParsed.tags || (hasPhoto ? ['telegram', 'polaroid'] : (audioObj ? ['telegram', 'voice'] : ['telegram'])),\n likes: 1,\n stampedText: aiParsed.stampedText || (hasPhoto ? 'POLAROID' : (audioObj ? 'VOICE NOTE' : 'TELEGRAM')),\n \n // Polaroid Fotoğraf alanları\n imageUrl: imageUrl || aiParsed.imageUrl,\n imageCaption: imageCaption || aiParsed.imageCaption,\n \n // Ses dosyası meta verileri\n audioDuration: audioDuration || aiParsed.audioDuration,\n audioTitle: audioTitle || aiParsed.audioTitle,\n audioUrl: audioUrl || aiParsed.audioUrl\n }\n};\n" - }, - "id": "0f6db6e4-4033-42e0-a632-a7ad76d4e2f8", - "name": "Format Journal Payload", - "type": "n8n-nodes-base.code", - "typeVersion": 2, - "position": [ - 1024, - 0 - ] - }, - { - "parameters": { - "method": "POST", - "url": "https://mstfyldz.com/api/posts", - "sendHeaders": true, - "headerParameters": { - "parameters": [ + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "bfacad39-bcd9-447e-bba0-82192573e08f", + "leftValue": "={{ $json.message.photo[0].file_id }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, { - "name": "Content-Type", - "value": "application/json" + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "3e81a46e-cf60-4e2a-95ef-1d946fe7b525", + "leftValue": "={{ $json.message.text }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + } + } + ], + "combinator": "and" + } } ] }, - "sendBody": true, - "specifyBody": "json", - "jsonBody": "={{ JSON.stringify($json) }}", "options": {} }, - "id": "2355e658-0c7d-4e96-81e3-e0a6716529c1", - "name": "HTTP POST to Journal API", - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.1, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, "position": [ - 1312, - 0 - ] + -96, + 320 + ], + "id": "baebb5f0-df5f-4b90-98cb-eaf7fc3f3405", + "name": "Switch" }, { "parameters": { - "chatId": "={{ $(\"Telegram Trigger\").first().json.message.chat.id }}", - "text": "=✅ *Not Deftere Karalandı!*\n\n📖 *Format:* {{ $(\"Format Journal Payload\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload\").first().json.moodLabel }}\n📌 *Başlık:* {{ $(\"Format Journal Payload\").first().json.title || 'Başlıksız Not' }}\n🏷️ *Etiketler:* #{{ $(\"Format Journal Payload\").first().json.tags.join(' #') }}\n\n✍️ _\"{{ $(\"Format Journal Payload\").first().json.marginNotes[0] || '' }}\"_", - "additionalFields": { - "parse_mode": "Markdown" - } + "resource": "file", + "fileId": "={{ $json.message.voice.file_id }}", + "additionalFields": {} }, - "id": "b69bbb0c-e760-4a06-bb72-1bdaab8ff3c9", - "name": "Telegram Send Confirmation", "type": "n8n-nodes-base.telegram", "typeVersion": 1.2, "position": [ - 1600, - -32 + 160, + 288 ], - "webhookId": "656440d2-a136-4926-a700-67a780664c91", + "id": "b9f0a086-36db-462b-ae75-460b6ae6bf9a", + "name": "Get a file", + "webhookId": "376048bf-8f95-4841-b048-46bdf3b82dfd", "credentials": { "telegramApi": { "id": "EHAAmsKUkdoY5dGj", @@ -128,22 +134,32 @@ }, { "parameters": { - "conditions": { - "number": [ + "method": "PUT", + "url": "=https://storage.bunnycdn.net/apexlegal/journal/voice_{{ Date.now() }}.m4a", + "sendHeaders": true, + "headerParameters": { + "parameters": [ { - "value1": "={{ $json.message.voice }}", - "operation": "isNotEmpty" + "name": "AccessKey", + "value": "1cc9536e-7e5c-480d-8c93ac12ec46-357a-4d81" + }, + { + "name": "Content-Type", + "value": "application/octet-stream" } ] - } + }, + "sendBody": true, + "specifyBody": "key", + "bodyKey": "data" }, - "id": "5de02aed-e840-461f-b9b1-b61ad820575d", - "name": "Security Check (Chat ID)1", - "type": "n8n-nodes-base.if", - "typeVersion": 1, + "id": "bunny-upload-voice", + "name": "Upload Voice to Bunny CDN", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, "position": [ - -96, - 64 + 380, + 288 ] }, { @@ -156,10 +172,10 @@ "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 2.1, "position": [ - 384, - 336 + 600, + 288 ], - "id": "d16cb1c2-a10c-4750-a65f-4d8c35e294fe", + "id": "5942e900-db59-4a94-a68b-99f1f0480fce", "name": "Transcribe a recording", "credentials": { "openAiApi": { @@ -168,28 +184,6 @@ } } }, - { - "parameters": { - "resource": "file", - "fileId": "={{ $json.message.voice.file_id }}", - "additionalFields": {} - }, - "type": "n8n-nodes-base.telegram", - "typeVersion": 1.2, - "position": [ - 128, - 288 - ], - "id": "cd320b67-3c21-4e60-b47a-fadeec758cab", - "name": "Get a file", - "webhookId": "376048bf-8f95-4841-b048-46bdf3b82dfd", - "credentials": { - "telegramApi": { - "id": "EHAAmsKUkdoY5dGj", - "name": "#1Piksel" - } - } - }, { "parameters": { "modelId": { @@ -201,11 +195,11 @@ "messages": { "values": [ { - "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen ham düşünceleri, kod kırıntılarını veya ses transkriptlerini analiz ederek günlüğün tasarım diline ve ruhuna uygun biçimlendirmek.\n\nGörevin sonucunda SADECE ve SADECE aşağıdaki JSON formatında yanıt ver (Markdown kod bloğu veya ekstra metin yazma):\n\n{\n \"type\": \"sticky\" | \"notebook\" | \"code\" | \"polaroid\" | \"audio\",\n \"mood\": \"spark\" | \"focus\" | \"night\" | \"calm\" | \"visual\",\n \"moodLabel\": \"Fikir Patlaması\" | \"Aşırı Odak & Kaos\" | \"Gece Melankolisi\" | \"Sakin & Karalama\" | \"Polaroid & Kırıntılar\",\n \"title\": \"İlgi çekici kısa başlık veya null\",\n \"stampedText\": \"ONAYLANDI\" | \"COMPILED\" | \"DOĞRU TESPİT\" | \"SUÇLU\" | \"KARALAMA\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu 1\", \"not 2\"],\n \"tags\": [\"etiket1\", \"etiket2\"]\n}\n\nKurallar:\n1. Mood Seçimi:\n - \"spark\": Ani fikirler, heyecanlı projeler, aydınlanmalar.\n - \"focus\": Kod yazma, teknik konular, karmaşık mimariler, kahve.\n - \"night\": Saat 03:00 kafası, derin felsefe, varoluşsal sorgular.\n - \"calm\": Çay anları, yürüyüş, doğa, dinginlik, nostalji.\n - \"visual\": Fotoğraf altı yazıları, görsel kırıntılar.\n2. Kenar Notları (Margin Notes): Mustafa'nın tarzında esprili, samimi, el yazısı havasında 1 veya 2 not türet (Örn: \"← tam olarak bu!\", \"çayı tazelemeyi unutma ☕\", \"derleyici yine haklı çıktı\").\n3. Etiketler: Metnin özünden 2-4 adet küçük harfli etiket çıkar.\n", + "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen ses transkriptini analiz ederek günlüğün tasarım diline uygun biçimlendirmek.\n\nSADECE aşağıdaki JSON formatında yanıt ver:\n{\n \"type\": \"audio\",\n \"mood\": \"spark\" | \"focus\" | \"night\" | \"calm\",\n \"moodLabel\": \"Fikir Patlaması\" | \"Aşırı Odak & Kaos\" | \"Gece Melankolisi\" | \"Sakin & Karalama\",\n \"title\": \"Kısa ilgi çekici başlık\",\n \"stampedText\": \"VOICE NOTE\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu\"],\n \"tags\": [\"ses-kaydı\", \"düşünceler\"]\n}\n", "role": "system" }, { - "content": "=Analiz Edilecek Telegram İçeriği:\n\"{{ $json.text }}\"\n" + "content": "=Analiz Edilecek Transkript:\n\"{{ $json.text }}\"\n" } ] }, @@ -213,13 +207,13 @@ "temperature": 0.7 } }, - "id": "45a02fbf-e547-44dd-9292-e9102fa5e8f0", + "id": "fbecf695-5165-477f-9a1b-2f116572edf5", "name": "OpenAI Mood & Curator1", "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 1, "position": [ - 704, - 368 + 820, + 288 ], "credentials": { "openAiApi": { @@ -230,15 +224,15 @@ }, { "parameters": { - "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\n// 1. Photo (Polaroid) Tespiti & Caption\nconst hasPhoto = Array.isArray(msg?.photo) && msg.photo.length > 0;\nlet imageUrl = undefined;\nlet imageCaption = undefined;\n\nif (hasPhoto) {\n imageCaption = msg.caption || aiParsed.imageCaption || undefined;\n const photoFilePath = $(\"Get a file\")?.first()?.json?.result?.file_path || $(\"Get File\")?.first()?.json?.result?.file_path;\n if (photoFilePath) {\n audioUrl = undefined;\n imageUrl = `https://api.telegram.org/file/bot[YOUR_BOT_TOKEN]/${photoFilePath}`;\n }\n}\n\n// 2. Ses Kaydı (Voice / Audio) Tespiti ve Süre Hesabı\nconst audioObj = msg?.voice || msg?.audio;\nlet audioDuration = undefined;\nlet audioTitle = undefined;\nlet audioUrl = undefined;\n\nif (audioObj) {\n const durSec = audioObj.duration || 0;\n const mins = Math.floor(durSec / 60).toString().padStart(2, '0');\n const secs = (durSec % 60).toString().padStart(2, '0');\n audioDuration = `${mins}:${secs}`;\n audioTitle = msg.audio?.file_name || `Telegram_Voice_Note_${durSec}s.m4a`;\n \n const filePath = $(\"Get a file\")?.first()?.json?.result?.file_path || $(\"Get File\")?.first()?.json?.result?.file_path;\n if (filePath) {\n audioUrl = `https://api.telegram.org/file/bot[YOUR_BOT_TOKEN]/${filePath}`;\n }\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nlet postType = aiParsed.type || 'sticky';\nif (hasPhoto) postType = 'polaroid';\nif (audioObj) postType = 'audio';\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: postType,\n date: dateStr,\n timestamp: timeStr,\n mood: hasPhoto ? 'visual' : (audioObj ? 'spark' : (aiParsed.mood || 'spark')),\n moodLabel: hasPhoto ? 'Polaroid & Kırıntılar' : (audioObj ? 'Fikir Patlaması' : (aiParsed.moodLabel || 'Fikir Patlaması')),\n title: aiParsed.title || (audioObj ? 'Telegram Ses Kaydı' : (hasPhoto ? (imageCaption || 'Polaroid Anı') : undefined)),\n content: $(\"Transcribe a recording\")?.first()?.json?.text || msg.text || msg.caption || (hasPhoto ? 'Fotoğraf gönderildi' : 'Telegram Notu'),\n marginNotes: aiParsed.marginNotes || [hasPhoto ? '← Telegram fotoğrafı 📸' : (audioObj ? '← Telegram ses kaydı 🎙️' : '← Telegram ile atıldı 📱')],\n tags: aiParsed.tags || (hasPhoto ? ['telegram', 'polaroid'] : (audioObj ? ['telegram', 'voice'] : ['telegram'])),\n likes: 1,\n stampedText: aiParsed.stampedText || (hasPhoto ? 'POLAROID' : (audioObj ? 'VOICE NOTE' : 'TELEGRAM')),\n \n // Polaroid Fotoğraf alanları\n imageUrl: imageUrl || aiParsed.imageUrl,\n imageCaption: imageCaption || aiParsed.imageCaption,\n \n // Ses dosyası meta verileri\n audioDuration: audioDuration || aiParsed.audioDuration,\n audioTitle: audioTitle || aiParsed.audioTitle,\n audioUrl: audioUrl || aiParsed.audioUrl\n }\n};\n" + "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\nconst audioObj = msg?.voice || msg?.audio;\nlet audioDuration = undefined;\nlet audioTitle = undefined;\nlet audioUrl = undefined;\n\nif (audioObj) {\n const durSec = audioObj.duration || 0;\n const mins = Math.floor(durSec / 60).toString().padStart(2, '0');\n const secs = (durSec % 60).toString().padStart(2, '0');\n audioDuration = `${mins}:${secs}`;\n audioTitle = msg.audio?.file_name || `Telegram_Voice_Note_${durSec}s.m4a`;\n \n // Bunny CDN Yükleme Sonucu (HTTP Response veya Time-based URL)\n const uploadResult = $(\"Upload Voice to Bunny CDN\")?.first()?.json;\n const nowTs = Date.now();\n audioUrl = `https://cdn.ayrislegal.com/journal/voice_${nowTs}.m4a`;\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: 'audio',\n date: dateStr,\n timestamp: timeStr,\n mood: aiParsed.mood || 'spark',\n moodLabel: aiParsed.moodLabel || 'Fikir Patlaması',\n title: aiParsed.title || 'Telegram Ses Kaydı',\n content: $(\"Transcribe a recording\")?.first()?.json?.text || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Telegram ses kaydı 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: 'VOICE NOTE',\n audioDuration: audioDuration || '01:00',\n audioTitle: audioTitle || 'Telegram_Voice_Note.m4a',\n audioUrl: audioUrl\n }\n};\n" }, - "id": "1de7cf33-cdef-4ab9-b593-788d1cacb33b", + "id": "e149107d-0521-4ded-875e-53125a5d406b", "name": "Format Journal Payload1", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 1088, - 368 + 1040, + 288 ] }, { @@ -259,30 +253,286 @@ "jsonBody": "={{ JSON.stringify($json) }}", "options": {} }, - "id": "beb38874-0475-4862-b1b0-8b3d4e39ac06", + "id": "34b351a4-ca88-4f0e-978a-69fa42b09856", "name": "HTTP POST to Journal API1", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ - 1392, - 336 + 1260, + 288 ] }, { "parameters": { "chatId": "={{ $(\"Telegram Trigger\").first().json.message.chat.id }}", - "text": "=✅ *Not Deftere Karalandı!*\n\n📖 *Format:* {{ $(\"Format Journal Payload1\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload1\").first().json.moodLabel }}\n📌 *Başlık:* {{ $(\"Format Journal Payload1\").first().json.title || 'Başlıksız Not' }}\n🏷️ *Etiketler:* #{{ $(\"Format Journal Payload1\").first().json.tags.join(' #') }}\n\n✍️ _\"{{ $(\"Format Journal Payload1\").first().json.marginNotes[0] || '' }}\"_", + "text": "=✅ *Sesli Not Bunny CDN & Deftere Kaydedildi!*\n\n📻 *Format:* {{ $(\"Format Journal Payload1\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload1\").first().json.moodLabel }}\n📌 *Başlık:* {{ $(\"Format Journal Payload1\").first().json.title }}\n⏱️ *Süre:* {{ $(\"Format Journal Payload1\").first().json.audioDuration }}\n🔗 *Bunny CDN:* {{ $(\"Format Journal Payload1\").first().json.audioUrl }}", "additionalFields": { "parse_mode": "Markdown" } }, - "id": "ae28a7f7-4753-4296-971c-10ec83814697", + "id": "feac8b5a-3187-4fe7-a7c4-048490674594", "name": "Telegram Send Confirmation1", "type": "n8n-nodes-base.telegram", "typeVersion": 1.2, "position": [ - 1648, - 352 + 1480, + 288 + ], + "webhookId": "656440d2-a136-4926-a700-67a780664c91", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "resource": "file", + "fileId": "={{ $json.message.photo[$json.message.photo.length - 1].file_id }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 160, + 608 + ], + "id": "df183b43-0faf-4682-8071-37ac46b0fe01", + "name": "Get a file1", + "webhookId": "376048bf-8f95-4841-b048-46bdf3b82dfd", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "method": "PUT", + "url": "=https://storage.bunnycdn.net/apexlegal/journal/photo_{{ Date.now() }}.jpg", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "AccessKey", + "value": "1cc9536e-7e5c-480d-8c93ac12ec46-357a-4d81" + }, + { + "name": "Content-Type", + "value": "application/octet-stream" + } + ] + }, + "sendBody": true, + "specifyBody": "key", + "bodyKey": "data" + }, + "id": "bunny-upload-photo", + "name": "Upload Photo to Bunny CDN", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 380, + 608 + ] + }, + { + "parameters": { + "modelId": { + "__rl": true, + "value": "gpt-4o-mini", + "mode": "list", + "cachedResultName": "GPT-4O-MINI" + }, + "messages": { + "values": [ + { + "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen fotoğraf yazısını analiz ederek biçimlendirmek.\n\nSADECE aşağıdaki JSON formatında yanıt ver:\n{\n \"type\": \"polaroid\",\n \"mood\": \"visual\",\n \"moodLabel\": \"Polaroid & Kırıntılar\",\n \"title\": \"Polaroid Anı\",\n \"imageCaption\": \"Fotoğraf açıklaması\",\n \"stampedText\": \"POLAROID\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu\"],\n \"tags\": [\"fotoğraf\", \"polaroid\"]\n}\n", + "role": "system" + }, + { + "content": "=Analiz Edilecek Fotoğraf Açıklaması:\n\"{{ $('Telegram Trigger').item.json.message.caption || '' }}\"\n" + } + ] + }, + "options": { + "temperature": 0.7 + } + }, + "id": "250514cb-c0f7-47ac-b20e-fd2176e209db", + "name": "OpenAI Mood & Curator2", + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 1, + "position": [ + 600, + 608 + ], + "credentials": { + "openAiApi": { + "id": "dkfTY90eMiE7rE6q", + "name": "OpenAi account 2" + } + } + }, + { + "parameters": { + "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nconst nowTs = Date.now();\nconst imageUrl = `https://cdn.ayrislegal.com/journal/photo_${nowTs}.jpg`;\nconst imageCaption = msg.caption || aiParsed.imageCaption || 'Polaroid Anı';\n\nreturn {\n json: {\n id: `post-tg-${nowTs}`,\n type: 'polaroid',\n date: dateStr,\n timestamp: timeStr,\n mood: 'visual',\n moodLabel: 'Polaroid & Kırıntılar',\n title: aiParsed.title || imageCaption,\n content: msg.caption || 'Telegram fotoğrafı',\n marginNotes: aiParsed.marginNotes || ['← Telegram fotoğrafı 📸'],\n tags: aiParsed.tags || ['telegram', 'polaroid'],\n likes: 1,\n stampedText: 'POLAROID',\n imageUrl: imageUrl,\n imageCaption: imageCaption\n }\n};\n" + }, + "id": "4ef91a2e-304b-4454-a195-0025daae383a", + "name": "Format Journal Payload2", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 820, + 608 + ] + }, + { + "parameters": { + "method": "POST", + "url": "https://mstfyldz.com/api/posts", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Content-Type", + "value": "application/json" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify($json) }}", + "options": {} + }, + "id": "c249c1af-c3ca-4a4f-9540-231e1be109e4", + "name": "HTTP POST to Journal API2", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 1040, + 608 + ] + }, + { + "parameters": { + "chatId": "={{ $(\"Telegram Trigger\").first().json.message.chat.id }}", + "text": "=✅ *Fotoğraf Bunny CDN & Deftere Kaydedildi!*\n\n📸 *Format:* {{ $(\"Format Journal Payload2\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload2\").first().json.moodLabel }}\n📌 *Açıklama:* {{ $(\"Format Journal Payload2\").first().json.imageCaption }}\n🔗 *Bunny CDN:* {{ $(\"Format Journal Payload2\").first().json.imageUrl }}", + "additionalFields": { + "parse_mode": "Markdown" + } + }, + "id": "8433104f-9bb2-4afd-88e8-cdd9db756d99", + "name": "Telegram Send Confirmation2", + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 1260, + 608 + ], + "webhookId": "656440d2-a136-4926-a700-67a780664c91", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "modelId": { + "__rl": true, + "value": "gpt-4o-mini", + "mode": "list", + "cachedResultName": "GPT-4O-MINI" + }, + "messages": { + "values": [ + { + "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen metin notunu analiz ederek biçimlendirmek.\n\nSADECE aşağıdaki JSON formatında yanıt ver:\n{\n \"type\": \"sticky\" | \"notebook\" | \"code\",\n \"mood\": \"spark\" | \"focus\" | \"night\" | \"calm\",\n \"moodLabel\": \"Fikir Patlaması\" | \"Aşırı Odak & Kaos\" | \"Gece Melankolisi\" | \"Sakin & Karalama\",\n \"title\": \"Kısa ilgi çekici başlık veya null\",\n \"stampedText\": \"ONAYLANDI\" | \"COMPILED\" | \"DOĞRU TESPİT\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu\"],\n \"tags\": [\"etiket1\", \"etiket2\"]\n}\n", + "role": "system" + }, + { + "content": "=Analiz Edilecek Telegram Metni:\n\"{{ $json.message.text || '' }}\"\n" + } + ] + }, + "options": { + "temperature": 0.7 + } + }, + "id": "bd9bc72e-1873-4b89-b5ea-23b7d4cf6720", + "name": "OpenAI Mood & Curator", + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 1, + "position": [ + 160, + -60 + ], + "credentials": { + "openAiApi": { + "id": "dkfTY90eMiE7rE6q", + "name": "OpenAi account 2" + } + } + }, + { + "parameters": { + "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: aiParsed.type || 'sticky',\n date: dateStr,\n timestamp: timeStr,\n mood: aiParsed.mood || 'spark',\n moodLabel: aiParsed.moodLabel || 'Fikir Patlaması',\n title: aiParsed.title || undefined,\n content: msg.text || '',\n marginNotes: aiParsed.marginNotes || ['← Telegram ile atıldı 📱'],\n tags: aiParsed.tags || ['telegram'],\n likes: 1,\n stampedText: aiParsed.stampedText || 'TELEGRAM'\n }\n};\n" + }, + "id": "4dddf013-f5e6-4009-b202-d6b17aac525e", + "name": "Format Journal Payload", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 380, + -60 + ] + }, + { + "parameters": { + "method": "POST", + "url": "https://mstfyldz.com/api/posts", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Content-Type", + "value": "application/json" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify($json) }}", + "options": {} + }, + "id": "265e43cc-8c16-451d-8d79-5bfbf27d8687", + "name": "HTTP POST to Journal API", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 600, + -60 + ] + }, + { + "parameters": { + "chatId": "={{ $(\"Telegram Trigger\").first().json.message.chat.id }}", + "text": "=✅ *Not Deftere Karalandı!*\n\n📖 *Format:* {{ $(\"Format Journal Payload\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload\").first().json.moodLabel }}\n📌 *Başlık:* {{ $(\"Format Journal Payload\").first().json.title || 'Başlıksız Not' }}\n🏷️ *Etiketler:* #{{ $(\"Format Journal Payload\").first().json.tags.join(' #') }}\n\n✍️ _\"{{ $(\"Format Journal Payload\").first().json.marginNotes[0] || '' }}\"_", + "additionalFields": { + "parse_mode": "Markdown" + } + }, + "id": "c4afd057-d48f-421d-abd2-ab3a0e56bb02", + "name": "Telegram Send Confirmation", + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 820, + -60 ], "webhookId": "656440d2-a136-4926-a700-67a780664c91", "credentials": { @@ -299,47 +549,14 @@ "main": [ [ { - "node": "Security Check (Chat ID)1", + "node": "Switch", "type": "main", "index": 0 } ] ] }, - "OpenAI Mood & Curator": { - "main": [ - [ - { - "node": "Format Journal Payload", - "type": "main", - "index": 0 - } - ] - ] - }, - "Format Journal Payload": { - "main": [ - [ - { - "node": "HTTP POST to Journal API", - "type": "main", - "index": 0 - } - ] - ] - }, - "HTTP POST to Journal API": { - "main": [ - [ - { - "node": "Telegram Send Confirmation", - "type": "main", - "index": 0 - } - ] - ] - }, - "Security Check (Chat ID)1": { + "Switch": { "main": [ [ { @@ -348,6 +565,13 @@ "index": 0 } ], + [ + { + "node": "Get a file1", + "type": "main", + "index": 0 + } + ], [ { "node": "OpenAI Mood & Curator", @@ -358,6 +582,17 @@ ] }, "Get a file": { + "main": [ + [ + { + "node": "Upload Voice to Bunny CDN", + "type": "main", + "index": 0 + } + ] + ] + }, + "Upload Voice to Bunny CDN": { "main": [ [ { @@ -411,6 +646,94 @@ } ] ] + }, + "Get a file1": { + "main": [ + [ + { + "node": "Upload Photo to Bunny CDN", + "type": "main", + "index": 0 + } + ] + ] + }, + "Upload Photo to Bunny CDN": { + "main": [ + [ + { + "node": "OpenAI Mood & Curator2", + "type": "main", + "index": 0 + } + ] + ] + }, + "OpenAI Mood & Curator2": { + "main": [ + [ + { + "node": "Format Journal Payload2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Format Journal Payload2": { + "main": [ + [ + { + "node": "HTTP POST to Journal API2", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP POST to Journal API2": { + "main": [ + [ + { + "node": "Telegram Send Confirmation2", + "type": "main", + "index": 0 + } + ] + ] + }, + "OpenAI Mood & Curator": { + "main": [ + [ + { + "node": "Format Journal Payload", + "type": "main", + "index": 0 + } + ] + ] + }, + "Format Journal Payload": { + "main": [ + [ + { + "node": "HTTP POST to Journal API", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP POST to Journal API": { + "main": [ + [ + { + "node": "Telegram Send Confirmation", + "type": "main", + "index": 0 + } + ] + ] } }, "active": false, @@ -419,7 +742,7 @@ "binaryMode": "separate", "availableInMCP": false }, - "versionId": "4f1d3e57-5188-48f2-a4b7-762fd76cc29b", + "versionId": "1dc4d58d-38a9-431d-95f6-6e9ba059a401", "meta": { "templateCredsSetupCompleted": true, "instanceId": "79d13d1a6fcae5c2e451a2b02247a15904071a685f973aa3c0464bf9f4cd5f82" diff --git a/n8n_journal_workflow.json b/n8n_journal_workflow.json index a678543..d09a165 100644 --- a/n8n_journal_workflow.json +++ b/n8n_journal_workflow.json @@ -5,66 +5,234 @@ "parameters": { "updates": [ "message" - ] + ], + "additionalFields": {} }, - "id": "node-telegram-trigger", + "id": "13ae8c1e-3cd2-4365-a6b2-8f3301a7f9db", "name": "Telegram Trigger", "type": "n8n-nodes-base.telegramTrigger", "typeVersion": 1.1, "position": [ - 100, - 300 - ] + -304, + 320 + ], + "webhookId": "ede016a9-34a3-4fc8-8725-291bd02403a2", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } }, { "parameters": { - "conditions": { - "number": [ + "rules": { + "values": [ { - "value1": "={{ $json.message.from.id }}", - "operation": "equal", - "value2": 123456789 + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "leftValue": "={{ $json.message.voice }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + }, + "id": "e71bb63b-56de-4030-a1e1-18bc62a5fd57" + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "bfacad39-bcd9-447e-bba0-82192573e08f", + "leftValue": "={{ $json.message.photo[0].file_id }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + } + } + ], + "combinator": "and" + } + }, + { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 3 + }, + "conditions": [ + { + "id": "3e81a46e-cf60-4e2a-95ef-1d946fe7b525", + "leftValue": "={{ $json.message.text }}", + "rightValue": "", + "operator": { + "type": "string", + "operation": "notEmpty", + "singleValue": true + } + } + ], + "combinator": "and" + } } ] - } + }, + "options": {} }, - "id": "node-auth-check", - "name": "Security Check (Chat ID)", - "type": "n8n-nodes-base.if", - "typeVersion": 1, + "type": "n8n-nodes-base.switch", + "typeVersion": 3.4, "position": [ - 320, - 300 + -96, + 320 + ], + "id": "baebb5f0-df5f-4b90-98cb-eaf7fc3f3405", + "name": "Switch" + }, + { + "parameters": { + "resource": "file", + "fileId": "={{ $json.message.voice.file_id }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 160, + 288 + ], + "id": "b9f0a086-36db-462b-ae75-460b6ae6bf9a", + "name": "Get a file", + "webhookId": "376048bf-8f95-4841-b048-46bdf3b82dfd", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "method": "PUT", + "url": "=https://storage.bunnycdn.net/apexlegal/journal/voice_{{ Date.now() }}.m4a", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "AccessKey", + "value": "1cc9536e-7e5c-480d-8c93ac12ec46-357a-4d81" + }, + { + "name": "Content-Type", + "value": "application/octet-stream" + } + ] + }, + "sendBody": true, + "specifyBody": "key", + "bodyKey": "data" + }, + "id": "bunny-upload-voice", + "name": "Upload Voice to Bunny CDN", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 380, + 288 ] }, { "parameters": { - "model": "gpt-4o-mini", + "resource": "audio", + "operation": "transcribe", + "binaryPropertyName": "=data", + "options": {} + }, + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 2.1, + "position": [ + 600, + 288 + ], + "id": "5942e900-db59-4a94-a68b-99f1f0480fce", + "name": "Transcribe a recording", + "credentials": { + "openAiApi": { + "id": "dkfTY90eMiE7rE6q", + "name": "OpenAi account 2" + } + } + }, + { + "parameters": { + "modelId": { + "__rl": true, + "value": "gpt-4o-mini", + "mode": "list", + "cachedResultName": "GPT-4O-MINI" + }, + "messages": { + "values": [ + { + "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen ses transkriptini analiz ederek günlüğün tasarım diline uygun biçimlendirmek.\n\nSADECE aşağıdaki JSON formatında yanıt ver:\n{\n \"type\": \"audio\",\n \"mood\": \"spark\" | \"focus\" | \"night\" | \"calm\",\n \"moodLabel\": \"Fikir Patlaması\" | \"Aşırı Odak & Kaos\" | \"Gece Melankolisi\" | \"Sakin & Karalama\",\n \"title\": \"Kısa ilgi çekici başlık\",\n \"stampedText\": \"VOICE NOTE\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu\"],\n \"tags\": [\"ses-kaydı\", \"düşünceler\"]\n}\n", + "role": "system" + }, + { + "content": "=Analiz Edilecek Transkript:\n\"{{ $json.text }}\"\n" + } + ] + }, "options": { "temperature": 0.7 - }, - "prompt": "=Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün AI yayın editörüsün. Telegram'dan gelen bu içeriği analiz et ve SADECE geçerli bir JSON nesnesi döndür.\n\nGelen Metin: \"{{ $json.message.text || $json.message.caption || '' }}\"\n\nKurallar:\n- mood: 'spark' | 'focus' | 'night' | 'calm' | 'visual'\n- moodLabel: 'Fikir Patlaması' | 'Aşırı Odak & Kaos' | 'Gece Melankolisi' | 'Sakin & Karalama' | 'Polaroid & Kırıntılar'\n- type: 'sticky' | 'notebook' | 'code' | 'polaroid' | 'audio'\n- stampedText: 'ONAYLANDI' | 'COMPILED' | 'DOĞRU TESPİT' | 'SUÇLU' | 'KARALAMA'\n- marginNotes: [ \"← samimi el yazısı kenar notu\" ]\n- tags: [ \"etiket1\", \"etiket2\" ]\n- title: \"Kısa ilgi çekici başlık (varsa metin yoksa null)\"\n\nBeklenen Çıktı Örneği:\n{\n \"type\": \"sticky\",\n \"mood\": \"spark\",\n \"moodLabel\": \"Fikir Patlaması\",\n \"title\": \"Sadelik Üzerine\",\n \"stampedText\": \"ONAYLANDI\",\n \"marginNotes\": [\"← tam olarak bu!\"],\n \"tags\": [\"felsefe\", \"yazılım\"]\n}" + } }, - "id": "node-openai-curator", - "name": "OpenAI Mood & Curator", + "id": "fbecf695-5165-477f-9a1b-2f116572edf5", + "name": "OpenAI Mood & Curator1", "type": "@n8n/n8n-nodes-langchain.openAi", "typeVersion": 1, "position": [ - 560, - 300 - ] + 820, + 288 + ], + "credentials": { + "openAiApi": { + "id": "dkfTY90eMiE7rE6q", + "name": "OpenAi account 2" + } + } }, { "parameters": { - "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\n// Ses Kaydı (Voice / Audio) Tespiti ve Süre Hesabı\nconst audioObj = msg?.voice || msg?.audio;\nlet audioDuration = undefined;\nlet audioTitle = undefined;\nlet audioUrl = undefined;\n\nif (audioObj) {\n const durSec = audioObj.duration || 0;\n const mins = Math.floor(durSec / 60).toString().padStart(2, '0');\n const secs = (durSec % 60).toString().padStart(2, '0');\n audioDuration = `${mins}:${secs}`;\n audioTitle = msg.audio?.file_name || `Telegram_Voice_Note_${durSec}s.m4a`;\n \n // Telegram Get File düğümünden gelen dosya yolu (Varsa)\n const filePath = $(\"Telegram Get File\")?.first()?.json?.result?.file_path;\n if (filePath) {\n audioUrl = `https://api.telegram.org/file/bot[YOUR_BOT_TOKEN]/${filePath}`;\n }\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: audioObj ? 'audio' : (aiParsed.type || 'sticky'),\n date: dateStr,\n timestamp: timeStr,\n mood: aiParsed.mood || 'spark',\n moodLabel: aiParsed.moodLabel || 'Fikir Patlaması',\n title: aiParsed.title || (audioObj ? 'Telegram Ses Kaydı' : undefined),\n content: $(\"OpenAI Whisper\")?.first()?.json?.text || msg.text || msg.caption || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Telegram ses kaydı 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: aiParsed.stampedText || 'VOICE NOTE',\n audioDuration: audioDuration || aiParsed.audioDuration,\n audioTitle: audioTitle || aiParsed.audioTitle,\n audioUrl: audioUrl || aiParsed.audioUrl\n }\n};\n" + "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\nconst audioObj = msg?.voice || msg?.audio;\nlet audioDuration = undefined;\nlet audioTitle = undefined;\nlet audioUrl = undefined;\n\nif (audioObj) {\n const durSec = audioObj.duration || 0;\n const mins = Math.floor(durSec / 60).toString().padStart(2, '0');\n const secs = (durSec % 60).toString().padStart(2, '0');\n audioDuration = `${mins}:${secs}`;\n audioTitle = msg.audio?.file_name || `Telegram_Voice_Note_${durSec}s.m4a`;\n \n const nowTs = Date.now();\n audioUrl = `https://cdn.ayrislegal.com/journal/voice_${nowTs}.m4a`;\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: 'audio',\n date: dateStr,\n timestamp: timeStr,\n mood: aiParsed.mood || 'spark',\n moodLabel: aiParsed.moodLabel || 'Fikir Patlaması',\n title: aiParsed.title || 'Telegram Ses Kaydı',\n content: $(\"Transcribe a recording\")?.first()?.json?.text || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Telegram ses kaydı 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: 'VOICE NOTE',\n audioDuration: audioDuration || '01:00',\n audioTitle: audioTitle || 'Telegram_Voice_Note.m4a',\n audioUrl: audioUrl\n }\n};\n" }, - "id": "node-code-formatter", - "name": "Format Journal Payload", + "id": "e149107d-0521-4ded-875e-53125a5d406b", + "name": "Format Journal Payload1", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ - 780, - 300 + 1040, + 288 ] }, { @@ -82,15 +250,272 @@ }, "sendBody": true, "specifyBody": "json", - "jsonBody": "={{ JSON.stringify($json) }}" + "jsonBody": "={{ JSON.stringify($json) }}", + "options": {} }, - "id": "node-http-post", + "id": "34b351a4-ca88-4f0e-978a-69fa42b09856", + "name": "HTTP POST to Journal API1", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 1260, + 288 + ] + }, + { + "parameters": { + "chatId": "={{ $(\"Telegram Trigger\").first().json.message.chat.id }}", + "text": "=✅ *Sesli Not Bunny CDN & Deftere Kaydedildi!*\n\n📻 *Format:* {{ $(\"Format Journal Payload1\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload1\").first().json.moodLabel }}\n📌 *Başlık:* {{ $(\"Format Journal Payload1\").first().json.title }}\n⏱️ *Süre:* {{ $(\"Format Journal Payload1\").first().json.audioDuration }}\n🔗 *Bunny CDN:* {{ $(\"Format Journal Payload1\").first().json.audioUrl }}", + "additionalFields": { + "parse_mode": "Markdown" + } + }, + "id": "feac8b5a-3187-4fe7-a7c4-048490674594", + "name": "Telegram Send Confirmation1", + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 1480, + 288 + ], + "webhookId": "656440d2-a136-4926-a700-67a780664c91", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "resource": "file", + "fileId": "={{ $json.message.photo[$json.message.photo.length - 1].file_id }}", + "additionalFields": {} + }, + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 160, + 608 + ], + "id": "df183b43-0faf-4682-8071-37ac46b0fe01", + "name": "Get a file1", + "webhookId": "376048bf-8f95-4841-b048-46bdf3b82dfd", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "method": "PUT", + "url": "=https://storage.bunnycdn.net/apexlegal/journal/photo_{{ Date.now() }}.jpg", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "AccessKey", + "value": "1cc9536e-7e5c-480d-8c93ac12ec46-357a-4d81" + }, + { + "name": "Content-Type", + "value": "application/octet-stream" + } + ] + }, + "sendBody": true, + "specifyBody": "key", + "bodyKey": "data" + }, + "id": "bunny-upload-photo", + "name": "Upload Photo to Bunny CDN", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 380, + 608 + ] + }, + { + "parameters": { + "modelId": { + "__rl": true, + "value": "gpt-4o-mini", + "mode": "list", + "cachedResultName": "GPT-4O-MINI" + }, + "messages": { + "values": [ + { + "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen fotoğraf yazısını analiz ederek biçimlendirmek.\n\nSADECE aşağıdaki JSON formatında yanıt ver:\n{\n \"type\": \"polaroid\",\n \"mood\": \"visual\",\n \"moodLabel\": \"Polaroid & Kırıntılar\",\n \"title\": \"Polaroid Anı\",\n \"imageCaption\": \"Fotoğraf açıklaması\",\n \"stampedText\": \"POLAROID\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu\"],\n \"tags\": [\"fotoğraf\", \"polaroid\"]\n}\n", + "role": "system" + }, + { + "content": "=Analiz Edilecek Fotoğraf Açıklaması:\n\"{{ $('Telegram Trigger').item.json.message.caption || '' }}\"\n" + } + ] + }, + "options": { + "temperature": 0.7 + } + }, + "id": "250514cb-c0f7-47ac-b20e-fd2176e209db", + "name": "OpenAI Mood & Curator2", + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 1, + "position": [ + 600, + 608 + ], + "credentials": { + "openAiApi": { + "id": "dkfTY90eMiE7rE6q", + "name": "OpenAi account 2" + } + } + }, + { + "parameters": { + "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nconst nowTs = Date.now();\nconst imageUrl = `https://cdn.ayrislegal.com/journal/photo_${nowTs}.jpg`;\nconst imageCaption = msg.caption || aiParsed.imageCaption || 'Polaroid Anı';\n\nreturn {\n json: {\n id: `post-tg-${nowTs}`,\n type: 'polaroid',\n date: dateStr,\n timestamp: timeStr,\n mood: 'visual',\n moodLabel: 'Polaroid & Kırıntılar',\n title: aiParsed.title || imageCaption,\n content: msg.caption || 'Telegram fotoğrafı',\n marginNotes: aiParsed.marginNotes || ['← Telegram fotoğrafı 📸'],\n tags: aiParsed.tags || ['telegram', 'polaroid'],\n likes: 1,\n stampedText: 'POLAROID',\n imageUrl: imageUrl,\n imageCaption: imageCaption\n }\n};\n" + }, + "id": "4ef91a2e-304b-4454-a195-0025daae383a", + "name": "Format Journal Payload2", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 820, + 608 + ] + }, + { + "parameters": { + "method": "POST", + "url": "https://mstfyldz.com/api/posts", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Content-Type", + "value": "application/json" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify($json) }}", + "options": {} + }, + "id": "c249c1af-c3ca-4a4f-9540-231e1be109e4", + "name": "HTTP POST to Journal API2", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.1, + "position": [ + 1040, + 608 + ] + }, + { + "parameters": { + "chatId": "={{ $(\"Telegram Trigger\").first().json.message.chat.id }}", + "text": "=✅ *Fotoğraf Bunny CDN & Deftere Kaydedildi!*\n\n📸 *Format:* {{ $(\"Format Journal Payload2\").first().json.type }}\n💡 *Mood:* {{ $(\"Format Journal Payload2\").first().json.moodLabel }}\n📌 *Açıklama:* {{ $(\"Format Journal Payload2\").first().json.imageCaption }}\n🔗 *Bunny CDN:* {{ $(\"Format Journal Payload2\").first().json.imageUrl }}", + "additionalFields": { + "parse_mode": "Markdown" + } + }, + "id": "8433104f-9bb2-4afd-88e8-cdd9db756d99", + "name": "Telegram Send Confirmation2", + "type": "n8n-nodes-base.telegram", + "typeVersion": 1.2, + "position": [ + 1260, + 608 + ], + "webhookId": "656440d2-a136-4926-a700-67a780664c91", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } + }, + { + "parameters": { + "modelId": { + "__rl": true, + "value": "gpt-4o-mini", + "mode": "list", + "cachedResultName": "GPT-4O-MINI" + }, + "messages": { + "values": [ + { + "content": "Sen Mustafa Yıldız'ın (mstfyldz) kişisel dijital günlüğünün yapay zeka yayın editörüsün.\nGörevin, Telegram'dan gönderilen metin notunu analiz ederek biçimlendirmek.\n\nSADECE aşağıdaki JSON formatında yanıt ver:\n{\n \"type\": \"sticky\" | \"notebook\" | \"code\",\n \"mood\": \"spark\" | \"focus\" | \"night\" | \"calm\",\n \"moodLabel\": \"Fikir Patlaması\" | \"Aşırı Odak & Kaos\" | \"Gece Melankolisi\" | \"Sakin & Karalama\",\n \"title\": \"Kısa ilgi çekici başlık veya null\",\n \"stampedText\": \"ONAYLANDI\" | \"COMPILED\" | \"DOĞRU TESPİT\",\n \"marginNotes\": [\"← samimi el yazısı kenar notu\"],\n \"tags\": [\"etiket1\", \"etiket2\"]\n}\n", + "role": "system" + }, + { + "content": "=Analiz Edilecek Telegram Metni:\n\"{{ $json.message.text || '' }}\"\n" + } + ] + }, + "options": { + "temperature": 0.7 + } + }, + "id": "bd9bc72e-1873-4b89-b5ea-23b7d4cf6720", + "name": "OpenAI Mood & Curator", + "type": "@n8n/n8n-nodes-langchain.openAi", + "typeVersion": 1, + "position": [ + 160, + -60 + ], + "credentials": { + "openAiApi": { + "id": "dkfTY90eMiE7rE6q", + "name": "OpenAi account 2" + } + } + }, + { + "parameters": { + "jsCode": "const msg = $(\"Telegram Trigger\").first().json.message;\nlet aiParsed = {};\ntry {\n const rawText = $input.first().json.message?.content || $input.first().json.text || '{}';\n aiParsed = JSON.parse(rawText.replace(/```json|```/g, '').trim());\n} catch (e) {\n aiParsed = {};\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' });\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: aiParsed.type || 'sticky',\n date: dateStr,\n timestamp: timeStr,\n mood: aiParsed.mood || 'spark',\n moodLabel: aiParsed.moodLabel || 'Fikir Patlaması',\n title: aiParsed.title || undefined,\n content: msg.text || '',\n marginNotes: aiParsed.marginNotes || ['← Telegram ile atıldı 📱'],\n tags: aiParsed.tags || ['telegram'],\n likes: 1,\n stampedText: aiParsed.stampedText || 'TELEGRAM'\n }\n};\n" + }, + "id": "4dddf013-f5e6-4009-b202-d6b17aac525e", + "name": "Format Journal Payload", + "type": "n8n-nodes-base.code", + "typeVersion": 2, + "position": [ + 380, + -60 + ] + }, + { + "parameters": { + "method": "POST", + "url": "https://mstfyldz.com/api/posts", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Content-Type", + "value": "application/json" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify($json) }}", + "options": {} + }, + "id": "265e43cc-8c16-451d-8d79-5bfbf27d8687", "name": "HTTP POST to Journal API", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.1, "position": [ - 1000, - 300 + 600, + -60 ] }, { @@ -101,30 +526,52 @@ "parse_mode": "Markdown" } }, - "id": "node-telegram-reply", + "id": "c4afd057-d48f-421d-abd2-ab3a0e56bb02", "name": "Telegram Send Confirmation", "type": "n8n-nodes-base.telegram", "typeVersion": 1.2, "position": [ - 1220, - 300 - ] + 820, + -60 + ], + "webhookId": "656440d2-a136-4926-a700-67a780664c91", + "credentials": { + "telegramApi": { + "id": "EHAAmsKUkdoY5dGj", + "name": "#1Piksel" + } + } } ], + "pinData": {}, "connections": { "Telegram Trigger": { "main": [ [ { - "node": "Security Check (Chat ID)", + "node": "Switch", "type": "main", "index": 0 } ] ] }, - "Security Check (Chat ID)": { + "Switch": { "main": [ + [ + { + "node": "Get a file", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Get a file1", + "type": "main", + "index": 0 + } + ], [ { "node": "OpenAI Mood & Curator", @@ -134,6 +581,127 @@ ] ] }, + "Get a file": { + "main": [ + [ + { + "node": "Upload Voice to Bunny CDN", + "type": "main", + "index": 0 + } + ] + ] + }, + "Upload Voice to Bunny CDN": { + "main": [ + [ + { + "node": "Transcribe a recording", + "type": "main", + "index": 0 + } + ] + ] + }, + "Transcribe a recording": { + "main": [ + [ + { + "node": "OpenAI Mood & Curator1", + "type": "main", + "index": 0 + } + ] + ] + }, + "OpenAI Mood & Curator1": { + "main": [ + [ + { + "node": "Format Journal Payload1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Format Journal Payload1": { + "main": [ + [ + { + "node": "HTTP POST to Journal API1", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP POST to Journal API1": { + "main": [ + [ + { + "node": "Telegram Send Confirmation1", + "type": "main", + "index": 0 + } + ] + ] + }, + "Get a file1": { + "main": [ + [ + { + "node": "Upload Photo to Bunny CDN", + "type": "main", + "index": 0 + } + ] + ] + }, + "Upload Photo to Bunny CDN": { + "main": [ + [ + { + "node": "OpenAI Mood & Curator2", + "type": "main", + "index": 0 + } + ] + ] + }, + "OpenAI Mood & Curator2": { + "main": [ + [ + { + "node": "Format Journal Payload2", + "type": "main", + "index": 0 + } + ] + ] + }, + "Format Journal Payload2": { + "main": [ + [ + { + "node": "HTTP POST to Journal API2", + "type": "main", + "index": 0 + } + ] + ] + }, + "HTTP POST to Journal API2": { + "main": [ + [ + { + "node": "Telegram Send Confirmation2", + "type": "main", + "index": 0 + } + ] + ] + }, "OpenAI Mood & Curator": { "main": [ [ @@ -167,5 +735,18 @@ ] ] } - } + }, + "active": false, + "settings": { + "executionOrder": "v1", + "binaryMode": "separate", + "availableInMCP": false + }, + "versionId": "1dc4d58d-38a9-431d-95f6-6e9ba059a401", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "79d13d1a6fcae5c2e451a2b02247a15904071a685f973aa3c0464bf9f4cd5f82" + }, + "id": "DOB8eXjqfTrFN2F1sE5_R", + "tags": [] } diff --git a/next.config.ts b/next.config.ts index eb510f1..8698080 100644 --- a/next.config.ts +++ b/next.config.ts @@ -9,6 +9,11 @@ const nextConfig: NextConfig = { hostname: "api.telegram.org", pathname: "/**", }, + { + protocol: "https", + hostname: "cdn.ayrislegal.com", + pathname: "/**", + }, { protocol: "https", hostname: "images.unsplash.com",