Pause/Wait next operations depends on the total previous operations

Describe the issue/error/question

Hey everyone.

i want to ask how to pause the operations if operations reaching n numbers.

my goal is to push the data from google sheet to freshworks crm, but since freshworks crm has 1k api call per hours, i want to manage that quota by using Pause/Wait functions

example:
if 2 freshworks crm node (im using http request) operations already reach more than 700, this will pause/wait for 1 hours, then after 1 hours will continue.

if 2 freshworks crm node (im using http request) operations is less than 200, this will bypass the pause/wait function and continue the rest.

i will use if functions to split the conditions

Please share the workflow

{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        400,
        -80
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "sheetId": "",
        "range": "A:Z",
        "options": {}
      },
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 1,
      "position": [
        480,
        260
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "1",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "requestMethod": "POST",
        "url": "https://mycompany.myfreshworks.com/crm/sales/api/contacts",
        "jsonParameters": true,
        "options": {
          "bodyContentType": "json",
          "fullResponse": true
        },
        "bodyParametersJson": "={\n  \"contact\": {\n    \"first_name\": \"{{$node[\"Google Sheets\"].json[\"first_name\"]}}\",\n    \"last_name\": \"{{$node[\"Google Sheets\"].json[\"last_name\"]}}\",\n    \"avatar\": null,\n    \"job_title\": \"\",\n    \"city\": \"{{$node[\"Google Sheets\"].json[\"city\"]}}\",\n    \"country\": \"{{$node[\"Google Sheets\"].json[\"nationality\"]}}\",\n    \"email\": \"{{$node[\"Google Sheets\"].json[\"email\"]}}\",\n    \"work_number\": \"\",\n    \"mobile_number\": \"{{$node[\"Google Sheets\"].json[\"Phone Number Formatted\"]}}\",\n    \"custom_field\": {\n      \"cf_contact_type\": \"Reseller\",\n      \"cf_agent_manager\": \"{{$node[\"Google Sheets\"].json[\"rdz_agent_email\"]}}\",\n\t  \"cf_source_helper\": \"\",\n\t  \"cf_sales_owner_helper\": \"\",\n\t  \"cf_status_helper\": \"Onboarded\",\n\t  \"cf_life_cycle_stage_helper\": \"Customer\"\n    }\n  }\n}"
      },
      "name": "Create Contacts",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        660,
        260
      ],
      "alwaysOutputData": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "4",
          "name": "Header Auth account"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "triggerTimes": {
          "item": [
            {
              "hour": 1
            }
          ]
        }
      },
      "name": "Cron",
      "type": "n8n-nodes-base.cron",
      "typeVersion": 1,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "requestMethod": "PUT",
        "url": "=https://mycompany.myfreshworks.com/crm/sales/api/contacts/{{$node[\"IF Lookup Based on External ID Empty\"].json[\"contacts\"][\"contacts\"][0][\"id\"]}}",
        "jsonParameters": true,
        "options": {
          "fullResponse": true
        },
        "bodyParametersJson": "={\n\"contact\": {\n\"first_name\": \"{{$node[\"Google Sheets\"].json[\"first_name\"]}}\",\n\"last_name\": \"{{$node[\"Google Sheets\"].json[\"last_name\"]}}\",\n\"avatar\": null,\n\"job_title\": \"\",\n\"city\": \"{{$node[\"Google Sheets\"].json[\"city\"]}}\",\n\"country\": \"{{$node[\"Google Sheets\"].json[\"nationality\"]}}\",\n\"email\": \"{{$node[\"Google Sheets\"].json[\"email\"]}}\",\n\"work_number\": \"\",\n\"mobile_number\": \"{{$node[\"Google Sheets\"].json[\"Phone Number Formatted\"]}}\",\n\"custom_field\": {\n\"cf_contact_type\": \"Reseller\",\n\"cf_agent_manager\": \"{{$node[\"Google Sheets\"].json[\"rdz_agent_email\"]}}\",\n\"cf_source_helper\": \"\",\n\"cf_sales_owner_helper\": \"\",\n\"cf_status_helper\": \"Onboarded\",\n\"cf_life_cycle_stage_helper\": \"Customer\"\n}\n}\n}"
      },
      "name": "Update Contacts (external id not empty)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1680,
        -100
      ],
      "alwaysOutputData": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "4",
          "name": "Header Auth account"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "=https://mycompany.myfreshworks.com/crm/sales/api/lookup?q={{$node[\"Google Sheets\"].json[\"email\"]}}&f=email&entities=contact",
        "jsonParameters": true,
        "options": {
          "fullResponse": false
        }
      },
      "name": "Lookup Contacts (email based)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1680,
        240
      ],
      "alwaysOutputData": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "4",
          "name": "Header Auth account"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "url": "=https://mycompany.myfreshworks.com/crm/sales/api/lookup?q={{$node[\"Google Sheets\"].json[\"id\"]}}&f=external_id&entities=contact",
        "jsonParameters": true,
        "options": {
          "fullResponse": false
        }
      },
      "name": "Lookup Contacts (external id based)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1040,
        80
      ],
      "alwaysOutputData": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "4",
          "name": "Header Auth account"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "string": [],
          "number": [
            {
              "value1": "={{$node[\"Lookup Contacts (external id based)\"].json[\"contacts\"][\"contacts\"][0][\"external_id\"]}}",
              "operation": "larger",
              "value2": 1
            }
          ],
          "boolean": []
        }
      },
      "name": "IF Lookup Based on External ID Empty",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        1200,
        80
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Create Contacts\"].json[\"error\"][\"name\"]}}",
              "value2": "Error"
            }
          ]
        }
      },
      "name": "IF Create Contacts is Error",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        860,
        260
      ]
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "requestMethod": "PUT",
        "url": "=https://mycompany.myfreshworks.com/crm/sales/api/contacts/{{$node[\"Lookup Contacts (email based)\"].json[\"contacts\"][\"contacts\"][0][\"external_id\"]}}",
        "jsonParameters": true,
        "options": {
          "fullResponse": true
        },
        "bodyParametersJson": "={\n\"contact\": {\n\"first_name\": \"{{$node[\"Google Sheets\"].json[\"first_name\"]}}\",\n\"last_name\": \"{{$node[\"Google Sheets\"].json[\"last_name\"]}}\",\n\"avatar\": null,\n\"job_title\": \"\",\n\"city\": \"{{$node[\"Google Sheets\"].json[\"city\"]}}\",\n\"country\": \"{{$node[\"Google Sheets\"].json[\"nationality\"]}}\",\n\"email\": \"{{$node[\"Google Sheets\"].json[\"email\"]}}\",\n\"work_number\": \"\",\n\"mobile_number\": \"{{$node[\"Google Sheets\"].json[\"Phone Number Formatted\"]}}\",\n\"custom_field\": {\n\"cf_contact_type\": \"Reseller\",\n\"cf_agent_manager\": \"{{$node[\"Google Sheets\"].json[\"rdz_agent_email\"]}}\",\n\"cf_source_helper\": \"\",\n\"cf_sales_owner_helper\": \"\",\n\"cf_status_helper\": \"Onboarded\",\n\"cf_life_cycle_stage_helper\": \"Customer\"\n}\n}\n}"
      },
      "name": "Update Contacts (external id empty, using email based)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        1840,
        240
      ],
      "alwaysOutputData": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "4",
          "name": "Header Auth account"
        }
      },
      "continueOnFail": true
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{$node[\"Update Contacts (external id not empty)\"].json[\"error\"][\"name\"]}}",
              "value2": "Error"
            }
          ]
        }
      },
      "name": "IF Update Error",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        2020,
        40
      ]
    },
    {
      "parameters": {},
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        1440,
        -40
      ],
      "webhookId": "591aee35-f840-4eb0-ae5f-03bf698bd570"
    },
    {
      "parameters": {},
      "name": "Wait1",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1,
      "position": [
        1440,
        200
      ],
      "webhookId": "5e2bf05a-e4e5-4371-8a2e-7f6147f60b44"
    }
  ],
  "connections": {
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Create Contacts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Contacts": {
      "main": [
        [
          {
            "node": "IF Create Contacts is Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Cron": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Contacts (external id not empty)": {
      "main": [
        [
          {
            "node": "IF Update Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Contacts (email based)": {
      "main": [
        [
          {
            "node": "Update Contacts (external id empty, using email based)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Lookup Contacts (external id based)": {
      "main": [
        [
          {
            "node": "IF Lookup Based on External ID Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Lookup Based on External ID Empty": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Create Contacts is Error": {
      "main": [
        [
          {
            "node": "Lookup Contacts (external id based)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update Contacts (external id empty, using email based)": {
      "main": [
        [
          {
            "node": "IF Update Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Update Contacts (external id not empty)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait1": {
      "main": [
        [
          {
            "node": "Lookup Contacts (email based)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Information on your n8n setup

  • **n8n version: [email protected]
  • **Database you’re using:SQLite
  • **Running n8n with the execution process :own
  • **Running n8n via :docker

Hi @Farhienza_Haikal,

if you want to avoid overloading an API you’re consuming through the HTTP Request node, the easiest way would be to configure the node’s batch settings (Batch Interval and Batch Size)). So if you know your target API allows 1,000 executions per hour (or 16 per minute), I’d set these values accordingly:
image

Unless you have other workflows (or services) calling the API at the same time (in which case you’d need to adjust the aforementioned values), the above should do the trick without the need for Wait nodes or loops.

Let me know if you run into any trouble with this!