{
  "id": "UMVskHQcryGFC3sW",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Voice agent for the notion tasks through the telegram",
  "tags": [
    {
      "id": "JUK6Xu1Fz0PWwGzI",
      "name": "active",
      "createdAt": "2025-10-04T12:29:09.131Z",
      "updatedAt": "2025-10-04T12:29:09.131Z"
    }
  ],
  "nodes": [
    {
      "id": "34b3273c-721e-488b-9bce-14ee704185ab",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -64,
        128
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.5-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e7d20742-834e-496f-9dda-9789035e7355",
      "name": "Approval Check (If Approved?)",
      "type": "n8n-nodes-base.if",
      "position": [
        1232,
        -48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9d302e0c-44e2-4b9e-a3ed-8d21e67945ed",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "e8a10ffe-b0ca-4fac-b995-b81675799620",
      "name": "Telegram: Receive Message",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -1472,
        -32
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a396c59a-f7b1-43aa-a8d8-572761967c2a",
      "name": "Switch: Text or Voice",
      "type": "n8n-nodes-base.switch",
      "position": [
        -1168,
        -32
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3fb72ce4-35b2-4997-a369-6a7fd723b36c",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "voice",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "667e13a9-4518-4abb-983d-3b6171f35e4f",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "=",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.3
    },
    {
      "id": "a2dde0cd-d68b-4545-820d-6d2c410ebd40",
      "name": "Set: Prepare Text",
      "type": "n8n-nodes-base.set",
      "position": [
        -608,
        -176
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "db72eea6-0517-4e77-a8db-dfe433d65fc8",
              "name": "text",
              "type": "string",
              "value": "={{ $json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "17e32a68-39e4-406a-8a98-0e57d8a06ca4",
      "name": "Telegram: Download Voice File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -832,
        224
      ],
      "parameters": {
        "fileId": "={{ $json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "7225d6e4-e632-4957-96b3-17ee4a7008c3",
      "name": "Gemini: Transcribe Voice",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -576,
        224
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-flash",
          "cachedResultName": "models/gemini-2.5-flash"
        },
        "options": {},
        "resource": "audio",
        "inputType": "binary"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "54ee3516-9e72-4b28-9cbe-e82b0c37547a",
      "name": "Set: Put Transcript into Text",
      "type": "n8n-nodes-base.set",
      "position": [
        -336,
        224
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "db72eea6-0517-4e77-a8db-dfe433d65fc8",
              "name": "text",
              "type": "string",
              "value": "={{ $json.content.parts[0].text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "bf58028e-5018-4105-86c9-5d7495fd22b4",
      "name": "AI Extractor: TaskName & TaskDue",
      "type": "@n8n/n8n-nodes-langchain.informationExtractor",
      "position": [
        -64,
        -32
      ],
      "parameters": {
        "text": "={{ $json.text }}",
        "options": {},
        "attributes": {
          "attributes": [
            {
              "name": "TaskName",
              "description": "The title of the task. Only return a value if it clearly exists; otherwise, leave empty."
            },
            {
              "name": "TaskDue",
              "type": "date",
              "description": "The due date of the task. Only return a value if clearly present; otherwise, leave empty."
            }
          ]
        }
      },
      "notesInFlow": false,
      "typeVersion": 1.2
    },
    {
      "id": "95ed4be7-aa98-4f72-bd87-dd96ed105f2e",
      "name": "If: Extraction Valid?",
      "type": "n8n-nodes-base.if",
      "position": [
        416,
        -32
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "54e99978-984e-479b-a8cd-678ac9dee81f",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.TaskName }}",
              "rightValue": ""
            },
            {
              "id": "f50a2ef0-990d-4740-a0eb-3c2452f8e0d5",
              "operator": {
                "type": "dateTime",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $json.output.TaskDue }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1e2f1750-1704-42fe-82c6-7c25a47dd39a",
      "name": "Telegram: Ask Approve / Decline",
      "type": "n8n-nodes-base.telegram",
      "position": [
        832,
        -48
      ],
      "parameters": {
        "chatId": "={{ $('Telegram: Receive Message').item.json.message.chat.id }}",
        "message": "=Task Name: {{ $json.output.TaskName }}\nDue Date: {{ new Date($json.output.TaskDue).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) }}",
        "options": {
          "appendAttribution": false
        },
        "operation": "sendAndWait",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "approveLabel": "Approve",
            "disapproveLabel": "Decline"
          }
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "fe396f08-c258-462d-bf61-1f50c3922510",
      "name": "Notion: Create Task Page",
      "type": "n8n-nodes-base.notion",
      "position": [
        1616,
        -64
      ],
      "parameters": {
        "title": "={{ $('AI Extractor: TaskName & TaskDue').item.json.output.TaskName }}",
        "options": {},
        "resource": "databasePage",
        "databaseId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_DATABASE_ID_HERE",
          "__regex": "^([0-9a-f]{8}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{4}-?[0-9a-f]{12})"
        },
        "propertiesUi": {
          "propertyValues": [
            {
              "key": "Date|date",
              "date": "={{ $('AI Extractor: TaskName & TaskDue').item.json.output.TaskDue }}",
              "includeTime": false
            }
          ]
        }
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "273da7c6-1dfe-4b70-a9ba-0f66d238d6c6",
      "name": "Telegram: Notify - Task Created",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1824,
        -64
      ],
      "parameters": {
        "text": "=\u2705 Task created in Notion.",
        "chatId": "={{ $('Telegram: Receive Message').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "f8d85ba2-217b-4d76-8954-c539ed472b9a",
      "name": "Telegram: Notify - Task Not Created",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1248,
        208
      ],
      "parameters": {
        "text": "=\u274c Task not created in Notion.",
        "chatId": "={{ $('Telegram: Receive Message').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "5a32830d-f766-45d3-a330-d058d8ff0d2b",
      "name": "Telegram: Notify - Extraction Failed",
      "type": "n8n-nodes-base.telegram",
      "position": [
        416,
        224
      ],
      "parameters": {
        "text": "=Title or due date cannot be extracted. Please try again.",
        "chatId": "={{ $('Telegram: Receive Message').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "772bab86-fb65-490e-a369-0e6c621fb7d0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1536,
        -208
      ],
      "parameters": {
        "color": 5,
        "height": 352,
        "content": "## \ud83d\udcac Telegram: Receive Message  \nTriggers when a new Telegram message arrives either text or voice and sends the data forward for processing."
      },
      "typeVersion": 1
    },
    {
      "id": "515140eb-2d20-44e3-9350-5c8fd044b02f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        -208
      ],
      "parameters": {
        "color": 5,
        "height": 352,
        "content": "## \ud83d\udd00 Switch: Text or Voice  \nChecks if the message is text or voice and routes it to the matching branch."
      },
      "typeVersion": 1
    },
    {
      "id": "1d535e73-7312-4a03-b186-d92642568b3b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -304
      ],
      "parameters": {
        "color": 5,
        "width": 256,
        "height": 288,
        "content": "## \u270f\ufe0f Set: Prepare Text  \nExtracts the text message from Telegram and stores it for later processing."
      },
      "typeVersion": 1
    },
    {
      "id": "89c4d4ca-548c-4708-93f9-dc24cbb5cb5a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        32
      ],
      "parameters": {
        "color": 5,
        "width": 720,
        "height": 368,
        "content": "## \ud83c\udf99\ufe0f Voice Processing Chain  \n1. **Telegram: Download Voice File:** Downloads the user's voice message from Telegram.  \n2. **Gemini: Transcribe Voice:** Sends the downloaded audio to Google Gemini and transcribes it into text.\n3. **Set: Put Transcript into Text:** Stores the transcribed text for further use in the workflow.  \n\n\ud83d\udd04 Together, these nodes convert voice messages into usable text for automation."
      },
      "typeVersion": 1
    },
    {
      "id": "5592afdf-aa6b-4cca-86aa-ad53c15ce6bd",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -288
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 560,
        "content": "## \ud83e\udde0 Task Information Extraction  \n1. **Google Gemini Chat Model** \u2013 Powers the AI extraction with Gemini 2.5 Flash Lite.  \n2. **AI Extractor: TaskName & TaskDue** \u2013 Identifies and extracts the *task title* and *due date* from the provided text.  \n\n\u2705 Converts user text into structured task data for Notion or any task system."
      },
      "typeVersion": 1
    },
    {
      "id": "30861b16-0e27-40a2-9273-cf4ca47de3b4",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -288
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 720,
        "content": "## \u2705 Validate Task Extraction\n1. **If: Extraction Valid?** \u2013 Checks if both `TaskName` and `TaskDue` exist from the AI-extracted output.  \n2. **Telegram: Notify - Extraction Failed** \u2013 Sends a Telegram message to the user if extraction fails: \"Title or due date cannot be extracted. Please try again.\"  \n\n\ud83d\udca1 Ensures only valid tasks proceed and notifies users when extraction is incomplete."
      },
      "typeVersion": 1
    },
    {
      "id": "de731a57-c922-4e9b-bf3a-eb797f71180d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        704,
        -288
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 448,
        "content": "## \ud83d\udce9 Ask for Task Approval\n- **Telegram: Ask Approve / Decline** \u2013 Sends a message with the extracted `TaskName` and `TaskDue` to the user.  \n- Provides **Approve** and **Decline** buttons for double approval.  \n\n\ud83d\udca1 Lets users quickly confirm or reject tasks directly via Telegram."
      },
      "typeVersion": 1
    },
    {
      "id": "b1332d50-95e4-4dc7-9923-078ecd4e7ad2",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1120,
        -208
      ],
      "parameters": {
        "color": 5,
        "width": 352,
        "height": 608,
        "content": "## \u2705 Check Task Approval\n- **Approval Check (If Approved?)** \u2013 Checks if the user approved the task in Telegram.\n- **Telegram: Notify - Task Not Created** \u2013 Notifies the user if the task was declined."
      },
      "typeVersion": 1
    },
    {
      "id": "67ff91ca-9c5f-4cff-a253-cebafa5d0cdf",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1536,
        -208
      ],
      "parameters": {
        "color": 5,
        "width": 496,
        "height": 336,
        "content": "## \ud83d\udcdd Create Task in Notion\n- **Notion: Create Task Page** \u2013 Adds a new page in Notion with the extracted task name and due date.\n- **Telegram: Notify - Task Created** \u2013 Confirms to the user that the task was successfully created."
      },
      "typeVersion": 1
    },
    {
      "id": "b990b59b-76c1-44e8-95e5-a9daf9e08f8e",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2528,
        -608
      ],
      "parameters": {
        "color": 3,
        "width": 896,
        "height": 1312,
        "content": "# Quick Setup Checklist \u2014 Telegram \u2192 Transcribe \u2192 Extract \u2192 Notion\n\n## 1) Telegram (BotFather)\n- Create a bot with **BotFather** \u2192 `/newbot` \u2192 copy the **Bot Token**.\n- Start the bot in your Telegram app (send any message to it).\n- **Get your chat ID**:\n  - Easiest: send a message to the bot, open the **Telegram Trigger** in n8n and check the incoming `chat.id`.\n  - Or use `getUpdates` with your bot token to read the latest `chat.id`.\n- Keep the Bot Token and one example `chat.id` handy for n8n credentials/testing.\n\n## 2) Google Gemini (transcription)\n- Create a Google Cloud project and enable the **GenAI / PaLM (Gemini)** API.\n- Note: use trial credits or free tier for testing if available.\n- In n8n: add Gemini (Google Palm) credentials under **Credentials**.\n\n## 3) Notion (integration + database)\n- Create a Notion integration and copy its **Integration Token**.\n- Create a **Notion database** for tasks with at least:\n  - **Title** \u2014 (Title) \u2014 for the task name\n  - **Date** \u2014 (Date) \u2014 for the due date\n- Share the database with your integration (Share \u2192 invite integration).\n- Copy the **Database ID** from the database URL.\n\n## 4) Map extracted values to Notion (simple instruction \u2014 no code)\n- In the **Notion: Create Task Page** node, map the extractor output using the UI:\n  - **Title** \u2192 map the extracted **TaskName** to the Notion Title.\n  - **Date** \u2192 map the extracted **TaskDue** to the Notion Date property.\n- Use the node's right-side input panel to pick values from `AI Extractor: TaskName & TaskDue`.\n\n## 5) Audio / Transcription notes (Gemini handles transcription)\n- Set **Telegram Get File** node to **Download = true** so the node provides binary.\n- Pass the downloaded binary into the **Gemini: Transcribe Voice** node (inputType = binary).\n- Gemini will transcribe the audio (no external converter required with this setup).\n- If you ever see format issues, confirm the Telegram binary is passed to Gemini (download=true).\n\n## 6) n8n required credentials (add these in n8n)\n- Telegram API (Bot Token)  \n- Google Gemini (Google Palm) API credentials  \n- Notion Integration Token\n\n## 7) Final quick tests\n- **Text test:** send a plain text task to the bot \u2192 extractor \u2192 approval \u2192 create Notion page.\n- **Voice test:** send a voice note \u2192 Gemini transcribes \u2192 extractor \u2192 approval \u2192 create Notion page.\n- If extraction fails, check the **If: Extraction Valid?** node and confirm the Notion mapping.\n\n---\n\n**Done.** Map TaskName \u2192 Title and TaskDue \u2192 Date in the Notion node using the UI (drag/select). If Notion shows the date wrong, tell me and I\u2019ll give a one-line fix."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bc34a6fe-47fe-4146-a529-6b7ad32b9ac2",
  "connections": {
    "Set: Prepare Text": {
      "main": [
        [
          {
            "node": "AI Extractor: TaskName & TaskDue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If: Extraction Valid?": {
      "main": [
        [
          {
            "node": "Telegram: Ask Approve / Decline",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram: Notify - Extraction Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch: Text or Voice": {
      "main": [
        [
          {
            "node": "Set: Prepare Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram: Download Voice File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gemini: Transcribe Voice": {
      "main": [
        [
          {
            "node": "Set: Put Transcript into Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Extractor: TaskName & TaskDue",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Notion: Create Task Page": {
      "main": [
        [
          {
            "node": "Telegram: Notify - Task Created",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram: Receive Message": {
      "main": [
        [
          {
            "node": "Switch: Text or Voice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approval Check (If Approved?)": {
      "main": [
        [
          {
            "node": "Notion: Create Task Page",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Telegram: Notify - Task Not Created",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set: Put Transcript into Text": {
      "main": [
        [
          {
            "node": "AI Extractor: TaskName & TaskDue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram: Download Voice File": {
      "main": [
        [
          {
            "node": "Gemini: Transcribe Voice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram: Ask Approve / Decline": {
      "main": [
        [
          {
            "node": "Approval Check (If Approved?)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extractor: TaskName & TaskDue": {
      "main": [
        [
          {
            "node": "If: Extraction Valid?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}