Telegram AI歌詞学習ボット — 翻訳、要約、語彙

上級

これはContent Creation, Multimodal AI分野の自動化ワークフローで、30個のノードを含みます。主にIf, Set, Code, OpenAi, Switchなどのノードを使用。 Telegram AI歌詞学習ボット — 翻訳、要約、語彙

前提条件
  • OpenAI API Key
  • HTTP Webhookエンドポイント(n8nが自動生成)
  • Telegram Bot Token
  • ターゲットAPIの認証情報が必要な場合あり
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "48882713bdea5994c47278ba42c20f3f79f92fdccb4bcd0af89b63737b5ab96c"
  },
  "nodes": [
    {
      "id": "347d3502-3620-4b03-bb13-ab2e25fbf020",
      "name": "付箋",
      "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": "エラーメッセージ送信",
      "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": "テキスト返信",
      "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": "付箋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": "クリーンアップ",
      "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": "Download_URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -704,
        528
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "067ffcb3-5310-4bfd-8a99-5593cda7792a",
      "name": "付箋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": "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": "設定",
      "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": "メッセージフィルター",
      "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": "条件分岐",
      "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": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        -2192,
        608
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "bc2c18fa-57a9-4135-8674-3b3c96522967",
      "name": "付箋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": "スイッチ",
      "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": "条件分岐1",
      "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": "付箋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": "不完全なコマンド",
      "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": "付箋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": "付箋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": "付箋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": "付箋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": "付箋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
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - コンテンツ作成, マルチモーダルAI

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数30
カテゴリー2
ノードタイプ10
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
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.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34