Telegramチャットボットの構築:Gemini Pro AIとGoogle Docsを統合

中級

これはSupport Chatbot, AI Chatbot, Multimodal AI分野の自動化ワークフローで、9個のノードを含みます。主にWait, Telegram, GoogleDocsTool, SplitInBatches, HttpRequestToolなどのノードを使用。 TelegramチャットボットにGemini Pro AIとGoogle Docsを統合

前提条件
  • Telegram Bot Token
  • ターゲットAPIの認証情報が必要な場合あり
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "cb9a1e5321767b6316634728341237e564b2587ab15b74ca0a89eb02a53484d6",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "17ac7115-a306-40bf-8b4a-9ce66ebbe3f1",
      "name": "モデルにメッセージを送信",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        4800,
        1232
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.5-pro",
          "cachedResultName": "models/gemini-2.5-pro"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "Replay test write user-friendly."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "fbd4e562-fb5a-4e85-9814-75e4a9df2900",
      "name": "テキストメッセージを送信",
      "type": "n8n-nodes-base.telegram",
      "position": [
        5216,
        1232
      ],
      "webhookId": "3111e55e-41d3-4e3b-863c-bfda700bba92",
      "parameters": {
        "text": "={{ $json.content.parts[0].text }}",
        "chatId": "={{ $('Telegram Trigger').item.json.message.from.id }}",
        "replyMarkup": "replyKeyboard",
        "additionalFields": {},
        "replyKeyboardOptions": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "98b5b120-ab55-47b2-8f0d-0bc29b32bb7f",
      "name": "Google Docsでドキュメントを取得",
      "type": "n8n-nodes-base.googleDocsTool",
      "position": [
        5184,
        1488
      ],
      "parameters": {
        "simple": false,
        "operation": "get",
        "documentURL": "https://docs.google.com/document/d/19vaCViYaFkjFM6azAMf6fH6tDL2cwSsjTE5vX3eK6Ss"
      },
      "typeVersion": 2
    },
    {
      "id": "c3df74b4-6077-4383-9c23-2f7505cea1fe",
      "name": "Telegramトリガー",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        4224,
        1216
      ],
      "webhookId": "05fcff6f-5e32-4599-9b29-c585878352d8",
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "41eee1be-dfb9-4e7d-b659-a9de0e740e7a",
      "name": "1秒待機",
      "type": "n8n-nodes-base.wait",
      "position": [
        5488,
        1232
      ],
      "webhookId": "8223d68f-b3b2-4c42-a6d2-473a19e2904c",
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    },
    {
      "id": "3dc90867-9946-4143-aeb9-a096993486c5",
      "name": "Google Geminiでモデルにメッセージを送信",
      "type": "@n8n/n8n-nodes-langchain.googleGeminiTool",
      "position": [
        4992,
        1488
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "models/gemini-2.0-flash-exp",
          "cachedResultName": "models/gemini-2.0-flash-exp"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "Replay test write user-friendly."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0049c3fc-f6a2-420f-b0ca-c7330021a405",
      "name": "HTTPリクエスト",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        4768,
        1488
      ],
      "parameters": {
        "url": "https://devcodejourney.com/",
        "options": {},
        "toolDescription": "Replay test write user-friendly."
      },
      "typeVersion": 4.2
    },
    {
      "id": "162fb82a-9ced-401a-a67e-6c4d3b84d118",
      "name": "付箋ノート",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2544,
        1184
      ],
      "parameters": {
        "width": 1552,
        "height": 2352,
        "content": "# 🤖 Telegram + Gemini + Google Docs Automation in n8n\n\n## 📌 Overview\n\nThis n8n workflow listens for messages sent to a Telegram bot and replies with AI-generated responses using **Google Gemini (PaLM)**. It optionally interacts with **Google Docs** to fetch documents and makes external API requests using an **HTTP Request** node.\n\nThe flow also includes batching and waiting logic to control the pace of replies, making it scalable and human-friendly.\n\n---\n\n## 🧠 What This Workflow Does\n\n### ✅ 1. Trigger from Telegram\n- **Node**: `Telegram Trigger`\n- **Function**: Starts the workflow when a message is received via your Telegram bot.\n\n### ✅ 2. Loop Through Messages\n- **Node**: `Loop Over Items`\n- **Function**: Allows processing multiple incoming messages if required, using batching logic.\n\n### ✅ 3. AI-Powered Reply with Gemini\n- **Node**: `Message a model` (Google Gemini Pro)\n- **Function**: Sends the message to the Gemini AI (via Google PaLM API) to generate a human-friendly, conversational response.\n\n### ✅ 4. Send AI Response via Telegram\n- **Node**: `Send a text message`\n- **Function**: Sends the generated Gemini response back to the user on Telegram.\n\n### ✅ 5. Delay Between Replies\n- **Node**: `Wait 1s`\n- **Function**: Adds a 1-second delay before proceeding to the next message in the loop (helps avoid Telegram rate limits and creates more natural pacing).\n\n### ✅ 6. Optional: External API Request\n- **Node**: `HTTP Request`\n- **Function**: Makes an external API request to `https://devcodejourney.com/` (placeholder URL).\n- **Note**: Currently not connected to message flow but can be used to fetch or send additional data.\n\n### ✅ 7. Optional: Fetch Document from Google Docs\n- **Node**: `Get a document in Google Docs`\n- **Function**: Retrieves the contents of a Google Docs document from a provided link. Can be used to add static text, FAQs, or templates to the conversation.\n\n### ✅ 8. Optional: Alternate Gemini Tool\n- **Node**: `Message a model in Google Gemini`\n- **Function**: Uses a different version (`gemini-2.0-flash-exp`) of the Gemini AI model for fast responses or testing purposes.\n\n---\n\n## 🔧 Technologies Used\n\n- **Telegram Bot API** – for message triggers and replies  \n- **Google Gemini (PaLM API)** – for AI-generated responses  \n- **Google Docs API** – to fetch document content  \n- **HTTP Request** – to connect to any third-party API  \n- **n8n** – no-code/low-code workflow automation platform  \n\n---\n\n## ⚙️ Use Cases\n\n- AI Chatbot for Telegram using Gemini  \n- Personal Assistant or FAQ bot reading from Google Docs  \n- Customer service bot that replies in natural language  \n- Looping conversations with controlled pacing  \n- External data fetching with AI processing  \n\n---\n\n## 📌 Notes\n\n- Make sure you have the correct credentials configured in n8n for:\n  - Telegram Bot\n  - Google Docs OAuth2\n  - Google Gemini API (PaLM)\n- You can add error-handling nodes or conditionals to expand the logic.\n- This can be extended into a full AI chatbot or customer support bot.\n\n---\n\n## 🧩 Nodes Used\n\n| Node Name                          | Type                       | Purpose                                 |\n|-----------------------------------|----------------------------|-----------------------------------------|\n| Telegram Trigger                  | telegramTrigger            | Listens for incoming Telegram messages  |\n| Loop Over Items                   | splitInBatches             | Handles batching of incoming data       |\n| Message a model                   | langchain.googleGemini     | Sends prompt to Google Gemini (Pro)     |\n| Send a text message               | telegram                   | Sends response back to Telegram user    |\n| Wait 1s                           | wait                        | Adds a delay between responses          |\n| HTTP Request                      | httpRequestTool            | Sends HTTP request to external API      |\n| Get a document in Google Docs     | googleDocsTool             | Fetches content from Google Docs        |\n| Message a model in Google Gemini | googleGeminiTool           | Alternate Gemini model for responses    |\n\n---\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9c16c31f-95db-40ab-aa8d-37750b123d2a",
      "name": "アイテムをループ処理1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        4480,
        1216
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    }
  ],
  "pinData": {},
  "connections": {
    "41eee1be-dfb9-4e7d-b659-a9de0e740e7a": {
      "main": [
        [
          {
            "node": "9c16c31f-95db-40ab-aa8d-37750b123d2a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0049c3fc-f6a2-420f-b0ca-c7330021a405": {
      "ai_tool": [
        [
          {
            "node": "17ac7115-a306-40bf-8b4a-9ce66ebbe3f1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "17ac7115-a306-40bf-8b4a-9ce66ebbe3f1": {
      "main": [
        [
          {
            "node": "fbd4e562-fb5a-4e85-9814-75e4a9df2900",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9c16c31f-95db-40ab-aa8d-37750b123d2a": {
      "main": [
        [],
        [
          {
            "node": "17ac7115-a306-40bf-8b4a-9ce66ebbe3f1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c3df74b4-6077-4383-9c23-2f7505cea1fe": {
      "main": [
        [
          {
            "node": "9c16c31f-95db-40ab-aa8d-37750b123d2a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fbd4e562-fb5a-4e85-9814-75e4a9df2900": {
      "main": [
        [
          {
            "node": "41eee1be-dfb9-4e7d-b659-a9de0e740e7a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "98b5b120-ab55-47b2-8f0d-0bc29b32bb7f": {
      "ai_tool": [
        [
          {
            "node": "17ac7115-a306-40bf-8b4a-9ce66ebbe3f1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "3dc90867-9946-4143-aeb9-a096993486c5": {
      "ai_tool": [
        [
          {
            "node": "17ac7115-a306-40bf-8b4a-9ce66ebbe3f1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

中級 - サポートチャットボット, AIチャットボット, マルチモーダルAI

有料ですか?

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

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

経験者向け、6-15ノードの中程度の複雑さのワークフロー

作成者
DevCode Journey

DevCode Journey

@devcodejourney

I build intelligent systems that automate tasks, streamline workflows, and enhance user experiences using tools like n8n, AI chatbots, and modern automation platforms. With a passion for solving real-world problems through smart technology, I create custom solutions that help individuals and businesses save time, scale faster, and work smarter. Whether it's integrating APIs, building no-code/low-code automations, or developing conversational AI, I'm always exploring the edge of what's possible.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34