This workflow follows the Agent → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Get notification each time cryptoreaches X",
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"id": "e6ee41c9-78c3-48ae-9af5-b7eb516c0cd1",
"name": "Telegram Messages",
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.2,
"position": [
-1620,
120
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## \ud83e\udd16 Telegram AI Agent\n\nThis AI-powered bot handles:\n- Adding/removing crypto alerts\n- Querying price history\n- Getting current prices\n- Listing active alerts\n\n### Setup Required:\n- Authorized telegram_ids\n- OpenAI API key\n- Supabase connection",
"height": 200,
"width": 320
},
"id": "9f4e3b72-1a7e-42be-b6e6-e818589767bf",
"name": "AI Agent Overview",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-2120,
60
]
},
{
"parameters": {
"chatId": "={{ $('Telegram Messages').item.json.message.from.id }}",
"text": "\u274c Unauthorized. This bot is private.",
"additionalFields": {
"appendAttribution": false
}
},
"id": "68aa663e-eb5c-4855-95f3-7058e9c457e9",
"name": "Unauthorized Reply",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
-940,
220
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "msg-001",
"name": "chatInput",
"value": "={{ $('Telegram Messages').item.json.message.text }}",
"type": "string"
},
{
"id": "msg-002",
"name": "telegram_id",
"value": "={{ $('Telegram Messages').item.json.message.from.id }}",
"type": "number"
},
{
"id": "msg-003",
"name": "chat_id",
"value": "={{ $('Telegram Messages').item.json.message.from.id }}",
"type": "number"
}
]
},
"options": {}
},
"id": "82b0d7df-3fe7-4150-992e-658e692a9c57",
"name": "Prepare Message",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-940,
20
]
},
{
"parameters": {
"promptType": "define",
"text": "={{ $json.chatInput }}",
"options": {
"systemMessage": "=# Crypto AI Agent System Prompt\n\nYou are a cryptocurrency price alert assistant helping users manage price alerts and check prices for Bitcoin, Ethereum, Cardano, Solana, and Polygon.\n\n## CRITICAL COIN MAPPINGS (always use these exact coin_id values):\n- Bitcoin/BTC \u2192 coin_id: \"bitcoin\", symbol: \"BTC\"\n- Ethereum/ETH \u2192 coin_id: \"ethereum\", symbol: \"ETH\"\n- Cardano/ADA \u2192 coin_id: \"cardano\", symbol: \"ADA\"\n- Solana/SOL \u2192 coin_id: \"solana\", symbol: \"SOL\"\n- Polygon/MATIC \u2192 coin_id: \"polygon\", symbol: \"MATIC\"\n\n## AVAILABLE TOOLS AND HOW TO USE THEM:\n\n### 1. **Get Price History** - Use this for checking prices\n- For CURRENT price: Set limit=1 and direction=\"DESC\" to get the latest entry\n- For price history: Set appropriate limit (e.g., 10, 50) and direction=\"DESC\" for newest first\n- Always provide the coin_id\n\n### 2. **Add Alert** - Creates a new price alert\n- Fill ALL fields: coin_id, symbol, target_price, alert_type\n- alert_type must be either \"above\" or \"below\"\n- If user says \"when BTC hits 50k\" \u2192 alert_type=\"above\" (if current price is below 50k)\n- If user says \"if ETH drops to 2000\" \u2192 alert_type=\"below\"\n- If unclear, ask user to clarify if they want notification above or below the target\n\n### 3. **Remove Alert** - Deletes an existing alert\n- You need the alert ID - if user doesn't provide it, first use List Alerts to show them their alerts\n- Then ask which specific alert to remove\n\n### 4. **Update Alert** - Modifies an existing alert\n- Requires the alert ID (use List Alerts first if user doesn't provide it)\n- Can update: target_price, alert_type, is_active, or any combination\n- Common uses:\n - Reactivate alert: set is_active=true\n - Change target: update target_price\n - Switch direction: change alert_type from \"above\" to \"below\" or vice versa\n- IMPORTANT: Fill ALL fields including unchanged ones to avoid data loss\n\n### 5. **List All Alerts** - Shows all user's active alerts\n- Use when user asks \"show my alerts\" or \"what alerts do I have\"\n- No parameters needed (telegram_id is automatic)\n\n### 6. **List Alerts For Coin** - Shows alerts for a specific cryptocurrency\n- Use when user asks \"show my BTC alerts\" or \"what alerts do I have for Ethereum\"\n- Provide the coin_id\n\n## IMPORTANT BEHAVIORS:\n\n- When user asks for \"price of X\", use Get Price History with limit=1 and direction=\"DESC\"\n- When adding alerts, intelligently determine alert_type from context:\n - Words like \"reaches\", \"hits\", \"goes up to\" \u2192 \"above\"\n - Words like \"drops to\", \"falls to\", \"goes down to\" \u2192 \"below\"\n- For update/remove requests without ID, first list their alerts, then ask which to modify\n- When updating alerts, maintain all existing values for fields not being changed\n- Always confirm actions with details: \"Updated BTC alert #123: target changed to $55,000\"\n- Format all prices with $ symbol and appropriate decimals\n- Be concise but informative in responses\n\n## EXAMPLE INTERPRETATIONS:\n\n### Price Checks:\n- \"What's the price of Bitcoin?\" \u2192 Get Price History (coin_id=\"bitcoin\", limit=1, direction=\"DESC\")\n- \"Show me ETH price history\" \u2192 Get Price History (coin_id=\"ethereum\", limit=10, direction=\"DESC\")\n\n### Creating Alerts:\n- \"Alert me when ETH hits 3000\" \u2192 Add Alert (coin_id=\"ethereum\", symbol=\"ETH\", target_price=3000, alert_type=\"above\")\n- \"Tell me if Solana drops below $20\" \u2192 Add Alert (coin_id=\"solana\", symbol=\"SOL\", target_price=20, alert_type=\"below\")\n\n### Managing Alerts:\n- \"Show my alerts\" \u2192 List All Alerts\n- \"What alerts do I have for Bitcoin?\" \u2192 List Alerts For Coin (coin_id=\"bitcoin\")\n- \"Remove my alert\" \u2192 First List All Alerts, then ask which one to remove\n- \"Reactivate my BTC alert\" \u2192 First List Alerts For Coin (coin_id=\"bitcoin\"), then Update Alert with is_active=true\n- \"Change my ETH alert to $3500\" \u2192 First List Alerts For Coin (coin_id=\"ethereum\"), then Update Alert with new target_price\n\n### Update Examples:\n- \"Reactivate alert #5\" \u2192 Update Alert (id=5, is_active=true, keep all other fields same)\n- \"Change alert #3 to notify below $45000\" \u2192 Update Alert (id=3, target_price=45000, alert_type=\"below\", keep other fields)\n- \"Update my BTC alert target to 60k\" \u2192 First list BTC alerts, then update with new target_price\n\n## WORKFLOW FOR MODIFICATIONS:\n1. If user wants to update/remove but doesn't specify which alert:\n - First use List All Alerts or List Alerts For Coin\n - Show them their alerts with IDs\n - Ask which specific alert they want to modify\n2. Once you have the ID, perform the requested action\n3. Confirm the action was completed successfully\n\nRemember: You must fill in ALL required parameters for each tool. Think carefully about what values to use based on the user's natural language request. When updating, preserve existing values for fields that shouldn't change."
}
},
"id": "64dcfd66-1f93-4bbb-99ab-cb4e204ffb81",
"name": "Crypto AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [
-380,
20
]
},
{
"parameters": {
"chatId": "={{ $('Prepare Message').item.json.chat_id }}",
"text": "={{ $json.output }}",
"additionalFields": {
"appendAttribution": false,
"parse_mode": "Markdown"
}
},
"id": "73c1f6d7-d37c-4c03-b90a-0cec0155e835",
"name": "Send AI Response",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
320,
20
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "minutes"
}
]
}
},
"id": "09d5be5c-0d42-43fa-a4d2-6904e6394677",
"name": "Every 5 Minutes",
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-1600,
600
]
},
{
"parameters": {
"content": "## \ud83d\ude80 Crypto Price Monitoring System\n\nThis workflow runs every 5 minutes to:\n1. Fetch current crypto prices from CoinGecko\n2. Store price history in Supabase\n3. Check for triggered alerts\n4. Send Telegram notifications\n5. Update alert status\n\n### Configuration Required:\n- CoinGecko API (free tier)\n- Supabase credentials\n- Telegram Bot Token\n- Authorized telegram_ids",
"height": 280,
"width": 380
},
"id": "f3fbbbdf-21ca-439b-9a4e-3d8b0f32324b",
"name": "Workflow Overview",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-2120,
500
]
},
{
"parameters": {
"jsCode": "// Get the price data from CoinGecko\nconst prices = $input.first().json;\nconst items = [];\n\n// Format each coin's price data for database insertion\nfor (const [coinId, data] of Object.entries(prices)) {\n items.push({\n json: {\n coin_id: coinId,\n price: data.usd,\n recorded_at: new Date().toISOString()\n }\n });\n}\n\nreturn items;"
},
"id": "32e4a9fc-1f56-4ecb-8f35-5e65085067d1",
"name": "Format Price Data",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-720,
500
]
},
{
"parameters": {
"tableId": "price_history",
"dataToSend": "autoMapInputData"
},
"id": "e1d50043-968b-456a-8cfb-8d2703eef36f",
"name": "Store Price History",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-500,
500
],
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "getAll",
"tableId": "tracked_coins",
"returnAll": true,
"filters": {
"conditions": [
{
"keyName": "is_active",
"condition": "eq",
"keyValue": true
}
]
}
},
"id": "5cd7cdf1-87bd-4dcb-a39c-0d0127bb150f",
"name": "Get Active Alerts",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-720,
700
],
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "// Get prices from CoinGecko node and alerts from Supabase\nconst prices = $('Get the price for all coins').first().json;\nconst alerts = $input.all();\nconst triggered = [];\n\nfor (const alert of alerts) {\n const alertData = alert.json;\n const coinId = alertData.coin_id;\n const currentPrice = prices[coinId]?.usd;\n \n // Skip if no price data available\n if (!currentPrice) continue;\n \n const targetPrice = parseFloat(alertData.target_price);\n const alertType = alertData.alert_type;\n \n // Check if alert condition is met\n let isTriggered = false;\n if (alertType === 'above' && currentPrice >= targetPrice) {\n isTriggered = true;\n } else if (alertType === 'below' && currentPrice <= targetPrice) {\n isTriggered = true;\n }\n \n if (isTriggered) {\n triggered.push({\n json: {\n ...alertData,\n current_price: currentPrice,\n usd_24h_change: prices[coinId]?.usd_24h_change || 0,\n triggered_at: new Date().toISOString()\n }\n });\n }\n}\n\nreturn triggered;"
},
"id": "fea1a81a-1512-455a-8f46-c375c92f8a52",
"name": "Check Alert Conditions",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-500,
700
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
},
"conditions": [
{
"leftValue": "={{ $items().length }}",
"rightValue": 0,
"operator": {
"type": "number",
"operation": "gt"
},
"id": "497ac717-070b-4bc7-a675-6a6e1c008ac9"
}
],
"combinator": "and"
},
"options": {}
},
"id": "348f18cf-cba0-45cd-8928-95bb91a702cb",
"name": "Any Alerts Triggered?",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
-280,
700
]
},
{
"parameters": {
"jsCode": "// Format triggered alerts into Telegram messages\nconst items = $input.all();\nconst messages = [];\n\nfor (const item of items) {\n const alert = item.json;\n \n // Create formatted message\n const changeText = alert.usd_24h_change ? \n `\ud83d\udcc8 24h Change: ${alert.usd_24h_change > 0 ? '+' : ''}${alert.usd_24h_change.toFixed(2)}%` : \n '';\n \n const message = `\ud83d\udea8 *CRYPTO ALERT TRIGGERED!*\\n\\n` +\n `\ud83d\udcb0 *${alert.symbol.toUpperCase()}* has reached *$${alert.current_price.toLocaleString()}*\\n` +\n `\ud83c\udfaf Your target: $${parseFloat(alert.target_price).toLocaleString()} (${alert.alert_type})\\n` +\n `${changeText}\\n\\n` +\n `\u23f0 ${new Date().toLocaleString()}\\n\\n` +\n `Would you like to set a new alert for ${alert.symbol.toUpperCase()}?`;\n \n messages.push({\n json: {\n telegram_id: alert.telegram_id,\n message: message,\n tracked_coin_id: alert.id,\n current_price: alert.current_price\n }\n });\n}\n\nreturn messages;"
},
"id": "3cd36ab1-b93c-44ce-baed-e3ea23fc9a26",
"name": "Format Alert Messages",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
0,
680
]
},
{
"parameters": {
"chatId": "={{ $json.telegram_id }}",
"text": "={{ $json.message }}",
"additionalFields": {
"appendAttribution": false,
"parse_mode": "Markdown"
}
},
"id": "447149df-2649-4918-8ec3-b896cdee3fbe",
"name": "Send Telegram Alert",
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
220,
680
],
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"tableId": "tracked_coins",
"filters": {
"conditions": [
{
"keyName": "id",
"condition": "eq",
"keyValue": "={{ $('Any Alerts Triggered?').item.json.id }}"
}
]
},
"fieldsUi": {
"fieldValues": [
{
"fieldId": "is_active",
"fieldValue": "false"
}
]
}
},
"id": "7dde704d-157a-4ab5-b738-81209b3e4d5e",
"name": "Deactivate Alert",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
0,
880
],
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"tableId": "alert_history",
"fieldsUi": {
"fieldValues": [
{
"fieldId": "tracked_coin_id",
"fieldValue": "={{ $('Any Alerts Triggered?').item.json.id }}"
},
{
"fieldId": "triggered_at",
"fieldValue": "={{ $(\"Any Alerts Triggered?\").item.json.triggered_at }}"
},
{
"fieldId": "price_at_trigger",
"fieldValue": "={{ $json.current_price }}"
}
]
}
},
"id": "52de4284-905d-4d16-8c98-70b51d1aa71b",
"name": "Log Alert History",
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
0,
480
],
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {
"temperature": 0.5,
"maxRetries": 2
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-720,
240
],
"id": "fceab2e8-4930-416f-8c8e-f34d106c82c0",
"name": "OpenAI Chat Model1",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $json.chat_id }}",
"tableName": "n8n_crypto_histories"
},
"type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
"typeVersion": 1.3,
"position": [
-600,
240
],
"id": "7c797043-c8e2-4e4c-a17d-eefd201286fc",
"name": "Postgres Chat Memory",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-1600,
960
],
"id": "89c92620-f24d-40bc-b227-ac7d94bf50d3",
"name": "When clicking \u2018Execute workflow\u2019"
},
{
"parameters": {
"operation": "getAll",
"tableId": "tracked_coins",
"returnAll": true
},
"type": "n8n-nodes-base.supabase",
"typeVersion": 1,
"position": [
-1380,
600
],
"id": "96bebfbb-e289-40ed-88cc-8d3f2e1154aa",
"name": "Get many rows",
"credentials": {
"supabaseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "// Extract unique coin IDs from tracked_coins\nconst items = $input.all();\nconst coinIds = [];\nconst seen = new Set();\n\n// Loop through all tracked coins and get unique coin_ids\nfor (const item of items) {\n const coinId = item.json.coin_id;\n if (coinId && !seen.has(coinId)) {\n coinIds.push(coinId);\n seen.add(coinId);\n }\n}\n\n// Return the array of coin IDs for CoinGecko\nreturn [{ json: { coin_ids: coinIds } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-1160,
600
],
"id": "3156c422-a142-484c-8dd0-853ad647bb15",
"name": "Extract Coin IDs for CoinGecko"
},
{
"parameters": {
"operation": "price",
"baseCurrencies": "={{ $json.coin_ids }}",
"quoteCurrencies": [
"usd"
],
"options": {
"include_24hr_change": true,
"include_24hr_vol": true,
"include_last_updated_at": true,
"include_market_cap": true
}
},
"type": "n8n-nodes-base.coinGecko",
"typeVersion": 1,
"position": [
-940,
600
],
"id": "4ef092c2-fbf9-4932-9b55-36208f761fa5",
"name": "Get the price for all coins"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "loose",
"version": 2
},
"conditions": [
{
"id": "94b898a7-6f88-4f4a-b42a-6598eb712c2e",
"leftValue": "={{ $items().length }}",
"rightValue": "=0",
"operator": {
"type": "number",
"operation": "gt"
}
}
],
"combinator": "or"
},
"looseTypeValidation": true,
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
-1200,
120
],
"id": "f374ea6c-dbdf-4a0f-89f6-82ce28810401",
"name": "Auth Check"
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "price_history",
"mode": "list",
"cachedResultName": "price_history"
},
"limit": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Limit', ``, 'number') }}",
"where": {
"values": [
{
"column": "coin_id",
"value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('values0_Value', ``, 'string') }}"
}
]
},
"sort": {
"values": [
{
"column": "recorded_at",
"direction": "={{ $fromAI('Direction', 'ASC or DESC', 'string') }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
-480,
240
],
"id": "5c8917b1-a030-48c6-a439-60cacf45278c",
"name": "Get Price History",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "deleteTable",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tracked_coins",
"mode": "list",
"cachedResultName": "tracked_coins"
},
"deleteCommand": "delete",
"where": {
"values": [
{
"column": "id",
"value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('values0_Value', ``, 'string') }}"
},
{
"column": "telegram_id",
"value": "={{ $('Prepare Message').item.json.chat_id }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
-360,
240
],
"id": "19631793-55e0-46f3-860b-5aac0424e8a2",
"name": "Remove Alert",
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"disabled": true
},
{
"parameters": {
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tracked_coins",
"mode": "list",
"cachedResultName": "tracked_coins"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"is_active": true,
"telegram_id": "={{ $('Prepare Message').item.json.chat_id }}",
"target_price": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('target_price', ``, 'number') }}",
"alert_type": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('alert_type', ``, 'string') }}",
"created_at": "={{ $now }}",
"symbol": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', ``, 'string') }}",
"coin_id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('coin_id', ``, 'string') }}"
},
"matchingColumns": [
"id"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "telegram_id",
"displayName": "telegram_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true
},
{
"id": "coin_id",
"displayName": "coin_id",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "symbol",
"displayName": "symbol",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "target_price",
"displayName": "target_price",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true
},
{
"id": "alert_type",
"displayName": "alert_type",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "is_active",
"displayName": "is_active",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true
},
{
"id": "created_at",
"displayName": "created_at",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
-240,
240
],
"id": "d16d3cdd-3020-4047-a9e2-aeb8d0263406",
"name": "Add Alert",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tracked_coins",
"mode": "list",
"cachedResultName": "tracked_coins"
},
"returnAll": "",
"where": {
"values": [
{
"column": "telegram_id",
"value": "={{ $('Prepare Message').item.json.chat_id }}"
}
]
},
"sort": {
"values": [
{
"column": "coin_id"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
-120,
240
],
"id": "fd151039-3fe1-4780-bc73-e5aeae4f45e6",
"name": "List All Alerts",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tracked_coins",
"mode": "list",
"cachedResultName": "tracked_coins"
},
"returnAll": true,
"where": {
"values": [
{
"column": "telegram_id",
"value": "={{ $('Prepare Message').item.json.chat_id }}"
},
{
"column": "coin_id",
"value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('values1_Value', ``, 'string') }}"
}
]
},
"sort": {
"values": [
{
"column": "target_price",
"direction": "DESC"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
0,
240
],
"id": "a91f071b-bc36-48de-af58-cc6da3db17b6",
"name": "List Alerts For Coin",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "users",
"mode": "list",
"cachedResultName": "users"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"telegram_id": "={{ $json.telegram_id }}",
"username": "={{ $json.username }}",
"created_at": "={{ $now }}"
},
"matchingColumns": [],
"schema": [
{
"id": "telegram_id",
"displayName": "telegram_id",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true
},
{
"id": "username",
"displayName": "username",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "created_at",
"displayName": "created_at",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-1180,
960
],
"id": "bc24692f-7443-485e-b78b-5b1afa330644",
"name": "Insert rows in a table",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"schema": {
"__rl": true,
"value": "public",
"mode": "list",
"cachedResultName": "public"
},
"table": {
"__rl": true,
"value": "tracked_coins",
"mode": "list",
"cachedResultName": "tracked_coins"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"is_active": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('is_active', ``, 'boolean') }}",
"telegram_id": "={{ $('Prepare Message').item.json.chat_id }}",
"target_price": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('target_price', ``, 'number') }}",
"alert_type": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('alert_type', ``, 'string') }}",
"symbol": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('symbol', ``, 'string') }}",
"coin_id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('coin_id', ``, 'string') }}",
"id": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('id__using_to_match_', ``, 'number') }}"
},
"matchingColumns": [
"id",
"telegram_id"
],
"schema": [
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "telegram_id",
"displayName": "telegram_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "coin_id",
"displayName": "coin_id",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "symbol",
"displayName": "symbol",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "target_price",
"displayName": "target_price",
"required": true,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true
},
{
"id": "alert_type",
"displayName": "alert_type",
"required": true,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "is_active",
"displayName": "is_active",
"required": false,
"defaultMatch": false,
"display": true,
"type": "boolean",
"canBeUsedToMatch": true
},
{
"id": "created_at",
"displayName": "created_at",
"required": false,
"defaultMatch": false,
"display": true,
"type": "dateTime",
"canBeUsedToMatch": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgresTool",
"typeVersion": 2.6,
"position": [
120,
240
],
"id": "b1bf6aaf-99e2-4f31-82a6-1f36a727d189",
"name": "Update alert",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"content": "## Add Users\n\nSpecify telegram id and username.\n",
"height": 200,
"width": 320
},
"id": "d2d711d8-fc97-46e4-af1b-a16981f4df43",
"name": "AI Agent Overview1",
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-2120,
900
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "dfc4c89a-27a2-446e-9ab2-34c1ae9d3b8d",
"name": "telegram_id",
"value": "={{ $env.Telegram_Chat_ID }}",
"type": "string"
},
{
"id": "22384386-a6c6-4def-92f7-8ceef79f1ccd",
"name": "username",
"value": "Daniel",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-1380,
960
],
"id": "33d47b77-4f66-4221-9949-8b4bbf74cdd2",
"name": "Set Telegram_ID and Username"
},
{
"parameters": {
"operation": "select",
"schema": {
"__rl": true,
"mode": "list",
"value": "public"
},
"table": {
"__rl": true,
"value": "users",
"mode": "list",
"cachedResultName": "users"
},
"returnAll": true,
"where": {
"values": [
{
"column": "telegram_id",
"value": "={{ $json.message.from.id }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
-1400,
120
],
"id": "b9577d42-62d7-4a57-a778-4504ed06118a",
"name": "Get Authenticated users",
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
}
],
"connections": {
"Telegram Messages": {
"main": [
[
{
"node": "Get Authenticated users",
"type": "main",
"index": 0
}
]
]
},
"Prepare Message": {
"main": [
[
{
"node": "Crypto AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Crypto AI Agent": {
"main": [
[
{
"node": "Send AI Response",
"type": "main",
"index": 0
}
]
]
},
"Every 5 Minutes": {
"main": [
[
{
"node": "Get many rows",
"type": "main",
"index": 0
}
]
]
},
"Format Price Data": {
"main": [
[
{
"node": "Store Price History",
"type": "main",
"index": 0
}
]
]
},
"Get Active Alerts": {
"main": [
[
{
"node": "Check Alert Conditions",
"type": "main",
"index": 0
}
]
]
},
"Check Alert Conditions": {
"main": [
[
{
"node": "Any Alerts Triggered?",
"type": "main",
"index": 0
}
]
]
},
"Any Alerts Triggered?": {
"main": [
[
{
"node": "Log Alert History",
"type": "main",
"index": 0
},
{
"node": "Deactivate Alert",
"type": "main",
"index": 0
},
{
"node": "Format Alert Messages",
"type": "main",
"index": 0
}
]
]
},
"Format Alert Messages": {
"main": [
[
{
"node": "Send Telegram Alert",
"type": "main",
"index": 0
}
]
]
},
"Send Telegram Alert": {
"main": [
[]
]
},
"Deactivate Alert": {
"main": [
[]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Crypto AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Postgres Chat Memory": {
"ai_memory": [
[
{
"node": "Crypto AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Log Alert History": {
"main": [
[]
]
},
"When clicking \u2018Execute workflow\u2019": {
"main": [
[
{
"node": "Set Telegram_ID and Username",
"type": "main",
"index": 0
}
]
]
},
"Get many rows": {
"main": [
[
{
"node": "Extract Coin IDs for CoinGecko",
"type": "main",
"index": 0
}
]
]
},
"Extract Coin IDs for CoinGecko": {
"main": [
[
{
"node": "Get the price for all coins",
"type": "main",
"index": 0
}
]
]
},
"Get the price for all coins": {
"main": [
[
{
"node": "Format Price Data",
"type": "main",
"index": 0
},
{
"node": "Get Active Alerts",
"type": "main",
"index": 0
}
]
]
},
"Auth Check": {
"main": [
[
{
"node": "Prepare Message",
"type": "main",
"index": 0
}
],
[
{
"node": "Unauthorized Reply",
"type": "main",
"index": 0
}
]
]
},
"Get Price History": {
"ai_tool": [
[
{
"node": "Crypto AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Remove Alert": {
"ai_tool": [
[
{
"node": "Crypto AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Add Alert": {
"ai_tool": [
[
{
"node": "Crypto AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"List All Alerts": {
"ai_tool": [
[
{
"node": "Crypto AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"List Alerts For Coin": {
"ai_tool": [
[
{
"node": "Crypto AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Update alert": {
"ai_tool": [
[
{
"node": "Crypto AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Set Telegram_ID and Username": {
"main": [
[
{
"node": "Insert rows in a table",
"type": "main",
"index": 0
}
]
]
},
"Get Authenticated users": {
"main": [
[
{
"node": "Auth Check",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"callerPolicy": "workflowsFromSameOwner",
"errorWorkflow": "hvVgg2yevFI1IKok"
},
"versionId": "23ecb9c9-d82a-4f36-8906-20d3f57976f7",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "m1UYftjvbkRkrmuu",
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
openAiApipostgressupabaseApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Get notification each time cryptoreaches X. Uses telegramTrigger, telegram, agent, supabase. Event-driven trigger; 34 nodes.
Source: https://gist.github.com/DaSheThe1/bdbccdb0ad77add4560f2314580c9cc1 — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Bitlab-Chatbot. Uses telegramTrigger, telegram, snowflake, httpRequest. Event-driven trigger; 87 nodes.
This intelligent lead generation workflow transforms voice commands or text input into verified prospect lists through automated Apollo.io scraping. The system processes natural language requests, ext
SPRINT3_WORKFLOW. Uses agent, telegramTrigger, telegram, postgres. Event-driven trigger; 26 nodes.
Telegram Chat with Buffering. Uses stickyNote, telegram, telegramTrigger, supabase. Event-driven trigger; 22 nodes.
When creating chatbots that interface through applications such as Telegram and WhatsApp, users can often sends multiple shorter messages in quick succession, in place of a single, longer message. Thi