This workflow follows the Google Sheets → HTTP Request 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": "Weather Bot - Main Handler",
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"type": "n8n-nodes-base.telegramTrigger",
"typeVersion": 1.2,
"position": [
-700,
40
],
"id": "e2fe9952-878f-4184-a7ae-0d5fc493d4d8",
"name": "Telegram Trigger",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "// Extract command and user info\nconst message = $input.first().json;\nconst userId = message.message.from.id;\nconst username = message.message.from.username || '';\nconst firstName = message.message.from.first_name || '';\nconst chatId = message.message.chat.id;\nconst text = message.message.text || '';\n\n// Parse command\nlet command = '';\nlet parameter = '';\n\nif (text.startsWith('/')) {\n const parts = text.split(' ');\n command = parts[0].toLowerCase();\n parameter = parts.slice(1).join(' ');\n}\n\nreturn [{\n json: {\n userId,\n username,\n firstName,\n chatId,\n command,\n parameter,\n originalMessage: text\n }\n}]; // <-- NO semicolon here"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-400,
40
],
"id": "ac0f02a4-d82c-4f83-8c52-d994554d06a1",
"name": "Parse Command"
},
{
"parameters": {
"authentication": "serviceAccount",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"filtersUI": {
"values": [
{
"lookupColumn": "user_id",
"lookupValue": "={{$json.userId}}"
}
]
},
"options": {
"returnFirstMatch": true
}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
340,
-1260
],
"id": "31a4eeca-5897-4a12-97ec-bdd457cb6b67",
"name": "Check User Exists",
"alwaysOutputData": true,
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "60b96854-4ad3-4d3f-a3a2-f2e25740af0e",
"leftValue": "={{$json.user_id}}",
"rightValue": "empty",
"operator": {
"type": "number",
"operation": "empty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
560,
-1260
],
"id": "ce21af28-ece9-45fd-bb99-6100c1351237",
"name": "New User Check"
},
{
"parameters": {
"authentication": "serviceAccount",
"operation": "append",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"user_id": "={{ $('Parse Command').item.json.userId }}",
"username": "={{ $('Parse Command').item.json.username }}",
"first_name": "={{ $('Parse Command').item.json.firstName }}",
"lat": "\"\"",
"lon": "\"\"",
"subscribed": "false",
"last_active": "={{$now}}",
"timezone": "\"\"",
"location": "\"\""
},
"matchingColumns": [],
"schema": [
{
"id": "user_id",
"displayName": "user_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "username",
"displayName": "username",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "first_name",
"displayName": "first_name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "location",
"displayName": "location",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lat",
"displayName": "lat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lon",
"displayName": "lon",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "subscribed",
"displayName": "subscribed",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "timezone",
"displayName": "timezone",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "last_active",
"displayName": "last_active",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
800,
-1360
],
"id": "f37d247a-2e9e-4ece-bacc-b664c90db808",
"name": "Add New User ",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const parameter = $json.parameter;\nconst userId = $json.userId;\nconst chatId = $json.chatId;\n\nif (!parameter || parameter.trim() === '') {\n return [{\n json: {\n error: true,\n chatId: chatId,\n message: \"Please provide a location. Example: /location London\"\n }\n }];\n}\n\nreturn [{\n json: {\n userId: userId,\n chatId: chatId,\n location: parameter.trim(),\n error: false\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
540,
20
],
"id": "1371dae8-d92d-4278-891e-411af9610656",
"name": "Validate Location Input"
},
{
"parameters": {
"jsCode": "const firstName = $json.first_name || 'there';\nconst message = `\ud83c\udf24\ufe0f Welcome to Weather Alert Bot, ${firstName}!\n\nTo get started, please set your location using:\n/location [Your City Name]\n\nExample: /location Errachidia\n\nAvailable commands:\n\ud83c\udf21\ufe0f /weather - Current weather\n\ud83d\udcc5 /forecast - 3-day forecast \n\ud83d\udccd /location - Set location\n\ud83d\udd14 /subscribe - Daily updates\n\ud83d\udd15 /unsubscribe - Stop updates\n\u26a0\ufe0f /alerts - Weather warnings\n\u2753 /help - Show this help\n\nLet's get your weather updates started! \ud83c\udf08`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1000,
-1360
],
"id": "897fbf49-1216-49d1-8366-35b37a7b3c54",
"name": "Prepare Welcome Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1200,
-1360
],
"id": "131bc079-833e-439d-8e7e-b48242ac1ced",
"name": "Send Welcome Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const firstName = $json.first_name || 'there';\nconst message = `\ud83c\udf24\ufe0f Welcome to Weather Alert Bot, ${firstName}!\n\nBot Is Already Strated\n\nAvailable commands:\n\ud83c\udf21\ufe0f /weather - Current weather\n\ud83d\udcc5 /forecast - 3-day forecast \n\ud83d\udccd /location - Set location\n\ud83d\udd14 /subscribe - Daily updates\n\ud83d\udd15 /unsubscribe - Stop updates\n\u26a0\ufe0f /alerts - Weather warnings\n\u2753 /help - Show this help\n\nLet's get your weather updates started! \ud83c\udf08`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
780,
-1160
],
"id": "8d134b96-271a-4e2c-a45d-f2c2118ad967",
"name": "Prepare Exist Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
980,
-1160
],
"id": "03fb4395-6a94-431e-a060-a7057f3d5f7e",
"name": "Send Exist Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const location = $input.first().json;\n\nconst userId = $('Validate Location Input').first().json.userId;\nconst chatId = $('Validate Location Input').first().json.chatId;\nconst locationInput = $('Validate Location Input').first().json.location;\n\nif (!location || !location.name) {\n return [{\n json: {\n error: true,\n chatId: chatId,\n message: `\u274c Could not find location \"${locationInput}\". Please try again with a different city name.`\n }\n }];\n}\n\nreturn [{\n json: {\n userId: userId,\n chatId: chatId,\n locationName: `${location.name}, ${location.country}`,\n lat: location.lat,\n lon: location.lon,\n error: false\n }\n}];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
980,
20
],
"id": "c34daad6-fb38-4433-a671-0071fa750d8a",
"name": "Process Geocoding Response"
},
{
"parameters": {
"authentication": "serviceAccount",
"operation": "update",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"user_id": "={{ $json.userId }}",
"location": "={{ $json.locationName }}",
"lat": "={{ $json.lat }}",
"lon": "={{ $json.lon }}",
"last_active": "={{$now}}"
},
"matchingColumns": [
"user_id"
],
"schema": [
{
"id": "user_id",
"displayName": "user_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "username",
"displayName": "username",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "first_name",
"displayName": "first_name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "location",
"displayName": "location",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lat",
"displayName": "lat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lon",
"displayName": "lon",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "subscribed",
"displayName": "subscribed",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "timezone",
"displayName": "timezone",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "last_active",
"displayName": "last_active",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
1200,
20
],
"id": "5bbaf477-f90e-4ba5-8d39-6f4ed2952931",
"name": "Update User Location",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const locationName = $input.first().json.location;\nconst message = `\ud83d\udccd Location set to: ${locationName}\n\nNow you can use:\n\ud83c\udf21\ufe0f /weather - Get current weather\n\ud83d\udcc5 /forecast - Get 3-day forecast\n\ud83d\udd14 /subscribe - Enable daily weather updates`;\n\nreturn [{\n json: {\n chatId: $('Process Geocoding Response').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1420,
20
],
"id": "3d8cd542-da91-4157-a0ba-3166f4c79562",
"name": "Prepare Confirm Location Set Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1640,
20
],
"id": "b05adaa6-148d-4ccb-aa8d-df1cfcae6d68",
"name": "Send Confirm Location Set Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"authentication": "serviceAccount",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"filtersUI": {
"values": [
{
"lookupColumn": "user_id",
"lookupValue": "={{$json.userId}}"
}
]
},
"options": {
"returnFirstMatch": false
}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
620,
-840
],
"id": "fbe639ea-3b8d-4aba-8693-56e0965fd22d",
"name": "Get User Location",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const weather = $input.first().json;\nconst userLocation = $('Check Location (Weather)').first().json.location;\n\n// Weather icon mapping\nconst iconMap = {\n '01d': '\u2600\ufe0f', '01n': '\ud83c\udf19', '02d': '\u26c5', '02n': '\u2601\ufe0f',\n '03d': '\u2601\ufe0f', '03n': '\u2601\ufe0f', '04d': '\u2601\ufe0f', '04n': '\u2601\ufe0f',\n '09d': '\ud83c\udf27\ufe0f', '09n': '\ud83c\udf27\ufe0f', '10d': '\ud83c\udf26\ufe0f', '10n': '\ud83c\udf27\ufe0f',\n '11d': '\u26c8\ufe0f', '11n': '\u26c8\ufe0f', '13d': '\u2744\ufe0f', '13n': '\u2744\ufe0f',\n '50d': '\ud83c\udf2b\ufe0f', '50n': '\ud83c\udf2b\ufe0f'\n};\n\nconst icon = iconMap[weather.weather[0].icon] || '\ud83c\udf24\ufe0f';\nconst temp = Math.round(weather.main.temp);\nconst feelsLike = Math.round(weather.main.feels_like);\nconst description = weather.weather[0].description;\nconst humidity = weather.main.humidity;\nconst windSpeed = Math.round(weather.wind.speed * 3.6); // Convert m/s to km/h\nconst pressure = weather.main.pressure;\n\n// Generate recommendations\nlet recommendations = '\\n\ud83d\udccb Recommendations:\\n';\nif (temp < 5) recommendations += '\ud83e\udde5 Wear a warm coat\\n';\nif (temp > 25) recommendations += '\ud83d\udc55 Light clothing recommended\\n';\nif (humidity > 80) recommendations += '\ud83d\udca7 High humidity - stay hydrated\\n';\nif (windSpeed > 20) recommendations += '\ud83d\udca8 Windy conditions - secure loose items\\n';\n\nconst message = `${icon} Current Weather in ${userLocation}\n\n\ud83c\udf21\ufe0f Temperature: ${temp}\u00b0C (feels like ${feelsLike}\u00b0C)\n\ud83d\udcdd Condition: ${description}\n\ud83d\udca7 Humidity: ${humidity}%\n\ud83d\udca8 Wind Speed: ${windSpeed} km/h\n\ud83d\udcca Pressure: ${pressure} hPa${recommendations}\n\nUpdated: ${new Date().toLocaleString()}`;\n\nreturn [{\n json: {\n chatId: $('Route Commands').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1300,
-940
],
"id": "ed1d922b-6d6e-42cf-b587-389757f90155",
"name": "Format Weather Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1520,
-940
],
"id": "81412cd9-57b7-4b15-9cf7-c5727e7b07aa",
"name": "Send Weather Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const message = `Please Provide a Valide Location Name.\nUse Command : /Location [city's name]\n\nUpdated: ${new Date().toLocaleString()}`;\n\nreturn [{\n json: {\n chatId: $('Route Commands').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1120,
-760
],
"id": "eddd554d-f7cc-4a2d-bd8f-bced3d5d6546",
"name": "Format Reset Location Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1340,
-760
],
"id": "39653fcc-3cdb-4c0a-a7c5-9bea08a530ed",
"name": "Send Reset Location Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "ce3cfb40-6a71-4f1c-9b58-5d9b9ae9d8ed",
"leftValue": "={{ $json.location }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1060,
-440
],
"id": "b7cae76e-2b84-4e2d-b21d-e1a2d0ea3d92",
"name": "Check Location Set",
"alwaysOutputData": true
},
{
"parameters": {
"jsCode": "const firstName = $json.first_name || 'there';\nconst message = `${firstName}, Please Choose a Location First!\n\nTo get started, please set your location using:\n/location [Your City Name]\n\nExample: /location Errachidia`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1440,
-280
],
"id": "0c1ccd36-6f98-40e0-8f8a-ddb273a41655",
"name": "Prepare Location Reminder Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1640,
-280
],
"id": "a92f843d-b3b5-47f7-b000-a983a79b799a",
"name": "Send Location Reminder Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"url": "https://api.openweathermap.org/data/2.5/forecast",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "lat",
"value": "={{ $json.lat }}"
},
{
"name": "lon",
"value": "={{ $json.lon }}"
},
{
"name": "appid",
"value": "[your weather API]"
},
{
"name": "units",
"value": "metric"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1580,
-540
],
"id": "119bd2bf-c3d3-4633-9c21-13e7453ec013",
"name": "5-Day Forecast"
},
{
"parameters": {
"authentication": "serviceAccount",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"filtersUI": {
"values": [
{
"lookupColumn": "user_id",
"lookupValue": "={{$json.userId}}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
860,
300
],
"id": "7011f4d9-ece4-459b-9dcc-381092f64ef8",
"name": "Get User Data (Subscribe)",
"alwaysOutputData": true,
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const firstName = $json.first_name || 'there';\nconst message = `Hi ${firstName}, \nYou are Already Subscribed!`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2160,
540
],
"id": "a106bf51-fc04-4418-ac0b-09a77ebe6f98",
"name": "Prepare Subscribed Reminder Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2360,
540
],
"id": "8dbf0289-c2cf-4122-8550-0789028afb68",
"name": "Send Subscribed Reminder Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const message = `\ud83d\udccd Please set your location first before subscribing:\n/location [Your City Name]\n\nExample: /location Paris\n\nOnce your location is set, use /subscribe again to enable daily updates.`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2360,
340
],
"id": "48d6aac2-33dd-47e8-878a-57952a6c87a9",
"name": "Prepare Location Set Message"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c9ce7826-b7e3-486d-9f68-232d0b3e245e",
"leftValue": "={{ $json.location }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
2060,
200
],
"id": "04884ff3-4195-4036-b198-478c8d0cedc1",
"name": "Check Location"
},
{
"parameters": {
"jsCode": "const location = $json.location || 'your location';\nconst message = `\ud83d\udd14 Daily weather updates enabled!\n\nYou'll receive weather updates for ${location} every morning at 7:00 AM.\n\nYou can:\n- Use /unsubscribe to stop daily updates\n- Use /location to change your location\n- Use /weather for current conditions\n\nStay informed! \ud83c\udf24\ufe0f`;\n\nreturn [{\n json: {\n chatId: $json.user_id,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2460,
180
],
"id": "e6d992bd-316d-4245-b923-ac53bd1e169c",
"name": "Prepare Subscribe Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2680,
180
],
"id": "82383e6e-752c-489f-8a74-ff9190f78d75",
"name": "Send Subscribe Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const forecast = $input.first().json;\nconst userLocation = $('Check Location Set').first().json.location;\n\n// Weather icon mapping\nconst iconMap = {\n '01d': '\u2600\ufe0f', '01n': '\ud83c\udf19', '02d': '\u26c5', '02n': '\u2601\ufe0f',\n '03d': '\u2601\ufe0f', '03n': '\u2601\ufe0f', '04d': '\u2601\ufe0f', '04n': '\u2601\ufe0f',\n '09d': '\ud83c\udf27\ufe0f', '09n': '\ud83c\udf27\ufe0f', '10d': '\ud83c\udf26\ufe0f', '10n': '\ud83c\udf27\ufe0f',\n '11d': '\u26c8\ufe0f', '11n': '\u26c8\ufe0f', '13d': '\u2744\ufe0f', '13n': '\u2744\ufe0f',\n '50d': '\ud83c\udf2b\ufe0f', '50n': '\ud83c\udf2b\ufe0f'\n};\n\n// Get 3-day forecast (next 3 days at noon)\nconst dailyForecasts = [];\nconst processedDates = new Set();\n\nfor (let item of forecast.list) {\n const date = new Date(item.dt * 1000);\n const dateStr = date.toDateString();\n const hour = date.getHours();\n \n // Get forecast around noon (12 PM) for each day\n if (hour >= 11 && hour <= 13 && !processedDates.has(dateStr) && dailyForecasts.length < 3) {\n const dayName = date.toLocaleDateString('en-US', { weekday: 'short' });\n const icon = iconMap[item.weather[0].icon] || '\ud83c\udf24\ufe0f';\n const temp = Math.round(item.main.temp);\n const description = item.weather[0].description;\n const rainProb = Math.round((item.pop || 0) * 100);\n \n dailyForecasts.push(`${dayName}: ${icon} ${temp}\u00b0C - ${description} (${rainProb}% rain)`);\n processedDates.add(dateStr);\n }\n}\n\nconst message = `\ud83d\udcc5 3-Day Forecast for ${userLocation}\n\n${dailyForecasts.join('\\n')}\n\n\ud83d\udca1 Tip: Use /weather for current conditions or /subscribe for daily updates!`;\n\nreturn [{\n json: {\n chatId: $('Check Location Set').first().json.user_id,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1800,
-540
],
"id": "82395b72-8ac9-4b43-9384-386a7c65bc14",
"name": "Format Forecast Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2020,
-540
],
"id": "1f652004-43d6-4c5c-88a8-8721ec55a8ac",
"name": "Send Forecast Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c2e73647-332e-442d-a616-c41ad1568a8f",
"leftValue": "={{ $json.user_id }}",
"rightValue": "",
"operator": {
"type": "number",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1080,
300
],
"id": "cf7284b2-86ed-4c64-b09d-04e3a34eb051",
"name": "Check User Existence"
},
{
"parameters": {
"authentication": "serviceAccount",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"filtersUI": {
"values": [
{
"lookupColumn": "user_id",
"lookupValue": "={{$json.userId}}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
1180,
880
],
"id": "8d3e5f73-2312-4968-b9e2-598423aaf996",
"name": "Get User Data (Unsubscribe)",
"alwaysOutputData": true,
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "c2e73647-332e-442d-a616-c41ad1568a8f",
"leftValue": "={{ $json.user_id }}",
"rightValue": "",
"operator": {
"type": "number",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1400,
880
],
"id": "3c148468-57af-4ba5-9e11-5b5f0e7ae5d3",
"name": "Check User Existence (Unsubscribe)"
},
{
"parameters": {
"jsCode": "const message = `\ud83e\udd16 You're not registered yet. Send /start to begin using the bot!`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.userId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1660,
1060
],
"id": "44f5c2d8-b73e-4011-8904-c3e18e2825db",
"name": "User Not Found (Unsubscribe)"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1900,
1060
],
"id": "4c67bb39-4dac-4f57-97c6-3b2fd6da660b",
"name": "Send Message : User Not Found (Unsubscribe)",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const message = `\ud83e\udd16 Please start the bot first by sending /start\n\nThen set your location and subscribe to daily updates!`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.userId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1340,
480
],
"id": "890d8b80-5f94-4690-89a1-3b0d66830a23",
"name": "User Not Found (Subscribe)"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1560,
480
],
"id": "cd3edc6f-091b-4a2e-950b-36ec67e1c447",
"name": "Send Message : User Not Found (Subscribe)",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "33770c28-7869-4404-9cf3-ddf4dd44cd3b",
"leftValue": "={{ $json.subscribed }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
2180,
880
],
"id": "c83f1ddf-6c68-44c1-9dc5-838eb033fd54",
"name": "Check Unsubscribe Status"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "33770c28-7869-4404-9cf3-ddf4dd44cd3b",
"leftValue": "={{ $json.subscribed }}",
"rightValue": "",
"operator": {
"type": "boolean",
"operation": "false",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1840,
300
],
"id": "2ede8149-941a-493b-b887-8bbb6e4e389c",
"name": "Check Subscribe Status"
},
{
"parameters": {
"jsCode": "const firstName = $json.first_name || 'there';\nconst message = `Hi ${firstName}, \nYou are Already Not Subscribed!`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2500,
1120
],
"id": "fc05ce0f-7161-4dff-90a2-a92c10ca705d",
"name": "Prepare Unsubscribed Reminder Message"
},
{
"parameters": {
"authentication": "serviceAccount",
"operation": "update",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"user_id": "={{ $json.user_id }}",
"subscribed": "false",
"last_active": "={{$now}}"
},
"matchingColumns": [
"user_id"
],
"schema": [
{
"id": "user_id",
"displayName": "user_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "username",
"displayName": "username",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "first_name",
"displayName": "first_name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "location",
"displayName": "location",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lat",
"displayName": "lat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lon",
"displayName": "lon",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "subscribed",
"displayName": "subscribed",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "timezone",
"displayName": "timezone",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "last_active",
"displayName": "last_active",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
2720,
720
],
"id": "9f97e62e-1c69-4a8c-9b82-cf73ede35906",
"name": "Change Unsubscribe Status",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"authentication": "serviceAccount",
"operation": "update",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"user_id": "={{ $json.user_id }}",
"subscribed": "true",
"last_active": "={{$now}}"
},
"matchingColumns": [
"user_id"
],
"schema": [
{
"id": "user_id",
"displayName": "user_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "username",
"displayName": "username",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "first_name",
"displayName": "first_name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "location",
"displayName": "location",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lat",
"displayName": "lat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "lon",
"displayName": "lon",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "subscribed",
"displayName": "subscribed",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "timezone",
"displayName": "timezone",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "last_active",
"displayName": "last_active",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
2460,
0
],
"id": "f6e8ed2f-5604-4780-936f-9e0f21c93244",
"name": "Change Subscribe Status",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2540,
340
],
"id": "8af3898f-3d8f-47b6-9b99-bbb73df5fd10",
"name": "Send Location Set Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const message = `\ud83d\udd15 Daily weather updates disabled.\n\nYou won't receive automatic morning weather updates anymore.\n\nYou can still:\n- Use /weather for current conditions\n- Use /forecast for 3-day forecast\n- Use /subscribe to re-enable daily updates\n\nThank you for using Weather Alert Bot! \ud83c\udf24\ufe0f`;\n\nreturn [{\n json: {\n chatId: $json.user_id,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2600,
940
],
"id": "4991d81e-d8ae-4c75-b3e8-c0fa8831e2ff",
"name": "Prepare Unsubscribe Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2820,
940
],
"id": "84d3b1b5-f0c4-44cf-b375-4652119c1f01",
"name": "Send Unsubscribe Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2700,
1120
],
"id": "3ae7594a-1ff7-46d6-ac16-8c44419a8104",
"name": "Send Unsubscribed Reminder Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const firstName = $json.firstName || 'there';\nconst message = `\ud83c\udf24\ufe0f Weather Alert Bot Help\n\nHi ${firstName}! Here are all available commands:\n\n\ud83d\ude80 **Getting Started:**\n/start - Start the bot and register\n/location [city] - Set your location\n\n\ud83c\udf21\ufe0f **Weather Info:**\n/weather - Current weather conditions\n/forecast - 3-day weather forecast\n/alerts - Active weather warnings\n\n\ud83d\udd14 **Daily Updates:**\n/subscribe - Enable daily morning updates\n/unsubscribe - Disable daily updates\n\n\u2753 **Support:**\n/help - Show this help message\n\n\ud83d\udccd **Example Usage:**\n/location Errachidia\n/weather\n/forecast\n/subscribe\n\n\ud83d\udca1 **Tips:**\n- Set your location first before using weather commands\n- Daily updates are sent at 7:00 AM\n- You'll get severe weather alerts automatically\n- Weather data updates every 30 minutes\n\nEnjoy your weather updates! \ud83c\udf08`;\n\nreturn [{\n json: {\n chatId: $json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
980,
1940
],
"id": "e6475066-5e1d-4907-8058-3bbd94a95def",
"name": "Prepare Help Message"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
1200,
1940
],
"id": "d63c750b-6cf2-40d1-8a22-c94176e21d43",
"name": "Send Help Message",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"authentication": "serviceAccount",
"documentId": {
"__rl": true,
"value": "1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Users",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1TI7vysDQJULYNJmFvJtpTBBnUQV50HKs75a3bI91ZVo/edit#gid=0"
},
"filtersUI": {
"values": [
{
"lookupColumn": "user_id",
"lookupValue": "={{ $json.userId }}"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.6,
"position": [
1320,
1580
],
"id": "9fc6e280-7b1b-48af-b313-134a03b925b1",
"name": "Get User Location (Alerts)",
"credentials": {
"googleApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "1e6e7c53-89ca-47c7-b9f2-63ddca67b6d8",
"leftValue": "={{ $json.user_id }}",
"rightValue": "",
"operator": {
"type": "number",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1580,
1580
],
"id": "06812762-6c00-4928-96dd-6946bd8db1b1",
"name": "User Existence (Alerts)"
},
{
"parameters": {
"jsCode": "const message = `\ud83e\udd16 You're not registered yet. Send /start to begin using the bot!`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.userId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1800,
1740
],
"id": "464c67aa-edbc-45a8-a319-43b5aacd3498",
"name": "User Not Found (Alerts)"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2040,
1740
],
"id": "04024d81-77a7-4510-9d65-a66f3b107f5c",
"name": "Send Message : User Not Found (Alerts)",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "b5b01b94-6535-4590-9641-81d77e3f70d7",
"leftValue": "={{ $json.location }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1800,
1480
],
"id": "acb609c7-7873-46e2-a6eb-1da7faacb40e",
"name": "Check Location Set (Alerts)"
},
{
"parameters": {
"jsCode": "const message = `\ud83d\udccd Please set your location first to check weather alerts:\n/location [Your City Name]\n\nExample: /location Marrakech\n\nAfter setting your location, use /alerts to check for weather warnings.`;\n\nreturn [{\n json: {\n chatId: $('Parse Command').first().json.chatId,\n message: message\n }\n}];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
2180,
1560
],
"id": "d04cac7a-3476-40b1-ae6d-26f80d5fb597",
"name": "Prepare Location Set Message (Alerts)"
},
{
"parameters": {
"chatId": "={{ $json.chatId }}",
"text": "={{ $json.message }}",
"additionalFields": {}
},
"type": "n8n-nodes-base.telegram",
"typeVersion": 1.2,
"position": [
2360,
1560
],
"id": "d9fc22ab-7ec2-4b66-b20f-8493419f3d4f",
"name": "Send Location Set Message (Alerts)",
"credentials": {
"telegramApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"url": "https://api.openweathermap.org/data/2.5/weather",
"sendQuery": true,
"queryParameters": {
"parameters": [
{
"name": "lat",
"value": "={{ $json.lat }}"
},
{
"name": "lon",
"value": "={{ $json.lon }}"
},
{
"name": "appid",
"value": "[your weather API]"
},
{
"name": "units",
"value": "metric"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
2120,
1340
],
"id": "18c50bdf-e349-4e16-bfee-10c0c77fad8d",
"name": "Current Weather for Alerts"
},
{
"parameters": {
"jsCode": "const weather = $input.first().json;\nconst location = $('Check Location Set (Alerts)').first().json.location;\nconst temp = weather.main.temp;\nconst windSpeed = weather.wind.speed * 3.6; // m/s to km/h\nconst condition = weather.weather[0].main;\nconst humidity = weather.main.humidity;\nconst visibility = weather.visibility / 1000; // meters to km\n\nlet activeAlerts = [];\nlet advisories = [];\n\n// Critical alerts (immediate attention needed)\nif (temp < -10) {\n activeAlerts.push('\ud83e\udd76 **EXTREME COLD WARNING**: Temperature below -10\u00b0C - Risk of frostbite');\n}\nif (temp > 40) {\n activeAlerts.push('\ud83d\udd25 **EXTREME HEAT WARNING**: Temperature above 40\u00b0C - Heat stroke risk');\n}\nif (windSpeed > 70) {\n activeAlerts.push('\ud83d\udca8 **SEVERE WIND WARNING**: Wind speed above 70 km/h - Dangerous conditions');\n}\nif (condition === 'Thunderstorm') {\n activeAlerts.push('\u26c8\ufe0f **THUNDERSTORM ALERT**: Seek shelter immediately');\n}\n\n// Weather advisories (caution recommended)\nif (temp < 0 && temp >= -10) {\n advisories.push('\u2744\ufe0f Freezing conditions - Ice possible on roads');\n}\nif (temp > 35 && temp <= 40) {\n advisories.push('\ud83c\udf21\ufe0f Very hot - Stay hydrated and avoid prolonged sun exposure');\n}\nif (windSpeed > 40 && windSpeed <= 70) {\n advisories.push('\ud83d\udca8 Strong winds - Secure loose objects');\n}\nif (humidity > 90) {\n advisories.push('\ud83d\udca7 Very high humidity - Uncomfortable conditions');\n}\nif (visibility < 1) {\n advisories.push('\ud83c\udf2b\ufe0f Poor visibility - Drive carefully');\n}\nif (condition === 'Snow') {\n advisories.push('\u2744\ufe0f Snow conditions - Reduced visibility and slippery roads');\n}\nif (condition === 'Rain' && weather.rain && weather.rain['1h'] > 10) {\n advisories.push('\ud83c\udf27\ufe0f Heavy rain - Possible flooding in low areas');\n}\n\nlet message = `\u26a0\ufe0f Weather Alerts for ${location}\\n\\n`;\n\nif (activeAlerts.length > 0) {\n message += `\ud83d\udea8 **ACTIVE ALERTS:**\\n${activeAlerts.join('\\n')}\\n\\n`;\n}\n\nif (advisories.length > 0) {\n message += `\u26a1 **ADVISORIES:**\\n${advisories.join('\\n')}\\n\\n`;\n}\n\nif (activeAlerts.length === 0 && advisories.length === 0) {\n message += `\u2705 No active weather alerts for your area.\\n\\n`;\n message += `Current conditions are normal:\\n`;\n message += `\ud83c\udf21\ufe0f ${Math.round(temp)}\u00b0C\\n`;\n message += `\ud83d\udca8 Wind: ${Math.round(windSpeed)} km/h\\n`;\n message += `\ud83d\udcdd ${weather.weather[0].description}\\n\\n`;\n}\n\nmessage += `\ud83d\udd50 Last updated: ${new Date().toLocaleString()}\\n`;\nmessage += `\ud83d\udca1 Use /weather for detailed current conditions`;\n\nreturn [{\n json: {\n chatId: $('Check Location Set (Alerts)').first().json.user_id,\n message: me
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.
googleApitelegramApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Weather Bot - Main Handler. Uses telegramTrigger, googleSheets, telegram, httpRequest. Event-driven trigger; 65 nodes.
Source: https://github.com/SAMURAI711/telegram-weather-alert-bot/blob/0df2cb09f542bbd86f989b41d0a4e8ee0a1b7345/n8n-workflows/main-handler.json — 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.
This workflow tracks a configurable crypto watchlist using the CoinGecko API, sends Telegram alerts when price, % change, or volume-spike conditions are met (with optional RSI filtering), optionally l
This n8n workflow automates the process of scraping Google Play Store reviews, analyzing app performance, and sending alerts for low-rated applications. It integrates with Bright Data for web scraping
Manual Alert 2. Uses httpRequest, telegramTrigger, telegram. Event-driven trigger; 7 nodes.
IR-CLU — ربات فروش (احراز هویت + هوش مصنوعی + پرداخت کارتبهکارت). Uses telegramTrigger, googleSheets, telegram, httpRequest. Event-driven trigger; 83 nodes.
IR-CLU — ربات فروش (احراز هویت + هوش مصنوعی + پرداخت کارتبهکارت). Uses telegramTrigger, googleSheets, telegram, httpRequest. Event-driven trigger; 76 nodes.