Telegram AI歌词学习bot — 翻译、摘要、词汇

Avanzado

Este es unContent Creation, Multimodal AIflujo de automatización del dominio deautomatización que contiene 30 nodos.Utiliza principalmente nodos como If, Set, Code, OpenAi, Switch. Telegram AI歌词学习bot — 翻译、摘要、词汇

Requisitos previos
  • Clave de API de OpenAI
  • Punto final de HTTP Webhook (n8n generará automáticamente)
  • Bot Token de Telegram
  • Pueden requerirse credenciales de autenticación para la API de destino
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "meta": {
    "instanceId": "48882713bdea5994c47278ba42c20f3f79f92fdccb4bcd0af89b63737b5ab96c"
  },
  "nodes": [
    {
      "id": "347d3502-3620-4b03-bb13-ab2e25fbf020",
      "name": "Nota adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        1360
      ],
      "parameters": {
        "width": 572,
        "height": 375,
        "content": "## Fallback for Unsupported Commands\nWhen the message doesn’t match any **Switch** case, send a friendly default reply:\n- **Expected input:** text starting with `/command`.\n- **Action:** return a message listing valid commands and usage examples.\n- **Why:** avoids silent failures when users send unknown commands (e.g., `/foo`).\n- **Tip:** keep this list in sync with the README.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2865a11c-4eae-4fa6-9e39-94daf3383ff7",
      "name": "Enviar mensaje de error",
      "type": "n8n-nodes-base.telegram",
      "position": [
        512,
        1584
      ],
      "webhookId": "b697b8f4-63c4-4ee9-b6ec-76e76f3110ee",
      "parameters": {
        "text": "=⚠️ Opa\\! Esse comando ainda não é suportado\\.\n\nPara ver a lista completa de comandos disponíveis, digite\\:\n\\/start\n\nOu envie um dos comandos válidos seguidos da URL da letra da música\\.\n\nExemplo\\:\n\\/get\\_lyrics https:\\/\\/www\\.letras\\.mus\\.br\\/lana\\-del\\-rey\\/summertime\\-sadness\\/\n",
        "chatId": "={{ $('Settings').first().json.chat_id }}",
        "additionalFields": {
          "parse_mode": "MarkdownV2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "307ddb89-1fc0-4d2e-be60-23f528187142",
      "name": "Webhook que recebe as mensagens",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2592,
        496
      ],
      "webhookId": "0b53cbd6-3316-4450-ae39-048e7b7d242e",
      "parameters": {
        "path": "lyrics-bot",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
      "name": "Respuesta de texto",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1104,
        464
      ],
      "webhookId": "e7be2f8b-b831-4046-a684-cb87253d6ee5",
      "parameters": {
        "text": "={{ $json.message.content }}",
        "chatId": "={{ $('Settings').first().json.chat_id }}",
        "additionalFields": {
          "parse_mode": "Markdown"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "11c69d81-0095-4ce8-a1d6-4e4b2640f86b",
      "name": "Nota adhesiva 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 731,
        "height": 516,
        "content": "## Download & Cleanup (ETL)\nPipeline to extract and normalize text from a URL:\n1) **Extract_URL (Code):** expects `/command <URL>` and reads `parts[1]`.\n   - **If URL is missing:** route to “Incomplete_Command”.\n2) **Download_URL (HTTP Request):** downloads `{{$json.url}}`.\n   - Suggestions: set `timeout=10000`, follow redirects, set a `User-Agent`.\n3) **CleanUp (Code):** remove `<script>`, `<style>`, comments and tags; normalize whitespace.\n   - **Outputs:** `clean_text`, `preview` (first 300 chars), `length`.\n**Limitations:** JS-heavy pages may yield little text; consider a fallback source.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cec43e23-395e-4207-b65f-7a8432bbeead",
      "name": "Limpieza",
      "type": "n8n-nodes-base.code",
      "position": [
        -544,
        528
      ],
      "parameters": {
        "jsCode": "// HTML bruto da página\nconst html = $input.item.json.data;\n\n// Limpa comentários, scripts e estilos\nlet clean = html\n  .replace(/<!--[\\s\\S]*?-->/g, '')                        // Remove comentários\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, '')             // Remove <script>\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, '')               // Remove <style>\n  .replace(/<\\/?(head|meta|link|iframe|noscript)[^>]*>/gi, '') // Remove head/meta/etc\n  .replace(/<[^>]+>/g, '')                                // Remove todas as tags HTML\n  .replace(/\\s{2,}/g, ' ')                                // Reduz múltiplos espaços\n  .replace(/\\n{2,}/g, '\\n')                               // Reduz múltiplas quebras\n  .trim();\n\n// Opcional: manter quebras de linha coerentes\nclean = clean.replace(/\\r\\n|\\r/g, '\\n');\n\nreturn [\n  {\n    json: {\n      clean_text: clean,\n      preview: clean.slice(0, 300) + '...',\n      length: clean.length\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "969da478-569f-4158-bb7d-3d5d1339d9c2",
      "name": "Descargar_URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -704,
        528
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "067ffcb3-5310-4bfd-8a99-5593cda7792a",
      "name": "Nota adhesiva 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 411,
        "height": 388,
        "content": "## Send to Telegram\n- **chatId:** `{{$('Settings').first().json.chat_id}}`\n- **parse_mode:** standardize to **MarkdownV2** (prevents formatting issues). Always escape: `_ * [ ] ( ) ~ ` > # + - = | { } . !`\n- **Long messages:** Telegram limit is ~4096 chars; split long outputs into chunks.\n- **Errors:** keep messages short, clear; do not expose internal details.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9fd83667-b874-458d-8c20-e74394369f4a",
      "name": "Extraer_URL",
      "type": "n8n-nodes-base.code",
      "position": [
        -1088,
        528
      ],
      "parameters": {
        "jsCode": "const message = $json.body.message.text;\nconst parts = message.split(\" \");\nconst url = parts[1];\n\nreturn [\n  {\n    json: {\n      url: url\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "f5736ecf-b3d1-4634-ade7-c5e3a05e7767",
      "name": "Configuración",
      "type": "n8n-nodes-base.set",
      "position": [
        -1856,
        480
      ],
      "parameters": {
        "values": {
          "number": [
            {
              "name": "model_temperature",
              "value": 0.8
            },
            {
              "name": "token_length",
              "value": "=4096"
            },
            {
              "name": "chat_id",
              "value": "={{ $json.body.message.chat.id }}"
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "45b4bedf-4201-4161-8682-478bdcfbe9e6",
      "name": "Filtro_de_mensajes",
      "type": "n8n-nodes-base.if",
      "position": [
        -2400,
        496
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fb710608-960b-4b73-9f83-b512a85e5c4f",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.body.message.text !== undefined }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "118c5813-5918-4af0-b7e4-44358ca3aa39",
      "name": "Si",
      "type": "n8n-nodes-base.if",
      "position": [
        -1424,
        480
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0cd737c4-e0d4-4e39-b1e7-d0ebf3d616db",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.body.message.text }}",
              "rightValue": "/start"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f81bff82-0402-4ab0-87ac-8c56e4a40e81",
      "name": "Sin operación, no hacer nada",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -2192,
        608
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bc2c18fa-57a9-4135-8674-3b3c96522967",
      "name": "Nota adhesiva 5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -320
      ],
      "parameters": {
        "color": 4,
        "width": 567,
        "height": 1636,
        "content": "## AI Interaction (OpenAI Chat)\nCommands → specific prompts:\n- **/start:** welcome + usage tips.\n- **/get_lyrics:** original lyrics + line-by-line translation.\n- **/interpret_lyrics:** emotional/symbolic reading.\n- **/study_lyrics:** idioms, slang, figures of speech.\n- **/summarize_lyrics:** short summary (≤ 5 sentences).\n- **/vocabulary_lyrics:** key vocabulary with meanings.\n- **/lyrics_poetic_analysis:** poetic/literary devices.\n**Config:** uses `Settings.model_temperature` and `Settings.token_length`.  \n**Formatting:** always return Telegram-safe Markdown; avoid overly wide tables.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "33460650-dbf0-481f-ae75-a25759c6319a",
      "name": "/start",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        32
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=Este é o primeiro contato do usuário `{{ $json.body.message.from.first_name }}`.  Gere uma mensagem de boas-vindas amigável e curta, no idioma `{{ $json.body.message.from.language_code }}`, explicando que este é o *Lyrics Assistant Bot*, com foco em análise de letras de músicas.  Inclua a mensagem abaixo no mesmo idioma, formatada em **Markdown V2** para renderizar corretamente no Telegram:  👋 Olá\\\\! {{ $json.body.message.from.first_name }} Seja bem\\-vindo ao *Lyrics Assistant Bot* 🎶  Com este bot você pode **analisar letras de músicas** de forma completa, seja para entender melhor a mensagem, estudar um idioma ou apenas se emocionar com as palavras\\\\.    *️⃣ *Como usar*:  Basta enviar um dos comandos abaixo seguido da **URL da letra da música** \\(em qualquer idioma\\)\\:  *Exemplo:*   \\- \\`\\/get_lyrics https:\\/\\/www\\.letras\\.mus\\.br\\/lana\\-del\\-rey\\/summertime\\-sadness\\/\\`   \\- \\`\\/interpret_lyrics https:\\/\\/genius\\.com\\/Eminem\\-lose\\-yourself\\-lyrics\\`  🧠 *Comandos disponíveis*: \\- \\`\\/start\\`: Exibe a Saudação e orientações de uso com exemplos de comandos. \\- \\`\\/get_lyrics\\`: Retorna a letra completa da música com tradução em PT-BR, se estiver em outro idioma.   \\- \\`\\/interpret_lyrics\\`: Fornece uma interpretação emocional e simbólica da música.   \\- \\`\\/study_lyrics\\`: Retorna um estudo linguístico com gírias, expressões idiomáticas e figuras de linguagem.   \\- \\`\\/summarize_lyrics\\`: Gera um resumo curto da letra da música. \\- \\`\\/vocabulary_lyrics\\`: Lista palavras difíceis ou relevantes com explicações simples.  \\- \\`\\/lyrics_poetic_analysis\\`: Analisa os recursos poéticos e literários da letra, como rimas, metáforas e aliterações.   🎧 Use músicas para aprender, sentir e crescer\\\\\\!"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "19eb1700-85d6-426f-9e0c-78ef3d5febe1",
      "name": "/get_lyrics",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        208
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=> Você é um especialista em idiomas e tradução de letras musicais.\n> Sua função é analisar letras de músicas enviadas em qualquer idioma e apresentar o resultado com a seguinte estrutura:\n>\n> * Mantenha a letra da música no idioma original, linha por linha, respeitando a ordem e a formatação originais.\n> * Abaixo de cada linha, adicione a tradução correspondente para o idioma **\\[Português / ou outro idioma-alvo se necessário]**.\n> * Preserve expressões idiomáticas e figuras de linguagem sempre que possível, oferecendo uma tradução que mantenha o sentido e o tom original.\n> * **Não modifique** o conteúdo original, apenas traduza de forma contextualizada e fiel.\n>\n> Exemplo de formatação esperada:\n>\n> ```\n> Original line 1  \n> Tradução linha 1\n>\n> Original line 2  \n> Tradução linha 2\n> ```\n\n{{ $json.clean_text }}"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "078d4df3-ec9a-498a-94ab-8c920f0e8c12",
      "name": "/interpret_lyrics",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        384
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=Você é um especialista em análise literária, semiótica e interpretação de letras de músicas. Receberá abaixo a letra completa de uma música (pode estar em qualquer idioma). Sua tarefa é:\n\n1. Apresentar uma **interpretação emocional e simbólica** da música, explicando:\n   - Quais sentimentos ela transmite?\n   - Qual a possível **mensagem central** da letra?\n   - Existe uma **história implícita** sendo contada?\n   - Quais eventos, metáforas ou símbolos são importantes para a interpretação?\n\n2. Caso a letra esteja em outro idioma, **considere a tradução para PT-BR** ao interpretar.\n\n3. Mantenha um tom **profundo, reflexivo e acessível**, como um crítico musical que conversa com o público geral.\n\n### Letra da música:\n{{ $json.clean_text }}\n"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "a1316152-7eb7-49dc-b07f-d1b8ecfdc79f",
      "name": "/study_lyrics",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        560
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=Você é um especialista em linguística aplicada ao ensino de idiomas e análise de letras de músicas. Receberá abaixo a letra de uma música (em qualquer idioma). Sua tarefa é ajudar um estudante de idiomas a aprender com essa música, explicando os elementos linguísticos relevantes.\n\n1. **Identifique e explique gírias, expressões idiomáticas e figuras de linguagem** encontradas na letra. Para cada item, forneça:\n   - A **frase original**\n   - Uma **tradução literal** (se aplicável)\n   - Uma **explicação do significado** ou uso cultural\n\n2. Destaque **expressões úteis para estudantes de idioma**, mesmo que não sejam gírias.\n\n3. Caso a letra esteja em outro idioma, forneça os exemplos com tradução para **PT-BR** e mantenha a explicação nesse idioma.\n\n4. Organize a resposta em tópicos numerados ou uma tabela, para facilitar a leitura e o estudo.\n\n### Letra da música:\n{{ $json.clean_text }}\n"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "75a78819-a978-4159-b3a3-ab305a7d3ac3",
      "name": "/summarize_lyrics",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        752
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=Você é um especialista em análise musical e linguagem. Receberá a letra completa de uma música e deve produzir um **resumo conciso**, destacando a ideia central e os principais temas abordados.\n\n1. Resuma o **conteúdo da letra** de forma clara, objetiva e com no máximo **5 frases curtas**.\n2. Evite repetir a letra; use **suas próprias palavras** para transmitir a mensagem.\n3. Se a música contar uma história, indique os **principais eventos ou sentimentos envolvidos**.\n4. Caso a letra esteja em outro idioma, considere a tradução para PT-BR ao elaborar o resumo.\n\n### Letra da música:\n{{ $json.clean_text }}\n"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "087d78ae-7a87-4c56-99cd-60f11ba52513",
      "name": "Interruptor",
      "type": "n8n-nodes-base.switch",
      "position": [
        -144,
        448
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c303e78e-8d8e-4fbb-8827-f5601fb17876",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Settings').first().json.body.message.text }}",
                    "rightValue": "/get_lyrics"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6a1368ea-dbe4-4dc5-9457-e39e0ebb9325",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Settings').first().json.body.message.text }}",
                    "rightValue": "/interpret_lyrics"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6d4b8947-4396-487a-8f57-8eb0c94d085e",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Settings').first().json.body.message.text }}",
                    "rightValue": "/study_lyrics"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "58ca41e8-9a90-4229-84f0-257bc24afcee",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Settings').first().json.body.message.text }}",
                    "rightValue": "/summarize_lyrics"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "99d7d69f-0506-4acf-8480-4fc9f5f2ff65",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Settings').first().json.body.message.text }}",
                    "rightValue": "/vocabulary_lyrics"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cedca88b-7397-400f-a316-b173003f1fa0",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    },
                    "leftValue": "={{ $('Settings').first().json.body.message.text }}",
                    "rightValue": "/lyrics_poetic_analysis"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        },
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "a421483e-55f9-4000-8b1f-1cf2772c61d1",
      "name": "/vocabulary_lyrics",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        944
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=Você é um especialista em ensino de idiomas e aquisição de vocabulário por meio de músicas. Receberá a letra completa de uma música (em qualquer idioma). Seu objetivo é ajudar um estudante brasileiro a aprender **novas palavras e expressões** com base nessa letra.\n\n1. Identifique e selecione de **5 a 15 palavras ou expressões relevantes**, com base nos seguintes critérios:\n   - Vocabulário de uso comum, mas **útil para estudantes**\n   - Palavras **desafiadoras** ou com **múltiplos significados**\n   - Expressões idiomáticas ou **verbos frasais** (se aplicável)\n\n2. Para cada item, forneça:\n   - A **palavra ou expressão original**\n   - A **tradução para o português (PT-BR)**\n   - Uma **definição clara e breve**\n   - (Opcional) Um **exemplo de uso simples**\n\n3. Caso a música esteja em inglês (ou outro idioma), escreva as definições e exemplos em **português**.\n\n4. Organize a resposta em formato de lista ou tabela, adequada para revisão e estudo.\n\n### Letra da música:\n{{ $json.clean_text }}\n"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "d1c4c7d3-b352-4881-98cd-6ff509fb473e",
      "name": "/lyrics_poetic_analysis",
      "type": "n8n-nodes-base.openAi",
      "position": [
        512,
        1152
      ],
      "parameters": {
        "prompt": {
          "messages": [
            {
              "content": "=Você é um especialista em literatura, poesia e análise estilística de textos. Receberá a letra completa de uma música e deverá identificar os **recursos poéticos e literários** utilizados pelo(a) compositor(a).\n\n1. Analise a letra destacando:\n   - **Metáforas** e comparações\n   - **Rimas** (se presentes)\n   - **Aliterações**, **assonâncias** ou repetições sonoras\n   - **Paralelismos**, **anáforas**, **hipérboles**, **personificações** ou outras figuras de linguagem\n   - Uso de **ritmo**, **estrutura poética** ou repetições que contribuam para a estética do texto\n\n2. Para cada recurso encontrado, forneça:\n   - O **verso ou trecho** onde aparece\n   - O **nome do recurso** identificado\n   - Uma **breve explicação** do efeito literário ou simbólico causado\n\n3. Se a letra estiver em outro idioma, use a **tradução em PT-BR como base para análise** e mantenha a explicação em português.\n\n4. Apresente a análise de forma organizada e compreensível mesmo para quem não é especialista, com tom educativo.\n\n### Letra da música:\n{{ $json.clean_text }}\n"
            }
          ]
        },
        "options": {
          "maxTokens": "={{ $('Settings').first().json.token_length }}",
          "temperature": "={{ $('Settings').first().json.model_temperature }}"
        },
        "resource": "chat",
        "requestOptions": {}
      },
      "typeVersion": 1
    },
    {
      "id": "049d20b1-1a84-4879-be79-ae0350061bbb",
      "name": "Si1",
      "type": "n8n-nodes-base.if",
      "position": [
        -896,
        528
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "0cd737c4-e0d4-4e39-b1e7-d0ebf3d616db",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.url }}",
              "rightValue": "/start"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "489c9b4c-97e9-40c1-b56f-792c8eafb2ff",
      "name": "Nota adhesiva 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1136,
        784
      ],
      "parameters": {
        "width": 736,
        "height": 311,
        "content": "## Error — Incomplete/Invalid Command\nTriggers when input is not `/command <URL>`:\n- **Validations:** presence of `message.text`, supported command, and `URL`.\n- **Response:** show correct usage with a concrete example for each command.\n- **Goal:** educate without blocking; reduce user rework.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d244263a-91d9-42a6-a5a7-bce0fea89b76",
      "name": "Comando_incompleto",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -704,
        944
      ],
      "webhookId": "b697b8f4-63c4-4ee9-b6ec-76e76f3110ee",
      "parameters": {
        "text": "=⚠️ O comando está incompleto ou incorreto\\.\n\nVerifique se você escreveu o comando corretamente e incluiu a URL da letra da música\\.\n\nExemplo de uso correto:  \n\\/get\\_lyrics https:\\/\\/www\\.letras\\.mus\\.br\\/lana\\-del\\-rey\\/summertime\\-sadness\\/\n\nSe tiver dúvidas, digite:  \n\\/start  \npara ver todos os comandos disponíveis e como usá\\-los\\.",
        "chatId": "={{ $('Settings').first().json.chat_id }}",
        "additionalFields": {
          "parse_mode": "MarkdownV2"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "11a61da7-7fb6-4684-81e0-6ccb0286069b",
      "name": "Nota adhesiva 7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3600,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 848,
        "height": 2816,
        "content": "## What this template does\nThis workflow turns a Telegram bot into a **lyrics analysis assistant**.  \nSend a command plus a **song lyrics URL**, and the bot will **download, clean, and analyze the text**, then reply on Telegram with one of the following:\n- Full lyrics with **line-by-line translation**\n- **Emotional/symbolic interpretation**\n- **Idioms/slang & figures of speech** for study\n- **Concise summary** (≤ 5 short sentences)\n- **Vocabulary list** with meanings\n- **Poetic/literary devices** (rhyme, metaphor, alliteration, etc.)\n\n## Scope & limitations\nThis flow targets **private chats and groups**. It is **not intended for channels**, because Telegram channel updates have a different JSON structure than what this workflow handles.\n\n## Apps & nodes used\nTelegram • Webhook • HTTP Request • Code • Set • Switch/IF • OpenAI • Sticky Note\n\n## Prerequisites\n- A Telegram bot token from **@BotFather**\n- An **OpenAI** API key configured as an n8n Credential  \n> No API keys are hardcoded in nodes. All secrets are stored in **Credentials**.\n\n## How it works\n1. **Telegram → Webhook** receives the message.\n2. **Routing (Switch/IF)** checks which command was sent.\n3. **URL Extract + Download (HTTP Request)** fetches the page containing the lyrics.\n4. **Cleanup (Code)** removes HTML, scripts, and styles, and normalizes whitespace.\n5. **OpenAI** formats the output according to the chosen command and returns text.\n6. **Telegram** sends the final answer back to the user.\n7. **Error handling** sends a friendly message for unsupported or incomplete commands.\n\n## Supported commands\n`/start` – Welcome + usage tips  \n`/get_lyrics <URL>` – Original lyrics + line-by-line translation  \n`/interpret_lyrics <URL>` – Emotional & symbolic interpretation  \n`/study_lyrics <URL>` – Idioms, slang, figures of speech  \n`/summarize_lyrics <URL>` – Short summary (≤ 5 sentences)  \n`/vocabulary_lyrics <URL>` – Key vocabulary with meanings  \n`/lyrics_poetic_analysis <URL>` – Literary/poetic devices\n\n## Setup\n1) Create **Telegram API** credentials in n8n and paste your BotFather token.  \n2) Create **OpenAI** credentials and paste your API key.  \n3) Publish the webhook and copy its URL:  \n   - Test: `https://[YOUR_DOMAIN]/webhook-test/[YOUR_PATH]`  \n   - Prod: `https://[YOUR_DOMAIN]/webhook/[YOUR_PATH]`  \n4) In Telegram, send a message to your bot to confirm it responds.  \n5) Test each command with a public lyrics URL.\n\n## Telegram webhook configuration\nSet your webhook to the **n8n Webhook URL** (test or prod). You can do this with a simple GET:\n```\n[https://api.telegram.org/bot](https://api.telegram.org/bot)\\<YOUR\\_BOT\\_TOKEN>/setWebhook?url=https\\://\\[YOUR\\_DOMAIN]/webhook/\\[YOUR\\_PATH]\n````\n\nOr POST with JSON (useful to restrict update types):\n```bash\ncurl -X POST https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"url\": \"https://[YOUR_DOMAIN]/webhook/[YOUR_PATH]\",\n    \"allowed_updates\": [\"message\"]\n  }'\n```\n\n## Allowed update types\n\nIf you don’t set `allowed_updates`, Telegram sends **all** update kinds. Common options:\n* `message` — Regular user messages\n* `edited_message` — Edited messages\n* `channel_post` — Posts in channels\n* `edited_channel_post` — Edited channel posts\n* `callback_query` — Inline button clicks\n* `inline_query` — Inline mode queries\n* `poll` — Poll updates\n* `chat_member` — Member status changes\n\n## Check, disable, and test updates\n\n* **Check current webhook:**\n```\nhttps://api.telegram.org/bot<YOUR_BOT_TOKEN>/getWebhookInfo\n```\n* **Disable webhook (e.g., to use polling):**\n```\nhttps://api.telegram.org/bot<YOUR_BOT_TOKEN>/deleteWebhook\n```\n* **Polling test (works only if webhook is disabled):**\n```\nhttps://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates\n```\n\n## Troubleshooting\n\n* **No reply?** Ensure the webhook is reachable from the internet and the Telegram token is valid.\n* **Empty output?** Verify that the URL actually contains lyrics text (some sites render behind JS).\n* **Bad formatting on Telegram?** Ensure `parse_mode` (Markdown/MarkdownV2) matches your message and escape special characters for MarkdownV2.\n\n## Privacy & Security\n\n* The workflow **does not store** user messages by default.\n* Secrets are kept in **Credentials**, not in nodes or environment variables in plain text.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cf33261a-b9dd-41ed-8ac9-94fc31eb3379",
      "name": "Nota adhesiva 6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1568,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 512,
        "content": "## Routing (If)\n- **If:** detects `/start` and sends the welcome message.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cb3f71b1-93b3-49ec-a761-bb3b065657fb",
      "name": "Nota adhesiva 9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 496,
        "height": 512,
        "content": "## Routing (Switch)\n- **Switch (startsWith):** `/get_lyrics`, `/interpret_lyrics`, `/study_lyrics`, `/summarize_lyrics`, `/vocabulary_lyrics`, `/lyrics_poetic_analysis`.\n- **Fallback:** Switch “else” → unsupported-command reply.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0a32c476-7084-474f-9e07-d7b5f13c0e0f",
      "name": "Nota adhesiva 10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 400,
        "height": 512,
        "content": "## Settings & Credentials\n- **model_temperature:** 0.8 (creativity control)\n- **token_length:** 4096 (practical upper bound to avoid truncation)\n- **chat_id:** `{{$json.body.message.chat.id}}` (derived from Webhook)\n- **Security:** Telegram/OpenAI tokens live in **Credentials** (never hardcoded in nodes)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9ddf823e-5ba0-490e-a1b7-6142abfa5091",
      "name": "Nota adhesiva 11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2672,
        240
      ],
      "parameters": {
        "color": 4,
        "width": 640,
        "height": 512,
        "content": "## Trigger & Intake (Webhook + Telegram)\n- **Webhook:** `POST /webhook/MusicAiBot`\n- **Text source:** `$json.body.message.text`\n- **Chat origin:** `chat_id ← $json.body.message.chat.id` (stored in **Settings**)\n- **Initial flow:** Webhook → Message_Filter (ensures `text`) → If(/start) → Switch(other commands)\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "118c5813-5918-4af0-b7e4-44358ca3aa39": {
      "main": [
        [
          {
            "node": "33460650-dbf0-481f-ae75-a25759c6319a",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "9fd83667-b874-458d-8c20-e74394369f4a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "049d20b1-1a84-4879-be79-ae0350061bbb": {
      "main": [
        [
          {
            "node": "969da478-569f-4158-bb7d-3d5d1339d9c2",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d244263a-91d9-42a6-a5a7-bce0fea89b76",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "33460650-dbf0-481f-ae75-a25759c6319a": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "087d78ae-7a87-4c56-99cd-60f11ba52513": {
      "main": [
        [
          {
            "node": "19eb1700-85d6-426f-9e0c-78ef3d5febe1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "078d4df3-ec9a-498a-94ab-8c920f0e8c12",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a1316152-7eb7-49dc-b07f-d1b8ecfdc79f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "75a78819-a978-4159-b3a3-ab305a7d3ac3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "a421483e-55f9-4000-8b1f-1cf2772c61d1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "d1c4c7d3-b352-4881-98cd-6ff509fb473e",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "2865a11c-4eae-4fa6-9e39-94daf3383ff7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cec43e23-395e-4207-b65f-7a8432bbeead": {
      "main": [
        [
          {
            "node": "087d78ae-7a87-4c56-99cd-60f11ba52513",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f5736ecf-b3d1-4634-ade7-c5e3a05e7767": {
      "main": [
        [
          {
            "node": "118c5813-5918-4af0-b7e4-44358ca3aa39",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "19eb1700-85d6-426f-9e0c-78ef3d5febe1": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9fd83667-b874-458d-8c20-e74394369f4a": {
      "main": [
        [
          {
            "node": "049d20b1-1a84-4879-be79-ae0350061bbb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "969da478-569f-4158-bb7d-3d5d1339d9c2": {
      "main": [
        [
          {
            "node": "cec43e23-395e-4207-b65f-7a8432bbeead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a1316152-7eb7-49dc-b07f-d1b8ecfdc79f": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "45b4bedf-4201-4161-8682-478bdcfbe9e6": {
      "main": [
        [
          {
            "node": "f5736ecf-b3d1-4634-ade7-c5e3a05e7767",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "f81bff82-0402-4ab0-87ac-8c56e4a40e81",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "078d4df3-ec9a-498a-94ab-8c920f0e8c12": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "75a78819-a978-4159-b3a3-ab305a7d3ac3": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a421483e-55f9-4000-8b1f-1cf2772c61d1": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d1c4c7d3-b352-4881-98cd-6ff509fb473e": {
      "main": [
        [
          {
            "node": "bba60d2f-2f57-4379-8d3f-c62f32a00df0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "307ddb89-1fc0-4d2e-be60-23f528187142": {
      "main": [
        [
          {
            "node": "45b4bedf-4201-4161-8682-478bdcfbe9e6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Avanzado - Creación de contenido, IA Multimodal

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Avanzado
Número de nodos30
Categoría2
Tipos de nodos10
Descripción de la dificultad

Adecuado para usuarios avanzados, flujos de trabajo complejos con 16+ nodos

Autor
Raphael De Carvalho Florencio

Raphael De Carvalho Florencio

@followdrabbit

Senior Information Security Architect transitioning into AI/RPA and productized workflows. I love to innovate and test ideas—prototyping with n8n, lovable, ChatGPT, and CrewAI to turn repetitive tasks into reusable, documented templates.

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34