diff --git a/My_workflow_3 (1).json b/My_workflow_3 (1).json deleted file mode 100644 index 8ec1c11..0000000 --- a/My_workflow_3 (1).json +++ /dev/null @@ -1,3136 +0,0 @@ -{ - "name": "My workflow 3", - "nodes": [ - { - "parameters": { - "httpMethod": "POST", - "path": "04e677f5-ec57-4772-bf12-96f2610d4b9c", - "responseMode": "lastNode", - "options": {} - }, - "type": "n8n-nodes-base.webhook", - "typeVersion": 2, - "position": [ - -1800, - 1300 - ], - "id": "d0f07ccf-3350-43a7-a099-e183be06c93d", - "name": "Webhook", - "webhookId": "04e677f5-ec57-4772-bf12-96f2610d4b9c" - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.provider }}", - "rightValue": "zoho", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "ec09c1c7-8686-49eb-9497-c17313d74d1e" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "e378a3a0-2104-4e08-b6d1-8be004fcf585", - "leftValue": "={{ $json.body.provider }}", - "rightValue": "salesforce", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "73218312-5c71-47d3-b5b9-d6859357d14a", - "leftValue": "={{ $json.body.provider }}", - "rightValue": "intuit", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - -1160, - 1300 - ], - "id": "398a367d-6bd5-433a-ba93-50c5f1951f6f", - "name": "Provider Switch", - "notes": "Provider Switch" - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.service }}", - "rightValue": "crm", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "96d87a3f-3ced-46c4-b9e3-f4910d8e6e5c" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "d5c89946-51d0-427f-9bf4-c06c3f113744", - "leftValue": "={{ $json.body.service }}", - "rightValue": "books", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "fb2caef9-6ef0-46e8-bcc0-4f0d15164ac4", - "leftValue": "={{ $json.body.service }}", - "rightValue": "people", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "84cb396b-6085-414e-8cc6-a8b3d67c5328", - "leftValue": "={{ $json.body.service }}", - "rightValue": "projects", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - 620, - 960 - ], - "id": "2c4f6f04-defb-44c0-9d46-00ec16c80baf", - "name": "Service Switch" - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.module }}", - "rightValue": "leads", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "c15a3656-cc8c-4773-8f3b-feb319a255b7" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "799b3ed5-57c3-4cbc-99fe-c77bb3e1d65d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "tasks", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "1cb88648-40cb-4306-b26a-d71fd943d85c", - "leftValue": "={{ $json.body.module }}", - "rightValue": "contacts", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "cd72d40a-a433-4317-aba5-766258fc133d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "accounts", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "6d6078a7-3384-48c9-a20f-59cae4cf5555", - "leftValue": "={{ $json.body.module }}", - "rightValue": "deals", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "63d08db5-5a2a-461b-977b-fafbe2a975cc", - "leftValue": "={{ $json.body.module }}", - "rightValue": "purchase_orders", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "a206e640-387b-4308-8384-053b5b28caca", - "leftValue": "={{ $json.body.module }}", - "rightValue": "sales_orders", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "3350450b-576f-403c-9dab-96d5ee425bd3", - "leftValue": "={{ $json.body.module }}", - "rightValue": "invoices", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - 940, - -260 - ], - "id": "47426d55-7d17-4f60-b679-3822403ee87a", - "name": "Zoho Crm Switch" - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Leads", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $('Service Switch').item.json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - -740 - ], - "id": "4d70c03c-27b9-4c43-a1cd-777391227d55", - "name": "CRM Leads" - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Tasks", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - -580 - ], - "id": "3ed1941a-e4c6-4d66-89bf-8fb4ad40aabc", - "name": "CRM Tasks", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Contacts", - "sendQuery": true, - "specifyQuery": "={{ $json.query.toJsonString() }}", - "queryParameters": { - "parameters": [ - {} - ] - }, - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - -400 - ], - "id": "a81c5edc-84d7-4e80-a210-3fd2d1214afb", - "name": "CRM Contacts" - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Accounts", - "sendQuery": true, - "specifyQuery": "={{ $json.query.toJsonString() }}", - "queryParameters": { - "parameters": [ - {} - ] - }, - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - -220 - ], - "id": "09c0e93f-01d9-4bcf-af32-369b44fd2731", - "name": "CRM Accounts" - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Deals", - "sendQuery": true, - "specifyQuery": "={{ $json.query.toJsonString() }}", - "queryParameters": { - "parameters": [ - {} - ] - }, - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - -40 - ], - "id": "7175d886-284f-4250-9e49-b9d3370a99c9", - "name": "CRM Deals" - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Purchase_Orders", - "sendQuery": true, - "specifyQuery": "={{ $json.query.toJsonString() }}", - "queryParameters": { - "parameters": [ - {} - ] - }, - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - 120 - ], - "id": "a988af59-2ea0-4026-bd70-8114d76cd6b0", - "name": "CRM Purchase Orders", - "disabled": true - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Sales_Orders", - "sendQuery": true, - "specifyQuery": "={{ $json.query.toJsonString() }}", - "queryParameters": { - "parameters": [ - {} - ] - }, - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - 300 - ], - "id": "94f4ff69-3765-4094-a85b-b20767154732", - "name": "CRM Sales Orders", - "disabled": true - }, - { - "parameters": { - "url": "https://www.zohoapis.com/crm/v2/Invoices", - "sendQuery": true, - "specifyQuery": "={{ $json.query.toJsonString() }}", - "queryParameters": { - "parameters": [ - {} - ] - }, - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1300, - 500 - ], - "id": "30f0b9ec-0d4a-403c-a9b9-857f045b22a6", - "name": "Invoices", - "disabled": true - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.module }}", - "rightValue": "organizations", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "c15a3656-cc8c-4773-8f3b-feb319a255b7" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "799b3ed5-57c3-4cbc-99fe-c77bb3e1d65d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "contacts", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "1cb88648-40cb-4306-b26a-d71fd943d85c", - "leftValue": "={{ $json.body.module }}", - "rightValue": "customers", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "cd72d40a-a433-4317-aba5-766258fc133d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "vendors", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "6d6078a7-3384-48c9-a20f-59cae4cf5555", - "leftValue": "={{ $json.body.module }}", - "rightValue": "accounts", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "63d08db5-5a2a-461b-977b-fafbe2a975cc", - "leftValue": "={{ $json.body.module }}", - "rightValue": "purchase_orders", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "a206e640-387b-4308-8384-053b5b28caca", - "leftValue": "={{ $json.body.module }}", - "rightValue": "sales_orders", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "3350450b-576f-403c-9dab-96d5ee425bd3", - "leftValue": "={{ $json.body.module }}", - "rightValue": "invoices", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "849ead69-4cb8-4686-8aef-6c88cc0d313d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "bills", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "033d11a6-fe26-4a97-ad07-7fa826f4674a", - "leftValue": "={{ $json.body.module }}", - "rightValue": "expenses", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - 2020, - -120 - ], - "id": "2be43e36-dafa-4bcd-97e1-1e137ae380fc", - "name": "Zoho Books Switch" - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/organizations", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2460, - -820 - ], - "id": "b47f0624-b0ba-4931-aa4e-7314fb5b0536", - "name": "Book Organization", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/contacts", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{$json.query.toJsonString()}}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2480, - -600 - ], - "id": "89e6f550-2040-4f30-bd39-67ae77c48ff6", - "name": "Book Contacts", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/contacts", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify({ ...$json.query, contact_type: \"customer\" }) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2480, - -380 - ], - "id": "9943aa83-f2d7-4ad4-9232-fbddf78d7abc", - "name": "Book Customers", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/contacts", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify({ ...$json.query, contact_type: \"vendor\" }) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2480, - -200 - ], - "id": "76fc7515-3bba-486a-ba4f-2354f7d86434", - "name": "Book Vendors", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/bankaccounts", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify($json.query) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2480, - 20 - ], - "id": "cb02d976-aff5-4046-8f9f-18e0840d9442", - "name": "Book Accounts", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/purchaseorders", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify($json.query) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2480, - 220 - ], - "id": "7caaf4d6-0614-4db6-9c14-60b5a1e6cc59", - "name": "Purchase Orders", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/salesorders", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify($json.query) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2500, - 420 - ], - "id": "fba30023-8e6a-46f1-a726-9a47868c7a67", - "name": "Sales Orders", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/invoices", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify($json.query) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2480, - 660 - ], - "id": "652c8f7b-a577-4c5c-94a7-66ebe66d6847", - "name": "Invoices2", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/bills", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify($json.query) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2500, - 860 - ], - "id": "28afa8aa-c934-45fe-a8f4-8aec860ef29d", - "name": "Bills", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://www.zohoapis.com/books/v3/expenses", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ JSON.stringify($json.query) }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2520, - 1060 - ], - "id": "b4ef3c22-545e-456e-89b6-7bc2e9f68494", - "name": "Expenses", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.module }}", - "rightValue": "employees", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "c15a3656-cc8c-4773-8f3b-feb319a255b7" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "799b3ed5-57c3-4cbc-99fe-c77bb3e1d65d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "departments", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "1cb88648-40cb-4306-b26a-d71fd943d85c", - "leftValue": "={{ $json.body.module }}", - "rightValue": "timesheets", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "cd72d40a-a433-4317-aba5-766258fc133d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "leaves", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "6d6078a7-3384-48c9-a20f-59cae4cf5555", - "leftValue": "={{ $json.body.module }}", - "rightValue": "attendence", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "63d08db5-5a2a-461b-977b-fafbe2a975cc", - "leftValue": "={{ $json.body.module }}", - "rightValue": "attendence_entries", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "a206e640-387b-4308-8384-053b5b28caca", - "leftValue": "={{ $json.body.module }}", - "rightValue": "attendence_report", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "3350450b-576f-403c-9dab-96d5ee425bd3", - "leftValue": "={{ $json.body.module }}", - "rightValue": "leave_tracker", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "849ead69-4cb8-4686-8aef-6c88cc0d313d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "leaves_data", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "033d11a6-fe26-4a97-ad07-7fa826f4674a", - "leftValue": "={{ $json.body.module }}", - "rightValue": "goals_data", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "5d85ad8a-ddef-4ff8-a655-aa030b9b7bc2", - "leftValue": "={{ $json.body.module }}", - "rightValue": "performance_data", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - 2060, - 2340 - ], - "id": "f680b2c4-b690-4020-88bc-5d4d8868f6b3", - "name": "Zoho People" - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/forms/employee/getRecords", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2420, - 1460 - ], - "id": "c1b38892-fc8a-41ea-8a74-0121fb87eb55", - "name": "Employees", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/v1/departments", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2440, - 1680 - ], - "id": "6af07f51-6a00-4f89-83d9-c70d5af51318", - "name": "Departments", - "alwaysOutputData": false, - "retryOnFail": false, - "disabled": true - }, - { - "parameters": { - "url": "https://people.zoho.com/people/timetracker/gettimesheet", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2420, - 1920 - ], - "id": "51d0952c-8c43-48a6-88b1-816751d88568", - "name": "TimeSheets", - "alwaysOutputData": false, - "retryOnFail": false, - "disabled": true - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/v1/leave", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2420, - 2180 - ], - "id": "a6e97bdc-9f49-4997-9b42-4899b2612291", - "name": "Leaves", - "alwaysOutputData": false, - "retryOnFail": false, - "disabled": true - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/attendance/getAttendanceEntries", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2440, - 2700 - ], - "id": "69d08c45-5935-4251-943a-0c0bcf8ce34a", - "name": "attendence_entries", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/v1/attendance", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2440, - 2440 - ], - "id": "d4bd33f8-c855-432b-9cd3-59df38ca7f6b", - "name": "Attendence", - "alwaysOutputData": false, - "retryOnFail": false, - "disabled": true - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/attendance/getUserReport", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const params = { ...$json.query };\n\n // Replace per_page with limit (and remove per_page)\n if (params.per_page) {\n params.limit = params.per_page;\n delete params.per_page;\n }\n\n // Set default sdate and edate (last 7 days) if not provided\n if (!params.sdate || !params.edate) {\n const today = new Date();\n const sevenDaysAgo = new Date(today.getTime() - 7 * 24 * 60 * 60 * 1000);\n params.sdate = sevenDaysAgo.toISOString().split('T')[0];\n params.edate = today.toISOString().split('T')[0];\n }\n\n // Default date format\n if (!params.dateFormat) {\n params.dateFormat = 'yyyy-MM-dd';\n }\n\n // Default start index\n if (!params.startIndex) {\n params.startIndex = 1;\n }\n\n return JSON.stringify(params);\n })()\n}}\n\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2440, - 2920 - ], - "id": "10206f7a-a916-47d8-aff3-b2bdf5d95bbf", - "name": "Attendence Report", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/v2/leavetracker/reports/bookedAndBalance", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const params = { ...$json.query };\n\n // Convert per_page → limit\n if (params.per_page) {\n params.limit = params.per_page;\n delete params.per_page;\n }\n\n // Helper function to format date as dd-MMM-yyyy\n const formatDate = (date) => {\n const day = String(date.getDate()).padStart(2, '0');\n const month = date.toLocaleString('en-US', { month: 'short' });\n const year = date.getFullYear();\n return `${day}-${month}-${year}`;\n };\n\n // Default 'from' = start of current year\n if (!params.from) {\n const currentYear = new Date().getFullYear();\n const startDate = new Date(currentYear, 0, 1); // Jan 1st\n params.from = formatDate(startDate);\n }\n\n // Default 'to' = today\n if (!params.to) {\n params.to = formatDate(new Date());\n }\n\n // Default 'page' = 1\n if (!params.page) {\n params.page = 1;\n }\n\n // Default 'unit' = 'Day'\n if (!params.unit) {\n params.unit = 'Day';\n }\n\n return JSON.stringify(params);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2440, - 3120 - ], - "id": "65f17259-4d4b-487b-9776-3bee624c5481", - "name": "Leave Tracker", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/forms/leave/getRecords", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}\n", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2460, - 3340 - ], - "id": "64be48f5-7f21-4990-a1ea-001125e953c5", - "name": "Leave Data", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/forms/goal/getRecords", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2460, - 3560 - ], - "id": "4597dd8e-f4f4-42f2-8a41-85f1136e8eb1", - "name": "Goals Data", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "https://people.zoho.com/people/api/forms/performance/getRecords", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{\n (() => {\n const query = { ...$json.query };\n if (query.per_page) {\n query.limit = query.per_page;\n delete query.per_page;\n }\n return JSON.stringify(query);\n })()\n}}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 2460, - 3780 - ], - "id": "4431b93d-5446-41fa-9bce-c2957864a30a", - "name": "Performance Data", - "alwaysOutputData": false, - "retryOnFail": false, - "disabled": true - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.module }}", - "rightValue": "portals", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "c15a3656-cc8c-4773-8f3b-feb319a255b7" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "1cb88648-40cb-4306-b26a-d71fd943d85c", - "leftValue": "={{ $json.body.module }}", - "rightValue": "projects", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "cd72d40a-a433-4317-aba5-766258fc133d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "tasks", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "6d6078a7-3384-48c9-a20f-59cae4cf5555", - "leftValue": "={{ $json.body.module }}", - "rightValue": "all_tasks", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "63d08db5-5a2a-461b-977b-fafbe2a975cc", - "leftValue": "={{ $json.body.module }}", - "rightValue": "tasklists", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "a206e640-387b-4308-8384-053b5b28caca", - "leftValue": "={{ $json.body.module }}", - "rightValue": "all_tasklists", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "3350450b-576f-403c-9dab-96d5ee425bd3", - "leftValue": "={{ $json.body.module }}", - "rightValue": "issues", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "849ead69-4cb8-4686-8aef-6c88cc0d313d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "phases", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "033d11a6-fe26-4a97-ad07-7fa826f4674a", - "leftValue": "={{ $json.body.module }}", - "rightValue": "goals_data", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "5d85ad8a-ddef-4ff8-a655-aa030b9b7bc2", - "leftValue": "={{ $json.body.module }}", - "rightValue": "performance_data", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - 1040, - 2380 - ], - "id": "ba477f0c-07c8-4dc3-8fd1-fea3f5e3cc2c", - "name": "Zoho Projects" - }, - { - "parameters": { - "url": "https://projectsapi.zoho.com/api/v3/portals", - "sendQuery": true, - "specifyQuery": "json", - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "specifyHeaders": "=keypair", - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 2120 - ], - "id": "5af5f22e-de4d-4953-8824-e8760d7ee499", - "name": "Portals", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/projects ", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 2320 - ], - "id": "03b728f5-cb2e-47fd-8239-649945e5507d", - "name": "Projects", - "alwaysOutputData": false, - "retryOnFail": false, - "executeOnce": false - }, - { - "parameters": { - "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nlet projects=[];\nfor (const item of $input.all()) {\n projects.push(item.json)\n}\n\nreturn [{\"data\":projects}];" - }, - "type": "n8n-nodes-base.code", - "typeVersion": 2, - "position": [ - 1520, - 2320 - ], - "id": "22a9b74f-59d8-472b-810d-53959c35e71e", - "name": "Code1" - }, - { - "parameters": { - "jsCode": "// Loop over input items and add a new field called 'myNewField' to the JSON of each one\nlet projects=[];\nfor (const item of $input.all()) {\n projects.push(item.json)\n}\n\nreturn [{\"data\":projects}];" - }, - "type": "n8n-nodes-base.code", - "typeVersion": 2, - "position": [ - 1520, - 2120 - ], - "id": "bcd46aa9-fc91-4570-a7f9-06eab7bcf62a", - "name": "Code" - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/tasks ", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 2640 - ], - "id": "d23335cf-98c5-41d6-8397-53294ab82b0c", - "name": "All Project Tasks", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/projects/{{ $json.query.project_id }}/tasklists", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 2820 - ], - "id": "2f1bcd05-2e7b-4eaf-b307-0da3158c0975", - "name": "Tasklist", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/all-tasklists ", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 3020 - ], - "id": "6e9ff28d-d5d6-4772-b75d-0b4e13be8afd", - "name": "All Tasklists", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/issues", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 3220 - ], - "id": "bc42c37f-7abf-4b19-be03-09579cd6698a", - "name": "Issues", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/phases", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 3420 - ], - "id": "3a26399d-f5c1-4b29-a00c-f5d6ce47c7bf", - "name": "Phases", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "url": "=https://projectsapi.zoho.com/api/v3/portal/{{ $json.query.portal_id }}/projects/{{ $json.query.project_id }}/tasks ", - "sendQuery": true, - "specifyQuery": "=json", - "queryParameters": { - "parameters": [ - {} - ] - }, - "jsonQuery": "={{ $json.query.toJsonString() }}", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Zoho-oauthtoken {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 1340, - 2480 - ], - "id": "cf5588fb-f692-45ea-8a92-9cc7001c9e1e", - "name": "Project Tasks", - "alwaysOutputData": false, - "retryOnFail": false - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.service }}", - "rightValue": "crm", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "96d87a3f-3ced-46c4-b9e3-f4910d8e6e5c" - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - -700, - 1580 - ], - "id": "e7e84c60-4333-484f-8df8-ce8da38f2329", - "name": "SalesForce Service" - }, - { - "parameters": { - "rules": { - "values": [ - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "leftValue": "={{ $json.body.module }}", - "rightValue": "leads", - "operator": { - "type": "string", - "operation": "equals" - }, - "id": "c15a3656-cc8c-4773-8f3b-feb319a255b7" - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "799b3ed5-57c3-4cbc-99fe-c77bb3e1d65d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "tasks", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "1cb88648-40cb-4306-b26a-d71fd943d85c", - "leftValue": "={{ $json.body.module }}", - "rightValue": "accounts", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "cd72d40a-a433-4317-aba5-766258fc133d", - "leftValue": "={{ $json.body.module }}", - "rightValue": "opportunities", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "6d6078a7-3384-48c9-a20f-59cae4cf5555", - "leftValue": "={{ $json.body.module }}", - "rightValue": "events", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - }, - { - "conditions": { - "options": { - "caseSensitive": true, - "leftValue": "", - "typeValidation": "strict", - "version": 2 - }, - "conditions": [ - { - "id": "63d08db5-5a2a-461b-977b-fafbe2a975cc", - "leftValue": "={{ $json.body.module }}", - "rightValue": "reports", - "operator": { - "type": "string", - "operation": "equals", - "name": "filter.operator.equals" - } - } - ], - "combinator": "and" - } - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.switch", - "typeVersion": 3.2, - "position": [ - -300, - 1660 - ], - "id": "865cf198-bb03-432a-bbc9-339178b17bef", - "name": "SalesForce CRM" - }, - { - "parameters": { - "url": "={{ $json.query.instance_url }}/services/data/v59.0/query/?q=SELECT+Id,FirstName,LastName,Company,Email,Status+FROM+Lead ", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Bearer {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 60, - 1300 - ], - "id": "67ef30c1-4bee-4006-92fd-c054f9dd3f44", - "name": "SalesForce Leads" - }, - { - "parameters": { - "url": "={{ $json.query.instance_url }}/services/data/v59.0/query/?q=SELECT+Id,Subject,Status,Priority,ActivityDate,WhatId, WhoId,OwnerId,Description,CreatedDate,LastModifiedDate+FROM +Task", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Bearer {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 60, - 1500 - ], - "id": "896ee6e4-84e9-4954-85e0-8b2d9ca4d58d", - "name": "SalesForce Tasks" - }, - { - "parameters": { - "url": "={{ $json.query.instance_url }}/services/data/v59.0/query/?q=SELECT+Id,Name,StageName,Amount,CloseDate,AccountId,Type,Probability,ForecastCategory,OwnerId,CreatedDate,LastModifiedDate+FROM+Opportunity", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Bearer {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 60, - 1840 - ], - "id": "01867f3c-e8f0-4142-adc0-4a842c42ba37", - "name": "SalesForce Opportunities" - }, - { - "parameters": { - "url": "={{ $json.query.instance_url }}/services/data/v59.0/query/?q=SELECT+Id,Subject,StartDateTime,EndDateTime,Location,Description,OwnerId,WhatId,WhoId,IsAllDayEvent,CreatedDate+FROM+Event", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Bearer {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 60, - 2020 - ], - "id": "b0d4dd0d-6190-413d-9528-cb54680e370f", - "name": "SalesForce Events" - }, - { - "parameters": { - "url": "={{ $json.query.instance_url }}/services/data/v59.0/query/?q=SELECT+Id,Name,Industry,Type,Phone,BillingCity,BillingState,BillingCountry,Website,OwnerId,CreatedDate+FROM+Account", - "sendHeaders": true, - "headerParameters": { - "parameters": [ - { - "name": "Authorization", - "value": "=Bearer {{ $json.body.acces_token }}" - } - ] - }, - "options": {} - }, - "type": "n8n-nodes-base.httpRequest", - "typeVersion": 4.2, - "position": [ - 60, - 1680 - ], - "id": "55fb63e3-3dd0-47ae-b30b-991e3b938e0c", - "name": "Accounts" - } - ], - "pinData": {}, - "connections": { - "Webhook": { - "main": [ - [ - { - "node": "Provider Switch", - "type": "main", - "index": 0 - } - ] - ] - }, - "Provider Switch": { - "main": [ - [ - { - "node": "Service Switch", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "SalesForce Service", - "type": "main", - "index": 0 - } - ] - ] - }, - "Service Switch": { - "main": [ - [ - { - "node": "Zoho Crm Switch", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Zoho Books Switch", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Zoho People", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Zoho Projects", - "type": "main", - "index": 0 - } - ] - ] - }, - "Zoho Crm Switch": { - "main": [ - [ - { - "node": "CRM Leads", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "CRM Tasks", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "CRM Contacts", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "CRM Accounts", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "CRM Deals", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "CRM Purchase Orders", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "CRM Sales Orders", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Invoices", - "type": "main", - "index": 0 - } - ] - ] - }, - "CRM Tasks": { - "main": [ - [], - [] - ] - }, - "Zoho Books Switch": { - "main": [ - [ - { - "node": "Book Organization", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Book Contacts", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Book Customers", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Book Vendors", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Book Accounts", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Purchase Orders", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Sales Orders", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Invoices2", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Bills", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Expenses", - "type": "main", - "index": 0 - } - ] - ] - }, - "Zoho People": { - "main": [ - [ - { - "node": "Employees", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Departments", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "TimeSheets", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Leaves", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Attendence", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "attendence_entries", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Attendence Report", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Leave Tracker", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Leave Data", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Goals Data", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Performance Data", - "type": "main", - "index": 0 - } - ] - ] - }, - "Zoho Projects": { - "main": [ - [ - { - "node": "Portals", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Projects", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Project Tasks", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "All Project Tasks", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Tasklist", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "All Tasklists", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Issues", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Phases", - "type": "main", - "index": 0 - } - ] - ] - }, - "Portals": { - "main": [ - [ - { - "node": "Code", - "type": "main", - "index": 0 - } - ] - ] - }, - "Projects": { - "main": [ - [ - { - "node": "Code1", - "type": "main", - "index": 0 - } - ] - ] - }, - "SalesForce Service": { - "main": [ - [ - { - "node": "SalesForce CRM", - "type": "main", - "index": 0 - } - ] - ] - }, - "SalesForce CRM": { - "main": [ - [ - { - "node": "SalesForce Leads", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "SalesForce Tasks", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "Accounts", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "SalesForce Opportunities", - "type": "main", - "index": 0 - } - ], - [ - { - "node": "SalesForce Events", - "type": "main", - "index": 0 - } - ] - ] - } - }, - "active": false, - "settings": { - "executionOrder": "v1" - }, - "versionId": "37c287d2-8fb8-406d-b3ff-36e13182f3cf", - "meta": { - "instanceId": "9d60a85fa4871b6b53e6270171078332f043c918ce5baaf350d902f18d860eec" - }, - "id": "ZcLXCtrLreCJBrTg", - "tags": [] -} \ No newline at end of file diff --git a/src/integrations/n8n/client.js b/src/integrations/n8n/client.js index db26aaa..0a522a4 100644 --- a/src/integrations/n8n/client.js +++ b/src/integrations/n8n/client.js @@ -51,7 +51,7 @@ class N8nClient { provider: payload.provider, service: payload.service, module: payload.module, - status: response.status + status: response.status }); return response.data; @@ -61,6 +61,7 @@ class N8nClient { service: payload.service, module: payload.module, error: error.message, + statusCode: error.response?.status, response: error.response?.data }); diff --git a/src/integrations/n8n/handler.js b/src/integrations/n8n/handler.js index 53e35f7..c9343f9 100644 --- a/src/integrations/n8n/handler.js +++ b/src/integrations/n8n/handler.js @@ -4,6 +4,10 @@ const { decrypt, encrypt } = require('../../utils/crypto'); const logger = require('../../utils/logger'); const axios = require('axios'); +// Token refresh lock to prevent concurrent refresh attempts +// Map structure: { 'userId-serviceName': Promise } +const tokenRefreshLocks = new Map(); + class N8nHandler { constructor(userId) { this.userId = userId; @@ -31,10 +35,47 @@ class N8nHandler { } /** - * Refresh Zoho access token + * Refresh Zoho access token with locking to prevent concurrent refreshes * @returns {Promise} New access token */ async refreshZohoToken() { + const lockKey = `${this.userId}-zoho`; + + // Check if there's already a refresh in progress + if (tokenRefreshLocks.has(lockKey)) { + logger.info('Token refresh already in progress, waiting for completion', { userId: this.userId, service: 'zoho' }); + + // Wait for the existing refresh to complete + try { + const newToken = await tokenRefreshLocks.get(lockKey); + return newToken; + } catch (error) { + // If the concurrent refresh failed, try again + } + } + + // Create a new refresh promise + const refreshPromise = this._doRefreshZohoToken(); + + // Store it in the lock map + tokenRefreshLocks.set(lockKey, refreshPromise); + + try { + const newToken = await refreshPromise; + return newToken; + } finally { + // Clean up the lock after a short delay + setTimeout(() => { + tokenRefreshLocks.delete(lockKey); + }, 1000); + } + } + + /** + * Internal method to actually refresh the Zoho token + * @private + */ + async _doRefreshZohoToken() { const { refreshToken } = await this.getServiceTokens('zoho'); if (!refreshToken) { @@ -80,10 +121,47 @@ class N8nHandler { } /** - * Refresh Salesforce access token + * Refresh Salesforce access token with locking to prevent concurrent refreshes * @returns {Promise} New access token */ async refreshSalesforceToken() { + const lockKey = `${this.userId}-salesforce`; + + // Check if there's already a refresh in progress + if (tokenRefreshLocks.has(lockKey)) { + logger.info('Token refresh already in progress, waiting for completion', { userId: this.userId, service: 'salesforce' }); + + // Wait for the existing refresh to complete + try { + const newToken = await tokenRefreshLocks.get(lockKey); + return newToken; + } catch (error) { + // If the concurrent refresh failed, try again + } + } + + // Create a new refresh promise + const refreshPromise = this._doRefreshSalesforceToken(); + + // Store it in the lock map + tokenRefreshLocks.set(lockKey, refreshPromise); + + try { + const newToken = await refreshPromise; + return newToken; + } finally { + // Clean up the lock after a short delay to allow concurrent requests to use the new token + setTimeout(() => { + tokenRefreshLocks.delete(lockKey); + }, 1000); + } + } + + /** + * Internal method to actually refresh the Salesforce token + * @private + */ + async _doRefreshSalesforceToken() { const { refreshToken, instanceUrl } = await this.getServiceTokens('salesforce'); if (!refreshToken) { @@ -100,6 +178,7 @@ class N8nHandler { try { const tokenUrl = process.env.SALESFORCE_INSTANCE_URL || 'https://login.salesforce.com'; + const response = await axios.post(`${tokenUrl}/services/oauth2/token`, params.toString(), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); @@ -247,13 +326,35 @@ class N8nHandler { query ); + // Check if the result contains an error (n8n returns 200 but with error in body) + if (result && (result.status === 401 || result.status === '401')) { + const error = new Error(result.message || 'Token expired'); + error.response = { status: 401, data: result }; + throw error; + } + return this.normalizeResponse(result, 'salesforce'); } catch (error) { + // Check if error indicates token expiration + const isTokenError = + error.response?.status === 401 || + error.message?.includes('401') || + error.message?.includes('INVALID_SESSION_ID') || + error.message?.includes('Session expired') || + error.message?.includes('unauthorized'); + // If unauthorized (401), try refreshing token once - if (error.message.includes('401') || error.message.includes('unauthorized')) { - logger.info('Received 401 error, attempting token refresh', { userId: this.userId }); + if (isTokenError) { + logger.info('Received token expiration error, attempting token refresh', { + userId: this.userId, + errorMessage: error.message, + errorStatus: error.response?.status + }); + try { + // Refresh the Salesforce token const newAccessToken = await this.refreshSalesforceToken(); + const { instanceUrl } = await this.getServiceTokens('salesforce'); const query = { instance_url: instanceUrl, @@ -262,7 +363,9 @@ class N8nHandler { nextRecordsUrl: options.nextRecordsUrl || null, ...options.filters }; + const result = await this.client.fetchSalesforceData(service, module, newAccessToken, instanceUrl, query); + return this.normalizeResponse(result, 'salesforce'); } catch (retryError) { logger.error('Failed to fetch Salesforce data after token refresh', { diff --git a/src/utils/logger.js b/src/utils/logger.js index e987708..7195544 100644 --- a/src/utils/logger.js +++ b/src/utils/logger.js @@ -14,7 +14,7 @@ function getCorrelationId(req) { function log(level, message, meta = {}) { const timestamp = new Date().toISOString(); const payload = { level, message, timestamp, ...meta }; - // eslint-disable-next-line no-console + // eslint-disable-next-line no-consoles console.log(JSON.stringify(payload)); }