diff --git a/mstfyldz Journal - Full Telegram & AI Automation.json b/mstfyldz Journal - Full Telegram & AI Automation.json index 2a04dec..edcc09c 100644 --- a/mstfyldz Journal - Full Telegram & AI Automation.json +++ b/mstfyldz Journal - Full Telegram & AI Automation.json @@ -233,7 +233,7 @@ }, { "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 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 || `Voice_Note_${durSec}s.m4a`;\n \n const voiceFileId = audioObj.file_id;\n audioUrl = `https://cdn.ayrislegal.com/journal/voice_${voiceFileId}.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 || 'Voice Note',\n content: $(\"Transcribe a recording\")?.first()?.json?.text || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Voice note 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: 'VOICE NOTE',\n audioDuration: audioDuration || '01:00',\n audioTitle: audioTitle || 'Voice_Note.m4a',\n audioUrl: 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 || `Voice_Note_${durSec}s.m4a`;\n \n const voiceFileId = audioObj.file_id;\n audioUrl = `https://cdn.ayrislegal.com/journal/voice_${voiceFileId}.m4a`;\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'Europe/Istanbul' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Istanbul' });\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 || 'Voice Note',\n content: $(\"Transcribe a recording\")?.first()?.json?.text || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Voice note 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: 'VOICE NOTE',\n audioDuration: audioDuration || '01:00',\n audioTitle: audioTitle || 'Voice_Note.m4a',\n audioUrl: audioUrl\n }\n};\n" }, "id": "32fe7f7c-fbae-4f19-8944-b530d4bceb1c", "name": "Format Journal Payload1", @@ -392,7 +392,7 @@ }, { "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 photoObj = msg?.photo ? msg.photo[msg.photo.length - 1] : null;\nconst photoFileId = photoObj?.file_id;\nconst imageUrl = photoFileId \n ? `https://cdn.ayrislegal.com/journal/photo_${photoFileId}.jpg` \n : `https://cdn.ayrislegal.com/journal/photo_${Date.now()}.jpg`;\n\nconst rawCaption = (msg.caption || '').trim();\nlet title = undefined;\nlet content = rawCaption || 'Fotoğraf Anısı';\n\nif (rawCaption.includes('\\n')) {\n // Telegram'da ilk satır BAŞLIK, alt satırlar İÇERİK\n const lines = rawCaption.split('\\n');\n title = lines[0].trim();\n content = lines.slice(1).join('\\n').trim() || lines[0].trim();\n} else {\n // Tek satırsa başlığı Yapay Zeka üretsin, metin içerik kalsın\n title = aiParsed.title || rawCaption || 'Polaroid Anı';\n}\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: 'polaroid',\n date: dateStr,\n timestamp: timeStr,\n mood: 'visual',\n moodLabel: 'Polaroid & Kırıntılar',\n title: title,\n content: content,\n marginNotes: aiParsed.marginNotes || ['← Telegram fotoğrafı 📸'],\n tags: aiParsed.tags || ['telegram', 'polaroid'],\n likes: 1,\n stampedText: 'POLAROID',\n imageUrl: imageUrl,\n imageCaption: rawCaption || title\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 now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'Europe/Istanbul' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Istanbul' });\n\nconst photoObj = msg?.photo ? msg.photo[msg.photo.length - 1] : null;\nconst photoFileId = photoObj?.file_id;\nconst imageUrl = photoFileId \n ? `https://cdn.ayrislegal.com/journal/photo_${photoFileId}.jpg` \n : `https://cdn.ayrislegal.com/journal/photo_${Date.now()}.jpg`;\n\nconst rawCaption = (msg.caption || '').trim();\nlet title = undefined;\nlet content = rawCaption || 'Fotoğraf Anısı';\n\nif (rawCaption.includes('\\n')) {\n // Telegram'da ilk satır BAŞLIK, alt satırlar İÇERİK\n const lines = rawCaption.split('\\n');\n title = lines[0].trim();\n content = lines.slice(1).join('\\n').trim() || lines[0].trim();\n} else {\n // Tek satırsa başlığı Yapay Zeka üretsin, metin içerik kalsın\n title = aiParsed.title || rawCaption || 'Polaroid Anı';\n}\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: 'polaroid',\n date: dateStr,\n timestamp: timeStr,\n mood: 'visual',\n moodLabel: 'Polaroid & Kırıntılar',\n title: title,\n content: content,\n marginNotes: aiParsed.marginNotes || ['← Telegram fotoğrafı 📸'],\n tags: aiParsed.tags || ['telegram', 'polaroid'],\n likes: 1,\n stampedText: 'POLAROID',\n imageUrl: imageUrl,\n imageCaption: rawCaption || title\n }\n};\n" }, "id": "ea3e4585-66bf-4dbc-b140-5da6e0b15b2d", "name": "Format Journal Payload2", @@ -494,7 +494,7 @@ }, { "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" + "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', timeZone: 'Europe/Istanbul' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Istanbul' });\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": "3a5d2072-3a5b-4614-9204-380d543889bb", "name": "Format Journal Payload", diff --git a/n8n_journal_workflow.json b/n8n_journal_workflow.json index 3fe75a7..d433a64 100644 --- a/n8n_journal_workflow.json +++ b/n8n_journal_workflow.json @@ -233,7 +233,7 @@ }, { "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 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 || `Voice_Note_${durSec}s.m4a`;\n \n const voiceFileId = audioObj.file_id;\n audioUrl = `https://cdn.ayrislegal.com/journal/voice_${voiceFileId}.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 || 'Voice Note',\n content: $(\"Transcribe a recording\")?.first()?.json?.text || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Voice note 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: 'VOICE NOTE',\n audioDuration: audioDuration || '01:00',\n audioTitle: audioTitle || 'Voice_Note.m4a',\n audioUrl: 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 || `Voice_Note_${durSec}s.m4a`;\n \n const voiceFileId = audioObj.file_id;\n audioUrl = `https://cdn.ayrislegal.com/journal/voice_${voiceFileId}.m4a`;\n}\n\nconst now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'Europe/Istanbul' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Istanbul' });\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 || 'Voice Note',\n content: $(\"Transcribe a recording\")?.first()?.json?.text || 'Sesli Not',\n marginNotes: aiParsed.marginNotes || ['← Voice note 🎙️'],\n tags: aiParsed.tags || ['telegram', 'voice'],\n likes: 1,\n stampedText: 'VOICE NOTE',\n audioDuration: audioDuration || '01:00',\n audioTitle: audioTitle || 'Voice_Note.m4a',\n audioUrl: audioUrl\n }\n};\n" }, "id": "32fe7f7c-fbae-4f19-8944-b530d4bceb1c", "name": "Format Journal Payload1", @@ -392,7 +392,7 @@ }, { "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 photoObj = msg?.photo ? msg.photo[msg.photo.length - 1] : null;\nconst photoFileId = photoObj?.file_id;\nconst imageUrl = photoFileId \n ? `https://cdn.ayrislegal.com/journal/photo_${photoFileId}.jpg` \n : `https://cdn.ayrislegal.com/journal/photo_${Date.now()}.jpg`;\n\nconst rawCaption = (msg.caption || '').trim();\nlet title = undefined;\nlet content = rawCaption || 'Fotoğraf Anısı';\n\nif (rawCaption.includes('\\n')) {\n // Telegram'da ilk satır BAŞLIK, alt satırlar İÇERİK\n const lines = rawCaption.split('\\n');\n title = lines[0].trim();\n content = lines.slice(1).join('\\n').trim() || lines[0].trim();\n} else {\n // Tek satırsa başlığı Yapay Zeka üretsin, metin içerik kalsın\n title = aiParsed.title || rawCaption || 'Polaroid Anı';\n}\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: 'polaroid',\n date: dateStr,\n timestamp: timeStr,\n mood: 'visual',\n moodLabel: 'Polaroid & Kırıntılar',\n title: title,\n content: content,\n marginNotes: aiParsed.marginNotes || ['← Telegram fotoğrafı 📸'],\n tags: aiParsed.tags || ['telegram', 'polaroid'],\n likes: 1,\n stampedText: 'POLAROID',\n imageUrl: imageUrl,\n imageCaption: rawCaption || title\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 now = new Date();\nconst dateStr = now.toLocaleDateString('tr-TR', { day: '2-digit', month: 'short', year: 'numeric', timeZone: 'Europe/Istanbul' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Istanbul' });\n\nconst photoObj = msg?.photo ? msg.photo[msg.photo.length - 1] : null;\nconst photoFileId = photoObj?.file_id;\nconst imageUrl = photoFileId \n ? `https://cdn.ayrislegal.com/journal/photo_${photoFileId}.jpg` \n : `https://cdn.ayrislegal.com/journal/photo_${Date.now()}.jpg`;\n\nconst rawCaption = (msg.caption || '').trim();\nlet title = undefined;\nlet content = rawCaption || 'Fotoğraf Anısı';\n\nif (rawCaption.includes('\\n')) {\n // Telegram'da ilk satır BAŞLIK, alt satırlar İÇERİK\n const lines = rawCaption.split('\\n');\n title = lines[0].trim();\n content = lines.slice(1).join('\\n').trim() || lines[0].trim();\n} else {\n // Tek satırsa başlığı Yapay Zeka üretsin, metin içerik kalsın\n title = aiParsed.title || rawCaption || 'Polaroid Anı';\n}\n\nreturn {\n json: {\n id: `post-tg-${Date.now()}`,\n type: 'polaroid',\n date: dateStr,\n timestamp: timeStr,\n mood: 'visual',\n moodLabel: 'Polaroid & Kırıntılar',\n title: title,\n content: content,\n marginNotes: aiParsed.marginNotes || ['← Telegram fotoğrafı 📸'],\n tags: aiParsed.tags || ['telegram', 'polaroid'],\n likes: 1,\n stampedText: 'POLAROID',\n imageUrl: imageUrl,\n imageCaption: rawCaption || title\n }\n};\n" }, "id": "ea3e4585-66bf-4dbc-b140-5da6e0b15b2d", "name": "Format Journal Payload2", @@ -494,7 +494,7 @@ }, { "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" + "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', timeZone: 'Europe/Istanbul' }).toUpperCase();\nconst timeStr = now.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit', timeZone: 'Europe/Istanbul' });\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": "3a5d2072-3a5b-4614-9204-380d543889bb", "name": "Format Journal Payload",