Telegram フォーマット済みテキスト出力

上級

これはOther, Building Blocks, AI分野の自動化ワークフローで、19個のノードを含みます。主にIf, Code, Limit, Switch, SplitOutなどのノードを使用、AI技術を活用したスマート自動化を実現。 LLM出力を豊富なテキストTelegramメッセージに変換――自動のなメディア処理とスマートチャンキング

前提条件
  • Telegram Bot Token
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "6bKCRgltEQMKck0S",
  "meta": {
    "instanceId": "90ee57f28a1370a05d29c652ea0aff6dc92be284367a87ea83ea3eac2120d7eb"
  },
  "name": "TelegramRichOutput",
  "tags": [],
  "nodes": [
    {
      "id": "a25428d1-d34c-42f4-9a1a-713bef6dc1e9",
      "name": "画像を返信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -480,
        720
      ],
      "webhookId": "bc86ba8e-2a9b-4f48-acdb-0550c95494ef",
      "parameters": {
        "file": "={{ $json.url }}",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chatId }}",
        "operation": "sendPhoto",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "FyjiLVRg007vuCnK",
          "name": "Telegram account (SCP)"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "052643fa-6319-43f3-a052-40ed0e255238",
      "name": "音声を返信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -260,
        720
      ],
      "webhookId": "bc86ba8e-2a9b-4f48-acdb-0550c95494ef",
      "parameters": {
        "file": "={{ $json.url }}",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chatId }}",
        "operation": "sendAudio",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "FyjiLVRg007vuCnK",
          "name": "Telegram account (SCP)"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "73dfb105-5ffe-4f8a-b96e-b0b556d73956",
      "name": "動画を返信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        -60,
        720
      ],
      "webhookId": "bc86ba8e-2a9b-4f48-acdb-0550c95494ef",
      "parameters": {
        "file": "={{ $json.url }}",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chatId }}",
        "operation": "sendVideo",
        "additionalFields": {
          "parse_mode": "HTML"
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "FyjiLVRg007vuCnK",
          "name": "Telegram account (SCP)"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e715f898-1bca-4e4e-a463-f30815664766",
      "name": "テキスト送信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        140,
        220
      ],
      "webhookId": "c5c03eae-b148-4358-8792-d03d55bd0b48",
      "parameters": {
        "text": "={{ $('When Executed by Another Workflow').item.json.output }}",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chatId }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "FyjiLVRg007vuCnK",
          "name": "Telegram account (SCP)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "38f15fa8-f9a2-469b-9f30-fed46296bf1f",
      "name": "テキストが長すぎる場合",
      "type": "n8n-nodes-base.if",
      "position": [
        -140,
        60
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a6365c72-9e4c-4b19-b725-9965fdb81e21",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('When Executed by Another Workflow').item.json.output.length > 1000 }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "286d11cb-f94a-4143-8a27-34b5f4e14192",
      "name": "別ワークフローで実行時",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -960,
        -100
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "chatId",
              "type": "number"
            },
            {
              "name": "output"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "dab1fb0c-970e-43f7-a335-c48639edaabe",
      "name": "リンクをループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -580,
        220
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "a1f73d92-b61e-41fa-a0c7-50e72078e096",
      "name": "リンクがない場合",
      "type": "n8n-nodes-base.if",
      "position": [
        -520,
        -100
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "332d2f85-5f44-4d8b-a5c0-03bda9c3976d",
              "operator": {
                "type": "array",
                "operation": "empty",
                "singleValue": true
              },
              "leftValue": "={{ $json.files }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "bd57fe5e-940b-46f9-a76f-ba4d6bae5c7c",
      "name": "リンクを抽出・分割",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -800,
        220
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "files"
      },
      "typeVersion": 1
    },
    {
      "id": "8e14c1e6-ece0-4310-97c2-829a37074706",
      "name": "長いテキストをチャンク分割",
      "type": "n8n-nodes-base.code",
      "position": [
        140,
        -120
      ],
      "parameters": {
        "jsCode": "const inputText = $('When Executed by Another Workflow').first().json.output || \"\";\nconst lines = inputText.split(\"\\n\");\n\nlet chunks = [];\nlet currentChunk = \"\";\n\nfor (const line of lines) {\n  // Check if adding the line would exceed the 1000 character limit\n  if ((currentChunk + line + \"\\n\").length > 1000) {\n    // Push current chunk if not empty\n    if (currentChunk) chunks.push(currentChunk.trim());\n    // Start new chunk with current line\n    currentChunk = line + \"\\n\";\n  } else {\n    // Add line to current chunk\n    currentChunk += line + \"\\n\";\n  }\n}\n\n// Push the final chunk if there’s remaining content\nif (currentChunk) chunks.push(currentChunk.trim());\n\n// Return each chunk as a separate item\nreturn { output:chunks.map(chunk => ({ chunk } ))};"
      },
      "typeVersion": 2
    },
    {
      "id": "b08e8087-f155-4747-a5d8-8c9bb5511777",
      "name": "チャンクを分割",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        360,
        -120
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "output"
      },
      "typeVersion": 1
    },
    {
      "id": "94b015d0-a1b7-4e13-973a-5a25fe88c209",
      "name": "テキストチャンクをループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        560,
        -120
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "51f2598e-4958-4139-ab00-3836b7a52ed5",
      "name": "テキストチャンク送信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        800,
        -120
      ],
      "webhookId": "c5c03eae-b148-4358-8792-d03d55bd0b48",
      "parameters": {
        "text": "={{ $json.chunk }}",
        "chatId": "={{ $('When Executed by Another Workflow').item.json.chatId }}",
        "additionalFields": {
          "parse_mode": "HTML",
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "FyjiLVRg007vuCnK",
          "name": "Telegram account (SCP)"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d7baaaff-a918-487d-970a-d2ef498504b3",
      "name": "制限",
      "type": "n8n-nodes-base.limit",
      "position": [
        -380,
        220
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "5f724698-027f-4e88-8329-1abd00f8e6c7",
      "name": "リンク抽出",
      "type": "n8n-nodes-base.code",
      "position": [
        -740,
        -100
      ],
      "parameters": {
        "jsCode": "// free-text input\nconst text = $input.first().json.output ?? \"\";\n\n/* media extensions grouped by type */\nconst IMG = ['jpg','jpeg','png','gif','bmp','webp','tif','tiff'];\nconst AUD = ['mp3','wav','m4a','flac','ogg','aac','opus'];\nconst VID = ['mp4','mov','mkv','webm','avi','mpeg','mpg'];\n\n/* one regex that grabs any media URL (no lazy quantifier, so the whole link is kept) */\nconst re = /(https?:\\/\\/[^\\s\"'<>]+\\.(?<ext>[A-Za-z0-9]{2,5}))(?:\\?[^\\s\"'<>]*)?/gi;\n\nconst seen  = new Set();\nconst files = [];\n\nfor (const m of text.matchAll(re)) {\n  const url = m[1];\n  if (seen.has(url)) continue;          // de-dupe\n  seen.add(url);\n\n  const ext = (m.groups.ext || '').toLowerCase();\n\n  let type = 'other';\n  if (IMG.includes(ext))  type = 'image';\n  else if (AUD.includes(ext)) type = 'audio';\n  else if (VID.includes(ext)) type = 'video';\n\n  files.push({ url, type });\n}\n\nreturn [{ json: { files } }];"
      },
      "typeVersion": 2
    },
    {
      "id": "45e41a01-68a2-4b64-8830-e05916170a97",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        420
      ],
      "parameters": {
        "color": 5,
        "width": 660,
        "height": 480,
        "content": "## Send links\nSend links to chat as separate messages \nwith appropriate type (image, audio, video)"
      },
      "typeVersion": 1
    },
    {
      "id": "bbeb6619-4a48-40f5-be75-e99e0c53462e",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        -220
      ],
      "parameters": {
        "color": 6,
        "width": 900,
        "height": 300,
        "content": "## Send a long message\nSeparate long message by chunks and send them one by one"
      },
      "typeVersion": 1
    },
    {
      "id": "4dbf96c8-fb30-4c22-8fc9-c551cb9893c6",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        80,
        120
      ],
      "parameters": {
        "width": 300,
        "height": 260,
        "content": "## Send a short message\nDeliver a short message (default flow)"
      },
      "typeVersion": 1
    },
    {
      "id": "e13e63e9-331e-458b-8933-4ec608eab00a",
      "name": "リンクタイプを確認",
      "type": "n8n-nodes-base.switch",
      "position": [
        -60,
        480
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "10ec4538-b5cc-4562-954a-fc4ada846d78",
                    "operator": {
                      "type": "string",
                      "operation": "endsWith"
                    },
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "image"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "9e0cee56-b281-4d01-9196-eb6495be9641",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "audio"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "video",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "007d1c92-0cd0-4dd6-ab9b-8c869e20797d",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.type }}",
                    "rightValue": "video"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    }
  ],
  "active": false,
  "pinData": {
    "Split Out the Chunks": [
      {
        "json": {
          "chunk": "Here are the image prompts we have so far:\n\n1. A pile of ancient, golden and silver coins scattered on a worn wooden table. The coins have varied designs with ornate patterns and symbols, and reflect light with an unnatural shimmer. A dim light from an overhead lamp highlights their metallic surface against the dark surroundings of what appears to be an old study room with bookshelves in the background.\n\n2. Ancient golden and silver coins suspended in mid-air, forming a slowly rotating spiral pattern about 2 feet above a worn wooden table. Various coins spin on their edges while others twist and turn in different directions. A person's silhouette is visible in the background, approaching cautiously. The room appears colder with a slight blue tint, and tiny ice crystals have formed on the edges of the table near the floating coins."
        }
      },
      {
        "json": {
          "chunk": "3. A researcher with a pained expression, looking pale and disoriented, stands beside a wooden table. Their hand is stretched out toward floating golden and silver coins, which are now partially transparent and fading at the edges. Some coins appear to be dissolving into tiny particles of light. Frost has formed on the researcher's outstretched fingers, and their breath is visible in the now freezing air of the study room.\n\n4. An empty wooden table where the coins once were, with only a few small patches of frost remaining as evidence. The researcher has stepped back, looking exhausted and confused. Their hand that reached for the coins appears slightly translucent, as if it partially disappeared with the coins. Scientific instruments scattered around the table show unusual readings with their displays glitching. The temperature in the room is returning to normal, shown by the frost slowly melting and the researcher's breath no longer visible."
        }
      },
      {
        "json": {
          "chunk": "5. A secure containment chamber with reinforced glass walls displaying the SCP 45 coins back in their dormant state on a pedestal. Several monitoring devices surround the pedestal, including thermal cameras and motion sensors with digital readouts showing extremely low temperatures. A researcher in protective gear stands at a safe distance, taking notes on a tablet. Warning signs on the walls indicate \"NO PHYSICAL CONTACT\" and \"TEMPORAL ANOMALY.\" The lighting is clinical and stark, highlighting the controlled environment in contrast to the earlier study room."
        }
      },
      {
        "json": {
          "chunk": "6. A classified SCP Foundation document page with aged photographs and handwritten notes about SCP 45's historical appearances. The document shows sketches of the coins from different time periods and locations, with red ink highlighting recurring witnesses who reported missing time. A black and white photograph from the 1920s shows identical coins in a museum display, with a blurred figure reaching toward them. The document is stamped \"LEVEL 4 CLEARANCE REQUIRED\" and includes marginalia noting correlation between coin appearances and local temporal anomalies. A coffee cup ring stains one corner of the document, giving it an authentic feel."
        }
      },
      {
        "json": {
          "chunk": "7. An archaeological excavation site inside an ancient temple vault. Researchers in protective gear carefully work around a stone altar where the SCP 45 coins are embedded in a circular pattern. Specialized equipment with SCP Foundation logos monitors the area, with readings showing temporal distortions. One researcher points to strange hieroglyphs on the wall depicting people with missing limbs reaching for circular objects. Small temporal bubbles, visible as distortions in the air, surround parts of the coins. Light from headlamps creates dramatic shadows across the dusty chamber, highlighting the tense, cautious expressions of the recovery team members."
        }
      },
      {
        "json": {
          "chunk": "8. A time-lapse montage showing a research subject affected by SCP 45. The image is split into four quadrants showing the same person at different stages: initially normal, then with a translucent arm, then with half their body faded, and finally just a ghost-like outline barely visible. Each quadrant shows a digital clock in the background with dramatically different times despite being taken minutes apart. The final quadrant shows researchers in hazmat suits responding to the emergency, their movements captured as motion blurs around the fading subject."
        }
      }
    ],
    "When Executed by Another Workflow": [
      {
        "json": {
          "chatId": 775716734,
          "output": "I've generated a 15-second narration about SCP-096 and created the audio file. The narration is:\n\n\"There is a creature called SCP-096 that is very thin and pale. If someone sees its face, even by accident, it becomes extremely upset and will chase them anywhere to keep its face hidden.\"\n\nI've saved the narration text and audio to your project. The audio file has been generated and is available at:\nhttps://tktuvgvuoreixlzuubfz.supabase.co/storage/v1/object/hht/2025-05-14_044617_voice.mp3\n\nThe actual audio length is 23 seconds.\n\nWould you like me to proceed with creating image prompts for this SCP-096 video?"
        }
      }
    ]
  },
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1901c6ab-e8db-40ee-81a2-6dd7967d2dd8",
  "connections": {
    "d7baaaff-a918-487d-970a-d2ef498504b3": {
      "main": [
        [
          {
            "node": "38f15fa8-f9a2-469b-9f30-fed46296bf1f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a1f73d92-b61e-41fa-a0c7-50e72078e096": {
      "main": [
        [
          {
            "node": "38f15fa8-f9a2-469b-9f30-fed46296bf1f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "bd57fe5e-940b-46f9-a76f-ba4d6bae5c7c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5f724698-027f-4e88-8329-1abd00f8e6c7": {
      "main": [
        [
          {
            "node": "a1f73d92-b61e-41fa-a0c7-50e72078e096",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e13e63e9-331e-458b-8933-4ec608eab00a": {
      "main": [
        [
          {
            "node": "a25428d1-d34c-42f4-9a1a-713bef6dc1e9",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "052643fa-6319-43f3-a052-40ed0e255238",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "73dfb105-5ffe-4f8a-b96e-b0b556d73956",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "dab1fb0c-970e-43f7-a335-c48639edaabe": {
      "main": [
        [
          {
            "node": "d7baaaff-a918-487d-970a-d2ef498504b3",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e13e63e9-331e-458b-8933-4ec608eab00a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "51f2598e-4958-4139-ab00-3836b7a52ed5": {
      "main": [
        [
          {
            "node": "94b015d0-a1b7-4e13-973a-5a25fe88c209",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "38f15fa8-f9a2-469b-9f30-fed46296bf1f": {
      "main": [
        [
          {
            "node": "8e14c1e6-ece0-4310-97c2-829a37074706",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e715f898-1bca-4e4e-a463-f30815664766",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "73dfb105-5ffe-4f8a-b96e-b0b556d73956": {
      "main": [
        [
          {
            "node": "dab1fb0c-970e-43f7-a335-c48639edaabe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "052643fa-6319-43f3-a052-40ed0e255238": {
      "main": [
        [
          {
            "node": "dab1fb0c-970e-43f7-a335-c48639edaabe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a25428d1-d34c-42f4-9a1a-713bef6dc1e9": {
      "main": [
        [
          {
            "node": "dab1fb0c-970e-43f7-a335-c48639edaabe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bd57fe5e-940b-46f9-a76f-ba4d6bae5c7c": {
      "main": [
        [
          {
            "node": "dab1fb0c-970e-43f7-a335-c48639edaabe",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b08e8087-f155-4747-a5d8-8c9bb5511777": {
      "main": [
        [
          {
            "node": "94b015d0-a1b7-4e13-973a-5a25fe88c209",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "94b015d0-a1b7-4e13-973a-5a25fe88c209": {
      "main": [
        [],
        [
          {
            "node": "51f2598e-4958-4139-ab00-3836b7a52ed5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8e14c1e6-ece0-4310-97c2-829a37074706": {
      "main": [
        [
          {
            "node": "b08e8087-f155-4747-a5d8-8c9bb5511777",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "286d11cb-f94a-4143-8a27-34b5f4e14192": {
      "main": [
        [
          {
            "node": "5f724698-027f-4e88-8329-1abd00f8e6c7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - その他, ビルディングブロック, 人工知能

有料ですか?

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

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

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

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34