Telegram Q&Aボットの構築:Linkupネットワーク検索、GPT-4.1、Mistral音声を統合

上級

これは自動化ワークフローで、21個のノードを含みます。主にIf, Set, Switch, Telegram, HttpRequestなどのノードを使用。 Linkupネットワーク検索、GPT-4.1、Mistral音声を統合したTelegram Q&Aボットを構築

前提条件
  • Telegram Bot Token
  • ターゲットAPIの認証情報が必要な場合あり
  • OpenAI API Key

カテゴリー

-
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "nodes": [
    {
      "id": "c1fbf4de-ddf2-450d-b09c-d07025d643f5",
      "name": "Telegramトリガー",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        240,
        544
      ],
      "webhookId": "cce06804-3cd5-4dff-a90a-ed4ce49b0b04",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "GQHcQvX9GizW5ai3",
          "name": "Duv Brain Telegram"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "f2e6b66d-8c5f-44fc-9bcf-34d48a7d8cd3",
      "name": "自分?",
      "type": "n8n-nodes-base.if",
      "position": [
        464,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fae16f10-e497-47ea-92ec-741f54cedd62",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.message.from.username }}",
              "rightValue": "<Replace with your Telegram username>"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d4b2699d-bff8-424c-a8e9-3879fbcb2a6a",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        2256,
        560
      ],
      "parameters": {
        "text": "={{ $json.final_user_message }}",
        "options": {
          "systemMessage": "=You are a helpful assistant that answers the user based on web-search.\n\nWhenever the user query requires getting insights from the web (most queries except empty queries like \"hi\"), call the tool \"Web search\" with a question to have it output an answer based on AI web search.\n\nProvide sources of the main insights.\n\nAnswer considring that this conversation happens on Telegram - adapt your style/format to that platform."
        },
        "promptType": "define"
      },
      "typeVersion": 1.8
    },
    {
      "id": "49ca5d84-ebac-41db-a961-f6c66d75a468",
      "name": "シンプルメモリ",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        2272,
        816
      ],
      "parameters": {
        "sessionKey": "={{ $('Telegram Trigger').item.json.message.from.username }}",
        "sessionIdType": "customKey",
        "contextWindowLength": 7
      },
      "typeVersion": 1.3
    },
    {
      "id": "1cad1569-ebc5-4446-8a8d-898cbfcebbbf",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        272
      ],
      "parameters": {
        "color": 2,
        "width": 873,
        "height": 293,
        "content": "# Process Audio"
      },
      "typeVersion": 1
    },
    {
      "id": "21b52da1-5a08-4f7b-9b83-56ec4b12fe07",
      "name": "音声ファイル取得",
      "type": "n8n-nodes-base.telegram",
      "position": [
        976,
        400
      ],
      "webhookId": "aa1f75c8-2c80-4fab-be6c-b4120381181d",
      "parameters": {
        "fileId": "={{ $('Telegram Trigger').item.json.message.voice.file_id }}",
        "resource": "file",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "GQHcQvX9GizW5ai3",
          "name": "Duv Brain Telegram"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "05bf3117-933d-4a17-bee7-ca26b454abc7",
      "name": "メッセージルーター",
      "type": "n8n-nodes-base.switch",
      "position": [
        688,
        512
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "audio",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b5d9f703-2a1b-4942-906c-7a7d1404a4d7",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.voice }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "342f0883-d959-44a2-b80d-379e39c76218",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('Telegram Trigger').item.json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "a0c3018c-0e5e-4184-9586-422fdb5aa16f",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2400,
        768
      ],
      "parameters": {
        "color": 6,
        "width": 336,
        "height": 368,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## Linkup web search\n\nReplace the API key placeholder with your linkup.so API key, or store it as a credential to reuse it easily in other workflows."
      },
      "typeVersion": 1
    },
    {
      "id": "93107652-cd00-4d85-9eb7-2d42276e76a1",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1904,
        768
      ],
      "parameters": {
        "color": 5,
        "width": 336,
        "height": 368,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n## AI model\n\nThe core AI model of your agent. Connect your OpenAI API key or switch to your favorite LLM provider."
      },
      "typeVersion": 1
    },
    {
      "id": "4a1bde4f-df6e-45b5-a91c-613e5673848f",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2192,
        320
      ],
      "parameters": {
        "color": 4,
        "width": 352,
        "height": 400,
        "content": "## The agent\n\nThis agent will distribute the relevant questions to the Linkup tool via the \"Web search\" tool. Feel free to provide more context in its system message and add instructions when it comes to the format or style of responses?"
      },
      "typeVersion": 1
    },
    {
      "id": "4f0fbc4e-55af-4b3e-b187-fab5231442ab",
      "name": "OpenAIチャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        2032,
        832
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "dMiSy27YCK6c6rra",
          "name": "Duv's OpenAI"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "469db785-dad8-4f46-ae4e-a73936d5c063",
      "name": "Telegram回答",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2832,
        560
      ],
      "webhookId": "7ac3dfe6-5df8-4791-8765-2234d475c22d",
      "parameters": {
        "text": "={{ $json.output }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "id": "GQHcQvX9GizW5ai3",
          "name": "Duv Brain Telegram"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d8484fa4-6147-49f5-a4cf-549a9b9c609c",
      "name": "付箋6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        288
      ],
      "parameters": {
        "color": 7,
        "width": 265,
        "height": 261,
        "content": "### AI transcription\n\nYou can replace with another model like OpenAI's."
      },
      "typeVersion": 1
    },
    {
      "id": "b99a6e1e-d26a-405f-a9ad-68a3f9108734",
      "name": "付箋7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        384,
        304
      ],
      "parameters": {
        "color": 3,
        "width": 265,
        "height": 405,
        "content": "### Make this bot private\n\nTelegram bots are public by default, so we're adding a filter here based on your unique Telegram username. Change the value to ensure only your messages can go through, or delete this step to make it 100% public"
      },
      "typeVersion": 1
    },
    {
      "id": "95bd10b8-242f-4947-a763-4fe69c507285",
      "name": "付箋8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        592
      ],
      "parameters": {
        "color": 2,
        "width": 873,
        "height": 293,
        "content": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Process text"
      },
      "typeVersion": 1
    },
    {
      "id": "48d77137-bc1a-4ae2-8b03-48ddcd17c4cf",
      "name": "音声からのメッセージ準備",
      "type": "n8n-nodes-base.set",
      "position": [
        1568,
        400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "bffc2c1f-990e-4396-b59a-ab82b843e061",
              "name": "preset_user_message",
              "type": "string",
              "value": "={{ $json.choices[0].message.content }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8a59c1a6-4b6c-4356-a083-33f2f8cb7651",
      "name": "テキストからのメッセージ準備",
      "type": "n8n-nodes-base.set",
      "position": [
        1280,
        672
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "b37b48ba-8fef-4e6c-bbca-73e6c2e1e0a8",
              "name": "preset_user_message",
              "type": "string",
              "value": "={{ $('Telegram Trigger').item.json.message.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "edc01d56-b1de-4e22-b8f8-60540d53434c",
      "name": "ユーザーメッセージ統合",
      "type": "n8n-nodes-base.set",
      "position": [
        1872,
        560
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7db97ffc-b1eb-422e-8bb1-90eea55c7aa2",
              "name": "final_user_message",
              "type": "string",
              "value": "={{ $json.preset_user_message }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "27a2b573-bbe5-47b6-a7ab-57c41a566d07",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -400
      ],
      "parameters": {
        "width": 880,
        "height": 544,
        "content": "# **AI Web Search Telegram Agent with Linkup & GPT-4.1 (text + voice)**\n\n**Summary:** A Telegram bot that answers questions using **Linkup** AI web search. Accepts text and voice (transcribed via **Mistral** by default) and uses an LLM agent that calls the **Web search** tool.\n\n**How it works (short):**\n1.  **Telegram Trigger** → Detects text or voice via **Message Router**.\n2.  Voice: **Get Audio File** → **Mistral transcribe** → prepare text.\n3.  **AI Agent** calls **Web search** (Linkup) when web knowledge is needed and sends answers via **Telegram answer**.\n\n**How to use / Setup:**\n1.  Create a Linkup account at [linkup.so](https://linkup.so) and get your **API Key**.\n2.  In the **Web search** node, go to the \"Headers\" section and replace the placeholder API key with your actual key in the `Authorization` field.\n3.  Add credentials: **Telegram API**, **OpenAI (or LLM)**, **Mistral Cloud**.\n4.  (Optional) Edit **Myself?** to set your Telegram username for private testing or delete it to make the bot public.\n5.  Activate the workflow and message your bot in Telegram.\n\n**Bold nodes to configure:** **Telegram Trigger**, **Web search**, **OpenAI Chat Model**, **Mistral transcribe**, **Myself?**\n\n*A template created by Guillaume Duvernay*"
      },
      "typeVersion": 1
    },
    {
      "id": "0e9b76b5-1d89-49f2-924f-53325a6a8507",
      "name": "ウェブ検索",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        2544,
        832
      ],
      "parameters": {
        "url": "https://api.linkup.so/v1/search",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "q",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters0_Value', `The query for AI web-search`, 'string') }}"
            },
            {
              "name": "depth",
              "value": "standard"
            },
            {
              "name": "outputType",
              "value": "sourcedAnswer"
            },
            {
              "name": "includeImages",
              "value": "false"
            },
            {
              "name": "includeInlineCitations",
              "value": "false"
            }
          ]
        },
        "toolDescription": "Call this tool when web-search base is required to answer the user query.",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer <your Linkup API key>"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "853eea91-4385-46bd-aaf7-5f910d6afbd6",
      "name": "Mistral文字起こし",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1280,
        400
      ],
      "parameters": {
        "url": "https://api.mistral.ai/v1/audio/transcriptions",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "voxtral-mini-2507"
            },
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "nodeCredentialType": "mistralCloudApi"
      },
      "credentials": {
        "mistralCloudApi": {
          "id": "vakRnCmKyOQFpdEk",
          "name": "Mistral Cloud account"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "connections": {
    "f2e6b66d-8c5f-44fc-9bcf-34d48a7d8cd3": {
      "main": [
        [
          {
            "node": "05bf3117-933d-4a17-bee7-ca26b454abc7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "d4b2699d-bff8-424c-a8e9-3879fbcb2a6a": {
      "main": [
        [
          {
            "node": "469db785-dad8-4f46-ae4e-a73936d5c063",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0e9b76b5-1d89-49f2-924f-53325a6a8507": {
      "ai_tool": [
        [
          {
            "node": "d4b2699d-bff8-424c-a8e9-3879fbcb2a6a",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "49ca5d84-ebac-41db-a961-f6c66d75a468": {
      "ai_memory": [
        [
          {
            "node": "d4b2699d-bff8-424c-a8e9-3879fbcb2a6a",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "21b52da1-5a08-4f7b-9b83-56ec4b12fe07": {
      "main": [
        [
          {
            "node": "853eea91-4385-46bd-aaf7-5f910d6afbd6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "05bf3117-933d-4a17-bee7-ca26b454abc7": {
      "main": [
        [
          {
            "node": "21b52da1-5a08-4f7b-9b83-56ec4b12fe07",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "8a59c1a6-4b6c-4356-a083-33f2f8cb7651",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c1fbf4de-ddf2-450d-b09c-d07025d643f5": {
      "main": [
        [
          {
            "node": "f2e6b66d-8c5f-44fc-9bcf-34d48a7d8cd3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4f0fbc4e-55af-4b3e-b187-fab5231442ab": {
      "ai_languageModel": [
        [
          {
            "node": "d4b2699d-bff8-424c-a8e9-3879fbcb2a6a",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "853eea91-4385-46bd-aaf7-5f910d6afbd6": {
      "main": [
        [
          {
            "node": "48d77137-bc1a-4ae2-8b03-48ddcd17c4cf",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "edc01d56-b1de-4e22-b8f8-60540d53434c": {
      "main": [
        [
          {
            "node": "d4b2699d-bff8-424c-a8e9-3879fbcb2a6a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8a59c1a6-4b6c-4356-a083-33f2f8cb7651": {
      "main": [
        [
          {
            "node": "edc01d56-b1de-4e22-b8f8-60540d53434c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "48d77137-bc1a-4ae2-8b03-48ddcd17c4cf": {
      "main": [
        [
          {
            "node": "edc01d56-b1de-4e22-b8f8-60540d53434c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級

有料ですか?

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

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

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

作成者
Guillaume Duvernay

Guillaume Duvernay

@duv

AI and automation expert

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34