{
"id": "HJwTWtzlhK8Q5SOv",
"meta": {
"instanceId": "fb924c73af8f703905bc09c9ee8076f48c17b596ed05b18c0ff86915ef8a7c4a",
"templateCredsSetupCompleted": true
},
"name": "Telegram AI multi-format chatbot",
"tags": [],
"nodes": [
{
"id": "65196267-0d57-4af4-9081-962701478146",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
660,
640
],
"parameters": {
"model": "gpt-4o",
"options": {
"temperature": 0.7,
"frequencyPenalty": 0.2
}
},
"credentials": {
"openAiApi": {
"id": "rveqdSfp7pCRON1T",
"name": "Ted's Tech Talks OpenAi"
}
},
"typeVersion": 1
},
{
"id": "fc446ef0-2f15-42e7-a993-7960d76d8876",
"name": "Window Buffer Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
800,
640
],
"parameters": {
"sessionKey": "=chat_with_{{ $('Listen for incoming events').first().json.message.chat.id }}",
"contextWindowLength": 10
},
"typeVersion": 1
},
{
"id": "51c3cddd-fc21-4fff-b615-ea7080c47947",
"name": "Correct errors",
"type": "n8n-nodes-base.telegram",
"position": [
1220,
580
],
"parameters": {
"text": "={{ $('AI Agent').item.json.output.replace(/&/g, \"&\").replace(/>/g, \">\").replace(/bold, bold\nitalic, italic\nunderline, underline\nstrikethrough, strikethrough, strikethrough\nspoiler, italic bold strikethrough italic bold strikethrough spoiler underline italic bold bold\ninline URL\ninline fixed-width code
\n
pre-formatted fixed-width code block\n2. Any code that you send should be wrapped in these tags:
pre-formatted fixed-width code block written in the Python programming language
\nOther programming languages are supported as well.\n3. All <, > and & symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (< with <, > with > and & with &)\n4. If the user sends you a message starting with / sign, it means this is a Telegram bot command. For example, all users send /start command as their first message. Try to figure out what these commands mean and reply accodringly\n"
}
},
"typeVersion": 1.1
},
{
"id": "2c56536d-1a86-4a49-b495-3e877adb308a",
"name": "Determine content type",
"type": "n8n-nodes-base.switch",
"position": [
-180,
480
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.message.text }}",
"rightValue": "/"
}
]
},
"renameOutput": true
},
{
"outputKey": "Voice",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "dd41bbf0-bee0-450b-9160-b769821a4abc",
"operator": {
"type": "object",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice}}",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {
"fallbackOutput": "extra"
}
},
"typeVersion": 3.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "15ae799b-6868-4519-b579-3f202e4de5b2",
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Send final reply",
"type": "main",
"index": 0
}
]
]
},
"Send final reply": {
"main": [
[],
[
{
"node": "Correct errors",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Download voice file": {
"main": [
[
{
"node": "Convert audio to text",
"type": "main",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Convert audio to text": {
"main": [
[
{
"node": "Combine content and set properties",
"type": "main",
"index": 0
}
]
]
},
"Determine content type": {
"main": [
[
{
"node": "Combine content and set properties",
"type": "main",
"index": 0
}
],
[
{
"node": "Download voice file",
"type": "main",
"index": 0
}
],
[
{
"node": "Send error message",
"type": "main",
"index": 0
}
]
]
},
"Listen for incoming events": {
"main": [
[
{
"node": "Determine content type",
"type": "main",
"index": 0
},
{
"node": "Send Typing action",
"type": "main",
"index": 0
}
]
]
},
"Combine content and set properties": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
}
}
}