Files
smartphone-n8n-tracking/tracker-db.json

463 lines
12 KiB
JSON
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"name": "Telegram Location Tracker - NocoDB",
"nodes": [
{
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"id": "ddba8065-2681-4767-a8fc-99f3ccdba6ec",
"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": "3b6cacfd-4fa8-49b5-b7d7-c53e8a38b2b1",
"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": "e6048d6f-f70e-48d2-b9ac-d8e9b666ed06",
"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": "871598c7-0d0d-420d-b570-6cc2fe68225b",
"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",
"limit": 1,
"options": {}
},
"id": "e80e8a1d-901e-4870-85a9-9daac4188b4a",
"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": "c98b7cd0-bf3e-41a0-811e-04b22c5e8662",
"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": "894ec56f-e490-4639-8c50-f5590b036cc9",
"name": "Bereite Bestätigung vor",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1344,
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": "e68d8cb8-7978-44eb-875c-5dd04ae1a4f8",
"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": "b3b98836-97c0-43b4-84ca-4a47eb4bc670",
"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": "efc8af5b-b101-4a1c-b43e-f53adc22736e",
"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\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": "9e270f26-f22e-4b12-a401-326786f8a3ec",
"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": "6f2b9459-9a70-4fd0-aeca-fd93e2686371",
"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": "5f977203-f2d1-4769-b586-61626021a492",
"name": "Sticky Note"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
1168,
128
],
"id": "ddefcd86-d670-408f-86c5-bbcf4468f446",
"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",
"callerPolicy": "workflowsFromSameOwner",
"executionTimeout": -1,
"availableInMCP": false,
"errorWorkflow": "PhwIkaqyXRasTXDH"
},
"versionId": "01b8afe3-8aa5-4004-9384-2dc32654961a",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "12d864c68e4fb5dfd100dc0c683b95f43cd55af7e9efa82e25407fac5a3824a5"
},
"id": "gs6GxPzIPKTjpK2Z",
"tags": []
}