457 lines
12 KiB
JSON
457 lines
12 KiB
JSON
{
|
||
"name": "Telegram Location Tracker - NocoDB",
|
||
"nodes": [
|
||
{
|
||
"parameters": {
|
||
"updates": [
|
||
"message"
|
||
],
|
||
"additionalFields": {}
|
||
},
|
||
"id": "0ff38437-1b45-4a44-80bb-708f48e3a0d2",
|
||
"name": "Telegram Trigger",
|
||
"type": "n8n-nodes-base.telegramTrigger",
|
||
"typeVersion": 1.1,
|
||
"position": [
|
||
80,
|
||
128
|
||
],
|
||
"webhookId": "telegram-location-webhook",
|
||
"credentials": {
|
||
"telegramApi": {
|
||
"id": "dRHgVQKqowQHIait",
|
||
"name": "Telegram account n8n-munich-bot"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"conditions": {
|
||
"string": [
|
||
{
|
||
"value1": "={{ $json.message.location }}",
|
||
"operation": "isNotEmpty"
|
||
}
|
||
]
|
||
}
|
||
},
|
||
"id": "cf11bd9c-c392-45d0-9fcf-b673c7302f98",
|
||
"name": "Hat Location?",
|
||
"type": "n8n-nodes-base.if",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
304,
|
||
128
|
||
]
|
||
},
|
||
{
|
||
"parameters": {
|
||
"jsCode": "// Extrahiere Location-Daten für NocoDB\nconst items = $input.all();\nconst results = [];\n\nfor (const item of items) {\n const location = item.json.message.location;\n const from = item.json.message.from;\n const messageDate = item.json.message.date;\n \n const timestamp = new Date(messageDate * 1000).toISOString();\n const displayTime = new Date(messageDate * 1000).toLocaleString('de-DE');\n \n results.push({\n json: {\n latitude: location.latitude,\n longitude: location.longitude,\n timestamp: timestamp,\n user_id: from.id,\n first_name: from.first_name || '',\n last_name: from.last_name || '',\n username: from.username || '',\n marker_label: `${from.first_name || ''} ${from.last_name || ''}`.trim(),\n display_time: displayTime,\n chat_id: item.json.message.chat.id\n }\n });\n}\n\nreturn results;"
|
||
},
|
||
"id": "648a42c5-99ce-4c7b-8a85-380cd40050d0",
|
||
"name": "Location verarbeiten",
|
||
"type": "n8n-nodes-base.code",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
528,
|
||
112
|
||
]
|
||
},
|
||
{
|
||
"parameters": {
|
||
"authentication": "nocoDbApiToken",
|
||
"operation": "create",
|
||
"projectId": "pdxl4cx4dbu9nxi",
|
||
"table": "m8pqj5ixgnnrzkg",
|
||
"fieldsUi": {
|
||
"fieldValues": [
|
||
{
|
||
"fieldName": "latitude",
|
||
"fieldValue": "={{ $json.latitude }}"
|
||
},
|
||
{
|
||
"fieldName": "longitude",
|
||
"fieldValue": "={{ $json.longitude }}"
|
||
},
|
||
{
|
||
"fieldName": "timestamp",
|
||
"fieldValue": "={{ $json.timestamp }}"
|
||
},
|
||
{
|
||
"fieldName": "user_id",
|
||
"fieldValue": "={{ $json.user_id }}"
|
||
},
|
||
{
|
||
"fieldName": "first_name",
|
||
"fieldValue": "={{ $json.first_name }}"
|
||
},
|
||
{
|
||
"fieldName": "last_name",
|
||
"fieldValue": "={{ $json.last_name }}"
|
||
},
|
||
{
|
||
"fieldName": "username",
|
||
"fieldValue": "={{ $json.username }}"
|
||
},
|
||
{
|
||
"fieldName": "marker_label",
|
||
"fieldValue": "={{ $json.marker_label }}"
|
||
},
|
||
{
|
||
"fieldName": "display_time",
|
||
"fieldValue": "={{ $json.display_time }}"
|
||
},
|
||
{
|
||
"fieldName": "chat_id",
|
||
"fieldValue": "={{ $json.chat_id }}"
|
||
}
|
||
]
|
||
}
|
||
},
|
||
"id": "0bd51abc-74cb-4220-aa42-f7801c8c79f1",
|
||
"name": "Speichere in NocoDB",
|
||
"type": "n8n-nodes-base.nocoDb",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
752,
|
||
112
|
||
],
|
||
"credentials": {
|
||
"nocoDbApiToken": {
|
||
"id": "6fNBtcghMe8wFoE5",
|
||
"name": "NocoDB Token account"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"authentication": "nocoDbApiToken",
|
||
"operation": "getAll",
|
||
"projectId": "pdxl4cx4dbu9nxi",
|
||
"table": "m8pqj5ixgnnrzkg",
|
||
"options": {}
|
||
},
|
||
"id": "b87051cc-a53b-4c8e-8380-1e8d1d69e75b",
|
||
"name": "Hole letzten Eintrag",
|
||
"type": "n8n-nodes-base.nocoDb",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
976,
|
||
112
|
||
],
|
||
"credentials": {
|
||
"nocoDbApiToken": {
|
||
"id": "6fNBtcghMe8wFoE5",
|
||
"name": "NocoDB Token account"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"authentication": "nocoDbApiToken",
|
||
"operation": "getAll",
|
||
"projectId": "pdxl4cx4dbu9nxi",
|
||
"table": "m8pqj5ixgnnrzkg",
|
||
"returnAll": true,
|
||
"options": {}
|
||
},
|
||
"id": "78a7fd6d-640d-4659-b0c7-11fefc827eaf",
|
||
"name": "Zähle Einträge",
|
||
"type": "n8n-nodes-base.nocoDb",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
976,
|
||
240
|
||
],
|
||
"credentials": {
|
||
"nocoDbApiToken": {
|
||
"id": "6fNBtcghMe8wFoE5",
|
||
"name": "NocoDB Token account"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"jsCode": "// Kombiniere Daten für Telegram-Bestätigung\nconst lastEntry = $('Hole letzten Eintrag').all();\nconst allEntries = $('Zähle Einträge').all();\nconst originalData = $('Location verarbeiten').first().json;\n\nreturn [{\n json: {\n latitude: originalData.latitude,\n longitude: originalData.longitude,\n display_time: originalData.display_time,\n chat_id: originalData.chat_id,\n total: allEntries.length\n }\n}];"
|
||
},
|
||
"id": "25429eb3-aa61-428d-9ec2-2f365e9669eb",
|
||
"name": "Bereite Bestätigung vor",
|
||
"type": "n8n-nodes-base.code",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
1328,
|
||
128
|
||
]
|
||
},
|
||
{
|
||
"parameters": {
|
||
"chatId": "={{ $json.chat_id }}",
|
||
"text": "=✅ Standort gespeichert!\n\n📍 Koordinaten:\nLat: {{ $json.latitude }}\nLon: {{ $json.longitude }}\n\n🕐 Zeit: {{ $json.display_time }}\n\n🗺️ Karte:\nhttps://web.unixweb.home64.de/tracker/index.html\n\n📊 Gespeicherte Punkte: {{ $json.total }}",
|
||
"additionalFields": {}
|
||
},
|
||
"id": "8a3be707-feb5-42c2-a551-5ebc4aa123f9",
|
||
"name": "Telegram Bestätigung",
|
||
"type": "n8n-nodes-base.telegram",
|
||
"typeVersion": 1.1,
|
||
"position": [
|
||
1520,
|
||
128
|
||
],
|
||
"webhookId": "9df3ad7d-315d-4782-b4ec-4fb154c0b46d",
|
||
"credentials": {
|
||
"telegramApi": {
|
||
"id": "dRHgVQKqowQHIait",
|
||
"name": "Telegram account n8n-munich-bot"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"path": "location",
|
||
"responseMode": "lastNode",
|
||
"options": {
|
||
"allowedOrigins": "*"
|
||
}
|
||
},
|
||
"id": "e8d5b4b8-0495-4599-be54-a21ff208f26b",
|
||
"name": "Webhook - Location API",
|
||
"type": "n8n-nodes-base.webhook",
|
||
"typeVersion": 1.1,
|
||
"position": [
|
||
80,
|
||
416
|
||
],
|
||
"webhookId": "location-api-endpoint"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"authentication": "nocoDbApiToken",
|
||
"operation": "getAll",
|
||
"projectId": "pdxl4cx4dbu9nxi",
|
||
"table": "m8pqj5ixgnnrzkg",
|
||
"returnAll": true,
|
||
"options": {}
|
||
},
|
||
"id": "61d1ee53-9536-419b-ab5a-aff4281b08ac",
|
||
"name": "Lade Daten aus NocoDB",
|
||
"type": "n8n-nodes-base.nocoDb",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
304,
|
||
416
|
||
],
|
||
"credentials": {
|
||
"nocoDbApiToken": {
|
||
"id": "6fNBtcghMe8wFoE5",
|
||
"name": "NocoDB Token account"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"jsCode": "// Baue API Response aus NocoDB-Daten\nconst locations = $input.all().map(item => item.json);\n\n// Sortiere nach timestamp (neueste zuerst)\nlocations.sort((a, b) => new Date(b.timestamp) - new Date(a.timestamp));\n\nconst current = locations.length > 0 ? locations[0] : null;\n\nreturn [{\n json: {\n success: true,\n current: current,\n history: locations,\n total_points: locations.length,\n last_updated: current ? current.timestamp : null\n }\n}];"
|
||
},
|
||
"id": "6e2d1c8b-1c23-44d4-9faf-2ab85a200e18",
|
||
"name": "Format API Response",
|
||
"type": "n8n-nodes-base.code",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
528,
|
||
416
|
||
]
|
||
},
|
||
{
|
||
"parameters": {
|
||
"respondWith": "json",
|
||
"responseBody": "={{ $json }}",
|
||
"options": {
|
||
"responseHeaders": {
|
||
"entries": [
|
||
{
|
||
"name": "Access-Control-Allow-Origin",
|
||
"value": "*"
|
||
},
|
||
{
|
||
"name": "Content-Type",
|
||
"value": "application/json"
|
||
}
|
||
]
|
||
}
|
||
}
|
||
},
|
||
"id": "81534ffa-a120-437c-a2cd-5b68991d95fe",
|
||
"name": "JSON Response",
|
||
"type": "n8n-nodes-base.respondToWebhook",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
752,
|
||
416
|
||
]
|
||
},
|
||
{
|
||
"parameters": {
|
||
"height": 544,
|
||
"width": 1632,
|
||
"color": 4
|
||
},
|
||
"type": "n8n-nodes-base.stickyNote",
|
||
"position": [
|
||
0,
|
||
0
|
||
],
|
||
"typeVersion": 1,
|
||
"id": "4fe64055-f0c3-4377-a4f5-be668e6856ef",
|
||
"name": "Sticky Note"
|
||
},
|
||
{
|
||
"parameters": {},
|
||
"type": "n8n-nodes-base.merge",
|
||
"typeVersion": 3.2,
|
||
"position": [
|
||
1168,
|
||
128
|
||
],
|
||
"id": "c7c605e5-9033-4542-a5b5-7847080de63b",
|
||
"name": "Merge"
|
||
}
|
||
],
|
||
"pinData": {},
|
||
"connections": {
|
||
"Telegram Trigger": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Hat Location?",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Hat Location?": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Location verarbeiten",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Location verarbeiten": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Speichere in NocoDB",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Speichere in NocoDB": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Hole letzten Eintrag",
|
||
"type": "main",
|
||
"index": 0
|
||
},
|
||
{
|
||
"node": "Zähle Einträge",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Hole letzten Eintrag": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Merge",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Zähle Einträge": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Merge",
|
||
"type": "main",
|
||
"index": 1
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Bereite Bestätigung vor": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Telegram Bestätigung",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Webhook - Location API": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Lade Daten aus NocoDB",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Lade Daten aus NocoDB": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Format API Response",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Format API Response": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "JSON Response",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Merge": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Bereite Bestätigung vor",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
}
|
||
},
|
||
"active": true,
|
||
"settings": {
|
||
"executionOrder": "v1"
|
||
},
|
||
"versionId": "2fe5806f-3c70-4680-b7eb-66f72a413ea9",
|
||
"meta": {
|
||
"instanceId": "12d864c68e4fb5dfd100dc0c683b95f43cd55af7e9efa82e25407fac5a3824a5"
|
||
},
|
||
"id": "8fjExqEGYvh8XWVu",
|
||
"tags": []
|
||
} |