{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "d52e085f-2711-4935-8887-d1a6afd9169e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4544,
        -1136
      ],
      "parameters": {
        "width": 480,
        "height": 832,
        "content": "## Untitled workflow\n\n### How it works\n\nThis workflow turns Telegram messages into LinkedIn posts. It receives a Telegram update, responds to /start, routes text or voice input, transcribes voice messages with Groq Whisper, generates a post with Groq Llama, publishes it to LinkedIn, and sends the result back through Telegram.\n\n### Setup steps\n\n- Configure Telegram bot credentials for the trigger and Telegram action nodes, including the bot token and any required chat settings.\n- Add Groq API authentication to the HTTP Request nodes for both Whisper transcription and Llama chat completion requests.\n- Configure LinkedIn credentials and set the correct posting target, such as a personal profile or organization page.\n- Review the JavaScript parsing/preparation nodes to ensure they match the Telegram payload format and the expected Groq response structure.\n\n### Customization\n\nAdjust the Groq Llama prompt to control tone, length, hashtags, and formatting of the LinkedIn post. You can also modify the /start welcome text, supported Telegram input types, or whether the workflow publishes immediately versus sending a draft for approval."
      },
      "typeVersion": 1
    },
    {
      "id": "5443e003-7cae-4fa2-b74c-a06160c41d3a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5104,
        -1136
      ],
      "parameters": {
        "color": 7,
        "width": 640,
        "height": 544,
        "content": "## Telegram entry handling\n\nReceives incoming Telegram messages, checks whether the user sent /start, and sends a welcome message for that command before continuing normal messages into the workflow."
      },
      "typeVersion": 1
    },
    {
      "id": "e11d677f-5222-49a3-85ae-29368e4f08f7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        5776,
        -1024
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 432,
        "content": "## Route and transcribe input\n\nDetermines whether the Telegram input is audio or text. Voice messages are downloaded, prepared with code, and transcribed through Groq Whisper, while text messages continue directly toward post generation."
      },
      "typeVersion": 1
    },
    {
      "id": "3cfb91a3-5688-4009-be92-e32c661ff639",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6656,
        -928
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 336,
        "content": "## Generate LinkedIn content\n\nSends the text or transcription to Groq Llama to draft a LinkedIn post, then parses the model response into a format suitable for publishing."
      },
      "typeVersion": 1
    },
    {
      "id": "b7556c23-6770-4e3c-bc7a-2665736e95ae",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        7104,
        -912
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "## Publish and confirm\n\nPublishes the generated content to LinkedIn and then sends the ready post or confirmation back to Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "2ea73a4d-4a27-4591-99ab-e8e912512785",
      "name": "Post to Chat Completion API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6704,
        -752
      ],
      "parameters": {
        "url": "https://api.groq.com/openai/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={{\n  {\n    \"model\": \"llama-3.1-8b-instant\",\n    \"messages\": [\n      {\n        \"role\": \"system\",\n        \"content\": `You are a master content strategist, LinkedIn ghostwriter, and viral Twitter creator. You are writing on behalf of a Chief AI Officer at an AI startup. Write with high-level authority, zero generic marketing fluff, and a strong focus on real-world engineering realities, business ROI, and tactical leadership. Use short, punchy paragraphs and high-impact hooks.\n\nYour job is to convert input ideas into high-converting social media outputs. Use a hook line\n\nCRITICAL INSTRUCTION: Return ONLY a valid JSON object with NO extra code blocks or conversational text. Do not put an outline or summary in linkedin_text\u2014put the COMPLETE, ready-to-publish post.\n\nFormat:\n{\n  \"linkedin_text\": \"(Write the FULL, complete, high-converting LinkedIn post here with a scroll-stopping hook, body paragraphs, bullet points, CTA, and 3-5 hashtags.)\",\n  \"image_prompt\": \"A crisp, detailed visual prompt describing a modern 3D illustration, sleek tech graphic, glassmorphism, 8k resolution, professional corporate aesthetic.\",\n  \"full_telegram_message\": \"\ud83d\ude80 <b>Successfully Generated & Posted to LinkedIn!</b>\\\\n\\\\n\ud83d\udcd8 <b>LINKEDIN POST (TAP TO COPY):</b>\\\\n<pre><code>(Paste the EXACT full LinkedIn post text here)</code></pre>\\\\n\\\\n\ud83e\uddf5 <b>TWITTER THREAD (TAP EACH TWEET TO COPY):</b>\\\\n\\\\n<b>Tweet 1/3</b>\\\\n<pre><code>(Tweet 1 text)</code></pre>\\\\n\\\\n<b>Tweet 2/3</b>\\\\n<pre><code>(Tweet 2 text)</code></pre>\\\\n\\\\n<b>Tweet 3/3</b>\\\\n<pre><code>(Tweet 3 text)</code></pre>\"\n}`\n      },\n      {\n        \"role\": \"user\",\n        \"content\": \"RAW VOICE TRANSCRIPT / IDEA:\\n\" + ($json.text || $json.message?.text || \"\")\n      }\n    ]\n  }\n}}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "65005205-2bea-4420-be28-bc4a10f82549",
      "name": "Extract Chat Response",
      "type": "n8n-nodes-base.code",
      "position": [
        6928,
        -752
      ],
      "parameters": {
        "jsCode": "let rawContent = $input.first().json.choices[0].message.content;\nrawContent = rawContent.replace(/```json/g, '').replace(/```/g, '').trim();\n\ntry {\n  const parsed = JSON.parse(rawContent);\n  return [{\n    json: {\n      linkedin_text: parsed.linkedin_text,\n      image_prompt: parsed.image_prompt,\n      full_telegram_message: parsed.full_telegram_message\n    }\n  }];\n} catch (e) {\n  return [{\n    json: {\n      linkedin_text: rawContent,\n      image_prompt: \"Modern high-tech abstract professional editorial visual, 8k resolution, sleek design\",\n      full_telegram_message: rawContent\n    }\n  }];\n}"
      },
      "typeVersion": 2
    },
    {
      "id": "227bfb0d-a447-49f2-9b39-3cd162273f5b",
      "name": "Share on LinkedIn",
      "type": "n8n-nodes-base.linkedIn",
      "position": [
        7152,
        -752
      ],
      "parameters": {
        "text": "={{ $json.linkedin_text }}",
        "person": "04b0LCr7rz",
        "additionalFields": {}
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9fa01947-4cd7-4207-92d8-6a8eb326e5cc",
      "name": "If Start Command Received",
      "type": "n8n-nodes-base.if",
      "position": [
        5392,
        -752
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.message.text || '' }}",
              "value2": "/start",
              "operation": "startsWith"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c38caede-0570-4e56-b575-ced8168ccfe2",
      "name": "Deliver Welcome Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5600,
        -976
      ],
      "parameters": {
        "text": "=\ud83d\udc4b **Welcome to your AI Content Assistant!**\n\nI turn your quick voice notes or rough text rants into high-converting posts for **LinkedIn** and **Twitter**.\n\n---\n\n### \ud83d\udca1 How to Use This Bot:\n\n\ud83c\udf99\ufe0f **Option 1: Voice Note**\n\u2022 Press the mic icon and record a 15\u201360 second voice rant sharing a thought, lesson, or opinion.\n\u2022 I'll transcribe it using **Whisper AI** and write your posts automatically.\n\n\ud83d\udcdd **Option 2: Text Message**\n\u2022 Type or paste any raw idea, bullet points, or draft text directly into the chat.\n\n---\n\n### \ud83d\udccb What You Get Back:\n1. \ud83d\udcd8 **A formatted LinkedIn Post** (Auto-published to your feed!).\n2. \ud83e\uddf5 **A Twitter Thread** (each tweet in its own box so you can **tap-to-copy** instantly).\n\nGive it a shot! Send a voice message or type an idea below \ud83d\udc47",
        "chatId": "={{ $json.message.chat.id }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c2f328b3-1939-4c7e-956c-63f38dddb1d6",
      "name": "On Telegram Message",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        5152,
        -752
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "ffb39815-c501-4439-b35e-56c5925602b0",
      "name": "Route by Message Type",
      "type": "n8n-nodes-base.switch",
      "position": [
        5824,
        -752
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "value2": "voice"
            },
            {
              "output": 1,
              "value2": "text"
            }
          ]
        },
        "value1": "={{ $json.message.voice ? 'voice' : 'text' }}",
        "dataType": "string"
      },
      "typeVersion": 1
    },
    {
      "id": "fe48be11-e6d4-4e86-9f8f-325cbe1b5650",
      "name": "Retrieve Voice Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        6048,
        -864
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e049bd4d-86e6-4b50-bbe0-c560600dbbfa",
      "name": "Prepare for Transcription",
      "type": "n8n-nodes-base.code",
      "position": [
        6256,
        -864
      ],
      "parameters": {
        "jsCode": "$input.first().binary.data.fileName = $input.first().binary.data.fileName.replace('.oga', '.ogg');\nreturn $input.first();"
      },
      "typeVersion": 2
    },
    {
      "id": "0cd5918b-0446-4cfa-b815-d6d2b765562a",
      "name": "Send to Voice Transcription API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6480,
        -864
      ],
      "parameters": {
        "url": "https://api.groq.com/openai/v1/audio/transcriptions",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "whisper-large-v3-turbo"
            },
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "groqApi": {
          "name": "<your credential>"
        },
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "9d806e0a-0f7a-4cc2-82ac-3c4a15e3a0f2",
      "name": "Forward Posts to Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        7376,
        -752
      ],
      "parameters": {
        "text": "={{ $node[\"Parse LLM Response2\"].json.full_telegram_message }}",
        "chatId": "={{ $node['Telegram Trigger4'].json.message.chat.id }}",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Share on LinkedIn": {
      "main": [
        [
          {
            "node": "Forward Posts to Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On Telegram Message": {
      "main": [
        [
          {
            "node": "If Start Command Received",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Chat Response": {
      "main": [
        [
          {
            "node": "Share on LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Message Type": {
      "main": [
        [
          {
            "node": "Retrieve Voice Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Post to Chat Completion API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Voice Message": {
      "main": [
        [
          {
            "node": "Prepare for Transcription",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If Start Command Received": {
      "main": [
        [
          {
            "node": "Deliver Welcome Message",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Route by Message Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare for Transcription": {
      "main": [
        [
          {
            "node": "Send to Voice Transcription API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Post to Chat Completion API": {
      "main": [
        [
          {
            "node": "Extract Chat Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send to Voice Transcription API": {
      "main": [
        [
          {
            "node": "Post to Chat Completion API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}