{
  "id": "0tvv4VH9NhxXWpTz",
  "name": "Voice Messages to Text",
  "tags": [],
  "nodes": [
    {
      "id": "8693d0ac-e9bd-4e1b-993f-b154e4762c3b",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -352,
        48
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "df9e5591-5cd4-472b-9b1f-ad57415466db",
      "name": "Check if message is voice",
      "type": "n8n-nodes-base.if",
      "position": [
        -192,
        48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "aa586ff8-3081-40a2-acf2-223e4518ffbe",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.message.audio }}",
              "rightValue": "audio"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "09347777-db4a-45cc-af4d-01d90a75e412",
      "name": "Transcribe message",
      "type": "n8n-nodes-smallestai.smallestai",
      "position": [
        288,
        32
      ],
      "parameters": {
        "resource": "stt",
        "additionalOptions": {}
      },
      "credentials": {},
      "typeVersion": 1
    },
    {
      "id": "b919bccb-4c68-4d5b-ab59-b7afb1d216f8",
      "name": "Get audio message file",
      "type": "n8n-nodes-base.telegram",
      "position": [
        80,
        32
      ],
      "parameters": {
        "fileId": "={{ $json.message.audio.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "1ce73659-d7da-4cc8-b9a9-998df09b676d",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        512,
        32
      ],
      "parameters": {
        "text": "=Transcription: {{ $json.transcription ?? '' }}\nChat id: {{ $('Telegram Trigger').item.json.message.chat.id }}",
        "options": {
          "systemMessage": "You are a helpful assistant processing a user's voice memo. Your job is to analyze the provided Transcription, generate a helpful response, and send it to the user by calling the \"reply\" tool.\n\nWhen you call the tool, you must pass the exact Chat ID provided, and you MUST format the \"Text\" argument exactly like this:\n\nWhat user is saying: [Insert the exact transcription text here]\n\nWhat you can reply (a suggestion): [Insert your concise and clear reply suggestion answering their request here]"
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "9638bf7e-14f0-4ff1-9a7a-5da01471a3d9",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        512,
        224
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "be4112fe-4846-41b9-9039-17e0e22fc2ae",
      "name": "reply",
      "type": "n8n-nodes-base.telegramTool",
      "position": [
        736,
        208
      ],
      "parameters": {
        "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Text', ``, 'string') }}",
        "chatId": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Chat_ID', ``, 'string') }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0b924c98-2680-4ad2-a194-44cf5fc6c7d4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 400,
        "height": 320,
        "content": "## 2. Download & Transcribe"
      },
      "typeVersion": 1
    },
    {
      "id": "52057ab9-bc56-4e1b-bcdc-5ad7efc6cdce",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "## 1. Capture & Filter Inbound Audio\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fbfdb89c-24ca-4cd9-820e-3dc1ab0fe338",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        -176
      ],
      "parameters": {
        "width": 464,
        "height": 592,
        "content": "## AI-Powered Telegram Voice Message Assistant\n\n### How it works\nThis workflow turns Telegram into an intelligent voice memo companion. When an inbound message hits the Telegram bot trigger, it validates if the payload contains an audio object. It then fetches the binary audio file from Telegram's servers and routes it directly to Smallest.ai for accurate speech-to-text processing. The resulting text is fed to a LangChain AI Agent running Google Gemini, which reads the transcription, drafts a clever reply suggestions layout, and automatically pings the user back using a native Telegram conversational tool.\n\n### Setup steps\n* Add your **Telegram Bot API Token** inside the Trigger, Audio Downloader, and Reply Tool nodes.\n* Connect your **Smallest.ai** API key credentials to the transcription node.\n* Link your **Google Gemini** API key account to fuel the underlying LangChain Chat Model.\n\n### Customization\nYou can completely rewrite the target system prompt parameters inside the **AI Agent** node if you want the bot to perform alternate tasks with your voice memos\u2014such as acting as a language translator, sorting actionable items into a task list, or saving formatting summaries out to an external notes database."
      },
      "typeVersion": 1
    },
    {
      "id": "3d2c91eb-d02b-432a-a649-67cc5df501a4",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        448,
        -64
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 448,
        "content": "## 3. Intelligent Response Loop"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "825a4607-8f60-4b4d-9839-6840cb07f3d4",
  "nodeGroups": [],
  "connections": {
    "reply": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check if message is voice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transcribe message": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get audio message file": {
      "main": [
        [
          {
            "node": "Transcribe message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check if message is voice": {
      "main": [
        [
          {
            "node": "Get audio message file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}