{ "id": "ZDL9028SnyCxS5tf", "meta": { "instanceId": "15c09ee9508dd818e298e675375571ba4b871bbb8c420fd01ac9ed7c58622669" }, "name": "Bitrix24 Task Form Widget Application Workflow example with Webhook Integration", "tags": [], "nodes": [ { "id": "cb30a147-2965-4b45-8974-12fea1eac96d", "name": "Bitrix24 Handler", "type": "n8n-nodes-base.webhook", "position": [ -800, -40 ], "webhookId": "c3ae607d-41f0-42bc-b669-c2c77936d443", "parameters": { "path": "bitrix24/widgethandler.php", "options": {}, "httpMethod": "POST", "responseMode": "responseNode" }, "typeVersion": 1 }, { "id": "08a11f9e-cc9a-430f-8ba1-70985504a10d", "name": "Extract Credentials", "type": "n8n-nodes-base.set", "position": [ -600, -40 ], "parameters": { "options": {}, "assignments": { "assignments": [ { "id": "030f8f90-2669-4c20-9eab-c572c4b7c70c", "name": "CLIENT_ID", "type": "string", "value": "=local.67b8a796e92127.82791242" }, { "id": "de9bbb7a-b782-4540-b259-527625db8490", "name": "CLIENT_SECRET", "type": "string", "value": "=BylHzv4eBw2JuDm7QXOP0C25qzEwf7ATGh79JeOn1iY5lmIRC2" }, { "id": "69bbcb1f-ba6e-42eb-be8a-ee0707ce997d", "name": "domain", "type": "string", "value": "={{$json.query.DOMAIN || $json.body.domain}}" }, { "id": "dc1b0515-f06a-4731-b0dc-912a8d04e56b", "name": "access_token", "type": "string", "value": "={{$json.body.AUTH_ID || $json.body.access_token}}" }, { "id": "86b7aff7-1e25-4b12-a366-23cf34e5a405", "name": "refresh_token", "type": "string", "value": "={{$json.body.REFRESH_ID || $json.body.refresh_token}}" }, { "id": "a1e55fc3-7d29-4f7d-b1a9-c458d2b10e33", "name": "application_token", "type": "string", "value": "={{$json.query.APP_SID || $json.body.APP_SID}}" }, { "id": "ba921f15-28ac-4c0e-89a1-8da755c70892", "name": "expires_in", "type": "string", "value": "={{$json.body.AUTH_EXPIRES || 3600}}" }, { "id": "dbca2de9-55aa-4642-b671-22a195631657", "name": "=client_endpoint", "type": "string", "value": "=https://{{ $json.query.DOMAIN }}/rest/" }, { "id": "1a53f9e3-bfc3-4ea5-88db-514ae1e1253c", "name": "settingsFilePath", "type": "string", "value": "/data/files/hotline_files/" } ] }, "includeOtherFields": true }, "typeVersion": 3.4 }, { "id": "c025c87d-8015-4323-ac60-191cabc8b5e0", "name": "Check Event Type", "type": "n8n-nodes-base.code", "position": [ -400, -40 ], "parameters": { "jsCode": "// PHP szerinti ellenőrzés: $_REQUEST['event'] == 'ONAPPINSTALL' vagy $_REQUEST['PLACEMENT'] == 'DEFAULT'\nconst items = $input.all();\nconst requestData = items[0].json;\n\nlet isInstallation = false;\nlet isInstallationFinished = false;\n\nif (requestData.body && requestData.body.event === 'ONAPPINSTALL') {\n isInstallation = true;\n} else if (requestData.body && requestData.body.PLACEMENT === 'DEFAULT') {\n isInstallation = true;\n if (requestData.body && requestData.body.PLACEMENT_OPTIONS) {\n po = JSON.parse(requestData.body.PLACEMENT_OPTIONS);\n if (po.install_finished === 'Y') {\n isInstallationFinished = true\n } \n} \n} \nreturn {\n json: {\n ...requestData,\n isInstallation: isInstallation,\n isInstallationFinished : isInstallationFinished \n }\n};" }, "typeVersion": 2 }, { "id": "7ba4765a-6c58-4d67-b3ae-5598474916c5", "name": "Is Installation?", "type": "n8n-nodes-base.if", "position": [ -200, -40 ], "parameters": { "options": {}, "conditions": { "options": { "version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict" }, "combinator": "or", "conditions": [ { "id": "da73d0ba-6eeb-405e-89fe-9d041fd2e0cd", "operator": { "type": "boolean", "operation": "equals" }, "leftValue": "={{$json.isInstallation}}", "rightValue": true } ] } }, "typeVersion": 2.2 }, { "id": "8e429e18-392c-4123-969a-f9086d12709d", "name": "Register Placement", "type": "n8n-nodes-base.httpRequest", "position": [ 220, -400 ], "parameters": { "url": "=https://{{$json.domain}}/rest/placement.bind?auth={{$json.access_token}}", "method": "POST", "options": {}, "sendBody": true, "bodyParameters": { "parameters": [ { "name": "PLACEMENT", "value": "TASK_VIEW_TAB" }, { "name": "HANDLER", "value": "={{$json.webhookUrl}}" }, { "name": "TITLE", "value": "My App" } ] } }, "typeVersion": 4.2 }, { "id": "e5d87f1e-1580-433f-990f-624e64fb80d2", "name": "Process Settings", "type": "n8n-nodes-base.function", "position": [ 480, 60 ], "parameters": { "functionCode": "// Process settings from file\nconst items = $input.all();\nlet settingsData = {};\n\ntry {\n // Try to parse the file content\n settingsData = items[0].json.data;\n \n // Extract task ID from PLACEMENT_OPTIONS if available\n let taskId = null;\n const placementOptions = items[0].json.body.PLACEMENT_OPTIONS;\n \n if (placementOptions) {\n try {\n const options = JSON.parse(placementOptions);\n taskId = options.taskId;\n } catch (e) {\n // Ignore parse errors\n }\n }\n \n return {\n json: {\n ...settingsData,\n taskId: taskId,\n success: true,\n originalRequest: items[0].json\n }\n };\n} catch (error) {\n console.log (\"ERROR: \" + error)\n // Return error if file doesn't exist or is invalid\n return {\n json: {\n error: 'No valid settings found',\n success: false,\n originalRequest: items[0].json\n }\n };\n}" }, "typeVersion": 1 }, { "id": "c7384217-38be-4184-b60f-a99c6b762406", "name": "Installation Response", "type": "n8n-nodes-base.respondToWebhook", "position": [ 1020, -380 ], "parameters": { "options": { "responseCode": 200, "responseHeaders": { "entries": [ { "name": "Content-Type", "value": "text/html" } ] } }, "respondWith": "text", "responseBody": "=
\n \n \n\n\n installation has been finished\n" }, "typeVersion": 1.1 }, { "id": "47c89107-6e6f-4255-94e6-776c2309de50", "name": "Has Valid Settings?", "type": "n8n-nodes-base.if", "position": [ 660, 60 ], "parameters": { "options": {}, "conditions": { "options": { "version": 2, "leftValue": "", "caseSensitive": true, "typeValidation": "strict" }, "combinator": "or", "conditions": [ { "id": "71e52c3d-c95c-4ecf-8dce-dbad5c9db29f", "operator": { "type": "boolean", "operation": "equals" }, "leftValue": "={{$json.success}}", "rightValue": true } ] } }, "typeVersion": 2.2 }, { "id": "220b32af-d886-4315-808e-825834eb440e", "name": "Get Task Data", "type": "n8n-nodes-base.httpRequest", "position": [ 920, -40 ], "parameters": { "url": "=https://{{ $json.originalRequest.query.DOMAIN }}/rest/tasks.task.get?auth={{ $json.originalRequest.access_token }}", "method": "POST", "options": {}, "jsonBody": "={{ $json.originalRequest.body.PLACEMENT_OPTIONS }}", "sendBody": true, "specifyBody": "json" }, "typeVersion": 4.2 }, { "id": "e25fb425-28f2-4e48-85b2-8917d4a7497d", "name": "Format Task Data", "type": "n8n-nodes-base.function", "position": [ 1100, -40 ], "parameters": { "functionCode": "// Format Task Data for display\nconst items = $input.all();\nlet taskData = {};\n\ntry {\n taskData = items[0].json.result.task;\n} catch (error) {\n return {\n json: {\n taskHtml: '${field} | \\n${displayValue} | \\n