TelegramでGPT-5とチャットする:AI駆動の会話ボット
中級
これはAI Chatbot, Multimodal AI分野の自動化ワークフローで、14個のノードを含みます。主にTelegram, AimlApi, GoogleSheets, TelegramTriggerなどのノードを使用。 TelegramでGPT-5とチャット:AI駆動の会話ボット
前提条件
- •Telegram Bot Token
- •Google Sheets API認証情報
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
"meta": {
"instanceId": "355b2d103ad4834400263e78c73e64bbdb709c896780479c01a9ab9ccd7df6cf",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "368c3442-b61b-4e35-9de0-f7ef3f52aa0f",
"name": "📩 Telegramメッセージ受信",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
1072,
1968
],
"webhookId": "3ceea664-fd53-4141-8bc6-4fdaca0a661d",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "cFC7gGbzU7PQGk6J",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "fe8f2304-f2f6-45d5-8f26-3e07f59f2122",
"name": "付箋 — 概要",
"type": "n8n-nodes-base.stickyNote",
"position": [
1168,
304
],
"parameters": {
"color": 5,
"width": 560,
"height": 496,
"content": "# 💬 AI Chat Bot — Telegram + AIMLAPI (via n8n)\n\nThis workflow lets users chat with **GPT-5** directly in Telegram. Messages are processed and answered in real-time via **AIMLAPI**.\n\n---\n\n## 🚀 Features\n\n* Chat with GPT-5 using natural language\n* Context-aware conversation\n* Telegram delivery of responses\n* Easy to extend with logging or moderation"
},
"typeVersion": 1
},
{
"id": "1d3c2472-92fe-4d4e-b157-81de61882d0b",
"name": "付箋 — カスタマイズ",
"type": "n8n-nodes-base.stickyNote",
"position": [
1168,
816
],
"parameters": {
"color": 5,
"width": 560,
"height": 560,
"content": "## ⚙️ Customization\n\n* Change the `model` parameter to use other AI models (Claude, Gemini, etc.)\n* Add:\n * Message logging to Google Sheets or DB\n * NSFW filtering\n * Command handling (`/help`, `/reset`)\n\n---\n\n## 💡 Example User Flow\n\n1. User sends:\n ```\n What's the capital of Japan?\n ```\n2. Bot replies:\n > The capital of Japan is Tokyo.\n\n3. Chat continues naturally with context preserved"
},
"typeVersion": 1
},
{
"id": "fc3443dd-7c1d-478f-846b-e20b2d480898",
"name": "付箋 — セットアップガイド",
"type": "n8n-nodes-base.stickyNote",
"position": [
1744,
448
],
"parameters": {
"color": 5,
"width": 560,
"height": 544,
"content": "# 🛠 Setup Guide\n\n### 1. 📲 Create a Telegram Bot\n* Go to [@BotFather](https://t.me/BotFather)\n* Use `/newbot`, set a name and username\n* Save the **API token**\n\n---\n### 2. 🔐 Connect Telegram API in n8n\n* Go to `Credentials > Telegram API`\n* Create new credentials using the token from BotFather\n\n---\n### 3. 🔌 Set Up AIMLAPI Credentials in n8n\n* Go to `Credentials > AI/ML API`\n* Enter your **API key**\n* Base URL: `https://api.aimlapi.com/v1`\n* Docs: [docs.aimlapi.com](https://docs.aimlapi.com)"
},
"typeVersion": 1
},
{
"id": "cdd88b85-4766-4e2c-9e5f-7b409963c443",
"name": "付箋 — ロギング&テスト",
"type": "n8n-nodes-base.stickyNote",
"position": [
1744,
1008
],
"parameters": {
"color": 5,
"width": 560,
"height": 432,
"content": "## 📁 Optional Data Logging\n\nYou can log every chat message to Google Sheets or a database for analytics:\n\n` | user_id | date | message | response | `\n` | ------- | ---- | ------- | -------- | `\n\n---\n## 🧪 Testing Tips\n\n* Use a test Telegram chat before production\n* Add `Console` or `Set` nodes to inspect payloads\n* For realistic tests, run via `/execute` from Telegram, **not** \"Execute Node\""
},
"typeVersion": 1
},
{
"id": "f6b40a2d-c83a-47aa-9046-23cdc601ef73",
"name": "📝 生成成功をログ記録",
"type": "n8n-nodes-base.googleSheets",
"position": [
2784,
1968
],
"parameters": {
"columns": {
"value": {
"date": "={{ new Date().toISOString().split('T')[0] }}",
"query": "={{ $('📩 Receive Telegram Message').item.json.message.text }}",
"result": "={{ $('🧠 Process with GPT‑5').item.json.content }}",
"user_id": "={{ $json.result.from.id }}"
},
"schema": [
{
"id": "user_id",
"type": "string",
"display": true,
"required": false,
"displayName": "user_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "date",
"type": "string",
"display": true,
"required": false,
"displayName": "date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "query",
"type": "string",
"display": true,
"required": false,
"displayName": "query",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "result",
"type": "string",
"display": true,
"required": false,
"displayName": "result",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 2060422727,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/19rsFwln4KMpGjOzxOdz7OC_-kRH8_qD4Agx5lXlDD9k/edit#gid=2060422727",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "19rsFwln4KMpGjOzxOdz7OC_-kRH8_qD4Agx5lXlDD9k",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/19rsFwln4KMpGjOzxOdz7OC_-kRH8_qD4Agx5lXlDD9k/edit?usp=drivesdk",
"cachedResultName": "AI bot usage statistic"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "OaJ0A7gqb1dgxqB8",
"name": "Google Sheets account"
}
},
"typeVersion": 4.6
},
{
"id": "a00ee4eb-0c89-48a2-87c1-000197b71a55",
"name": "付箋 — メッセージ受信",
"type": "n8n-nodes-base.stickyNote",
"position": [
944,
1552
],
"parameters": {
"color": 3,
"width": 384,
"height": 608,
"content": "# 📥 Step 1 — Receive Telegram Message\nListens for new messages sent to your Telegram bot.\n\nCaptures:\n* **chat.id** — used for sending responses back\n* **message.text** — the text provided by the user\n\n💡 You can restrict to specific commands/keywords if needed."
},
"typeVersion": 1
},
{
"id": "375019d6-a2c0-438c-950c-376603599dc5",
"name": "付箋 — GPT‑5処理",
"type": "n8n-nodes-base.stickyNote",
"position": [
1744,
1552
],
"parameters": {
"width": 384,
"height": 608,
"content": "# 🧠 Step 2 — Process with GPT‑5\nSends the raw Telegram message text to **AI/ML API** using `openai/gpt-5-chat-latest`.\n\nPurpose:\n* Improve or expand the input text\n* Make it more descriptive/structured as needed\n\n⚙️ Configurable:\n* Change the model ID\n* Add system instructions to control style, tone, or length"
},
"typeVersion": 1
},
{
"id": "e58d2186-f12e-43a4-9b7c-a644d27e64fa",
"name": "付箋 — 応答送信",
"type": "n8n-nodes-base.stickyNote",
"position": [
2144,
1552
],
"parameters": {
"color": 4,
"width": 384,
"height": 608,
"content": "# 📤 Step 3 — Send Response to Telegram\nSends the model’s response back to the same user.\n\nIncludes:\n* **chat_id** — from the original message\n* **text/caption** — the result returned by GPT‑5\n\n💡 You can format text, add emojis, or customize the reply style here."
},
"typeVersion": 1
},
{
"id": "06a31bfb-15af-40fe-b468-057cf985180f",
"name": "付箋 — ロギング",
"type": "n8n-nodes-base.stickyNote",
"position": [
2640,
1552
],
"parameters": {
"color": 5,
"width": 384,
"height": 608,
"content": "# 📝 Step 4 — Log Interaction (Optional)\nAppends a row to your sheet/database with:\n* **date** — ISO date\n* **user_id** — from Telegram\n* **query** — original message text\n* **result** — model output (text or link, depending on your setup)\n\nUse this for:\n* Usage tracking & quotas\n* Analytics and QA"
},
"typeVersion": 1
},
{
"id": "333a49e9-e553-4f95-87b9-d89548db6114",
"name": "🧠 GPT‑5で処理",
"type": "n8n-nodes-aimlapi.aimlApi",
"position": [
1888,
1968
],
"parameters": {
"model": "openai/gpt-5-chat-latest",
"prompt": "={{ $('📩 Receive Telegram Message').item.json.message.text }}",
"options": {},
"requestOptions": {}
},
"credentials": {
"aimlApi": {
"id": "EXXHjMACiSMAhuC8",
"name": "AI/ML account"
}
},
"retryOnFail": false,
"typeVersion": 1,
"alwaysOutputData": false
},
{
"id": "960ea33b-3c1a-4ad1-a330-18aab8bc030a",
"name": "📤 Telegramへ応答送信",
"type": "n8n-nodes-base.telegram",
"position": [
2288,
1968
],
"webhookId": "4a46da0a-9a91-4f31-802a-f0ce89516aa7",
"parameters": {
"text": "={{ $json.content }}",
"chatId": "={{ $('📩 Receive Telegram Message').item.json.message.chat.id }}",
"additionalFields": {
"appendAttribution": false,
"reply_to_message_id": "={{ $('📩 Receive Telegram Message').item.json.message.message_id }}"
}
},
"credentials": {
"telegramApi": {
"id": "cFC7gGbzU7PQGk6J",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "7cc29371-2e04-440c-baea-4f7a716a5acf",
"name": "付箋 — メッセージ受信1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1344,
1552
],
"parameters": {
"color": 3,
"width": 384,
"height": 608,
"content": "# 💬 Step 1.5 — Simulate Typing in Telegram\n\n\nSends a \"typing…\" chat action to the user in Telegram before delivering the actual \nresponse. \n\nThis creates a more natural conversational experience by letting the user know the bot is processing their message. \n\nUseful for longer AI processing times or when generating detailed responses."
},
"typeVersion": 1
},
{
"id": "3e50eeda-e420-48fe-b136-1191d679f422",
"name": "💬 Telegramで入力中をシミュレート",
"type": "n8n-nodes-base.telegram",
"position": [
1488,
1968
],
"webhookId": "d275c6c6-00c3-4ccd-9e29-48c99574d7b2",
"parameters": {
"chatId": "={{ $json.message.chat.id }}",
"operation": "sendChatAction"
},
"credentials": {
"telegramApi": {
"id": "cFC7gGbzU7PQGk6J",
"name": "Telegram account"
}
},
"typeVersion": 1.2
}
],
"pinData": {},
"connections": {
"333a49e9-e553-4f95-87b9-d89548db6114": {
"main": [
[
{
"node": "960ea33b-3c1a-4ad1-a330-18aab8bc030a",
"type": "main",
"index": 0
}
]
]
},
"368c3442-b61b-4e35-9de0-f7ef3f52aa0f": {
"main": [
[
{
"node": "3e50eeda-e420-48fe-b136-1191d679f422",
"type": "main",
"index": 0
}
]
]
},
"960ea33b-3c1a-4ad1-a330-18aab8bc030a": {
"main": [
[
{
"node": "f6b40a2d-c83a-47aa-9046-23cdc601ef73",
"type": "main",
"index": 0
}
]
]
},
"3e50eeda-e420-48fe-b136-1191d679f422": {
"main": [
[
{
"node": "333a49e9-e553-4f95-87b9-d89548db6114",
"type": "main",
"index": 0
}
]
]
}
}
}よくある質問
このワークフローの使い方は?
上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。
このワークフローはどんな場面に適していますか?
中級 - AIチャットボット, マルチモーダルAI
有料ですか?
このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。
関連ワークフロー
Telegram、AIMLAPI、Google Sheetsを使用してマルチモデルAIチャットボットを作成
Telegram、AIMLAPI、Google スプレッドシートを使って多模型AIチャットボットを作成
If
Set
Code
+
If
Set
Code
25 ノードAI/ML API | D1m7asis
個人の生産性
Telegram で GPT-4o を使って Flux Pro と合わせて AI 画像を生成
Telegram 内で GPT-4o と Flux Pro を使って AI 画像を生成
If
Set
Telegram
+
If
Set
Telegram
22 ノードAI/ML API | D1m7asis
コンテンツ作成
GPT-4oを使用したTelegramメンタルヘルスサポートボットの構築
GPT-4oをベースとしたTelegramメンタルヘルスサポートボットを構築
Set
Switch
Telegram
+
Set
Switch
Telegram
15 ノードAI/ML API | D1m7asis
サポートチャットボット
GPT-4oとTelegramを活用した対話式ロシア語学習チャットボット
GPT-4oとTelegramを基盤としたインタラクティブなロシア語チューターボット
Set
Switch
Telegram
+
Set
Switch
Telegram
16 ノードAI/ML API | D1m7asis
コンテンツ作成
带有 Chatgpt Agent Prompt 检查の信用卡
AI驱动信用卡推荐系统,統合OpenAI GPT、TelegramとGoogle Sheets
If
Set
Code
+
If
Set
Code
31 ノードNishant
AIチャットボット
GPT-4o VisionでTelegram画像の分析とテキスト抽出
GPT-4o Vision と Telegram を使って画像の分析とテキスト抽出
Code
Telegram
Http Request
+
Code
Telegram
Http Request
16 ノードAI/ML API | D1m7asis
文書抽出