AI Chatbot & Automation

Delay / Sleep Node

A Delay/Sleep Node pauses workflow execution for a set time or until a condition is met, commonly used to space out API requests and prevent system overload.

Delay Node Sleep Node Automation Workflows AI Chatbot Workflow Orchestration
Created: December 18, 2025

What Is a Delay / Sleep Node?

A Delay or Sleep Node is a component that introduces a pause in execution for a configurable period or until a condition is fulfilled. In code (JavaScript/Node.js), it’s implemented as a function (sleep, delay, etc.) that suspends further execution in a non-blocking way, typically using Promises and async/await. In workflow automation tools (n8n, Make, AWS SSM, Cognigy, Jira), it’s a visual node/block that can be configured for a specific time or event.

Why pause execution? To space out API calls and prevent rate limiting, wait for external processes (e.g., file upload, payment confirmation), orchestrate workflows with time-based or event-based conditions, simulate slow operations or network latency in testing, implement retries with exponential backoff, and allow time for data synchronization before continuing.

Purpose and Use Cases

When and Why Delay/Sleep Nodes Are Used

API Rate Limiting: Prevent exceeding quotas by spacing requests.
Workflow Orchestration: Ensure steps occur in a specific order with controlled intervals.
Polling/Condition Waits: Pause until an external event or condition is met.
Testing & Simulation: Simulate slow operations or network latency.
Retry & Backoff: Implement retries with exponential backoff.
Buffer for External Systems: Allow time for data sync before continuing.

Examples:

  • Waiting several seconds between notification emails
  • Pausing until a file upload is confirmed
  • Polling an API every minute until status is “complete”

How Delay / Sleep Is Implemented

JavaScript & Node.js

JavaScript and Node.js are single-threaded, non-blocking environments. There is no built-in sleep() function. The standard pattern is to use asynchronous approaches (Promises, async/await) to insert delays without blocking the event loop.

Community best practice:

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

Modern sleep function:

async function main() {
  console.log('Start');
  await sleep(2000);
  console.log('End after 2 seconds');
}

One-liner:

await new Promise(resolve => setTimeout(resolve, 5000));

Automation Platforms

Workflow tools provide visual Delay/Sleep nodes with configuration options:

  • Duration: Fixed time (seconds, minutes, hours, ISO 8601)
  • Condition/Event-based: Wait until a logical condition is true
  • Timeouts: Prevent indefinite waits
  • Exponential Backoff: For intelligent polling or retries

Implementation Techniques in JavaScript/Node.js

setTimeout with Callbacks

Pattern:

function sleep(ms, callback) {
  setTimeout(callback, ms);
}
console.log('Start');
sleep(2000, () => console.log('End after 2 seconds'));

Drawback: Callback hell, difficult to chain sequential operations.

Promises & async/await

Modern approach:

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
  console.log('Start');
  await sleep(2000);
  console.log('End after 2 seconds');
}
main();

Pros: Clean, readable, non-blocking, easy to compose.

Third-Party Packages

Example (sleep-promise):

const sleep = require('sleep-promise');
await sleep(5000); // Wait for 5 seconds

Pros: Features like cancellation, timeouts, better cross-platform support.

Blocking & Synchronous Sleep Methods

Not recommended for production. Blocks the entire event loop, degrading all concurrent tasks.

Example (Node.js, Unix only):

const { execSync } = require('child_process');
function sleep(seconds) {
  execSync(`sleep ${seconds}`);
}

Advanced: AbortController, Timeouts, and Intelligent Polling

Cancelable sleep:

const sleep = (ms, { signal, timeout } = {}) => {
  return new Promise((resolve, reject) => {
    const timer = setTimeout(resolve, ms);
    if (signal) {
      signal.addEventListener('abort', () => {
        clearTimeout(timer);
        reject(new Error('Sleep aborted'));
      });
    }
    if (timeout) {
      setTimeout(() => reject(new Error('Timeout')), timeout);
    }
  });
};

Intelligent polling (exponential backoff):

let interval = 1000, maxInterval = 30000;
while (!conditionMet) {
  await sleep(interval);
  if (checkCondition()) break;
  interval = Math.min(interval * 2, maxInterval);
}

Delay/Sleep Nodes in Automation Workflows

AWS SSM (Systems Manager) Automation

Node: aws:sleep
Configuration: Duration (ISO 8601, e.g., PT10M) or Timestamp (e.g., 2020-01-01T01:00:00Z)
Max delay: 7 days (604799 seconds)

Example:

name: sleep
action: aws:sleep
inputs:
  Duration: PT10M

Cognigy

Node: Sleep Node
Function: Pauses chatbot flow for a set duration
Configuration: Duration in ms, seconds, etc.

n8n & Make

Node: Delay/Sleep/Wait Node
Configuration: Duration, units, and in some cases, event-based waits

Best Practices:

  • Use Delay/Wait nodes sparingly to conserve execution resources
  • For processing arrays with delays, handle each item with a loop and insert a delay between iterations
  • Consider parallel execution implications

Jira Automation

Component: Delay / Pause / Wait Step
Function: Inserts a pause to prevent race conditions and sequence automation reliably
Configuration: Duration, or stacking multiple delays for longer waits

Best Practices:

  • Be aware that branches in Jira automation may execute in parallel
  • Serializing actions with delays or splitting into separate rules may be necessary

Best Practices

1. Always use non-blocking delays (Promises, async/await, or platform-native delay nodes)
2. Avoid synchronous/blocking sleep in servers or production environments
3. Use timeouts to prevent indefinite waits
4. Apply exponential backoff for polling external systems or retries
5. Limit the scope of delays to only where necessary
6. Support cancellation (e.g., with AbortController in JS, or abort/timeout configs in workflows)
7. Avoid excessive delays to conserve execution resources and avoid hitting quotas
8. Distribute delays in platforms like n8n to avoid bottlenecks and resource contention

Troubleshooting / FAQ

Why doesn’t Node.js have a built-in sleep() function?
Node.js is designed for asynchronous, non-blocking I/O. Blocking the event loop would degrade all concurrent tasks. Use async/await or Promises.

My delay node seems to block other flows!
Check for accidental use of blocking sleep (e.g., while loops or execSync in Node.js). In automation platforms, avoid excessive or long delays in shared (single-threaded) environments.

How do I wait for a condition, not just a fixed time?
Use a polling loop with increasing delays (exponential backoff), or use “wait until” nodes if your platform supports it.

Can I cancel a delay/sleep operation?
In modern JavaScript, use AbortController. In workflow tools, look for nodes supporting abort/timeout.

Parameter Table: Delay/Sleep Node (Generalized)

ParameterTypeDescriptionExample Value
DurationNumber/StringHow long to delay (ms/s/min/h, ISO 8601)5000, "PT10M"
ConditionFunction/StringOptional: Wait until condition is metstatus === "done"
Max WaitNumberMaximum time to wait60000 (1 minute)
Abort SignalObjectFor JS: AbortController.signal-
TimeoutNumberTimeout for polling or waiting30000 (30 seconds)

Example Use Cases

Chatbot Flow

Scenario: Wait 3 seconds after user input before responding to simulate processing.
How: Place a “Sleep” node (e.g., 3000 ms) in Cognigy or n8n.

API Rate Limiting

Scenario: Integration sends requests with 1 req/sec limit.
How: Use await sleep(1000) in Node.js, or a 1-second Delay node in automation.

Intelligent Polling (Event Wait)

Scenario: Wait for payment confirmation, but avoid excessive API calls.
How: Use exponential backoff polling loop:

let delay = 1000, maxDelay = 30000;
while (!(await isConfirmed())) {
  await sleep(delay);
  delay = Math.min(delay * 2, maxDelay);
}

Summary

A Delay/Sleep Node is a fundamental building block for orchestrating time-based and conditional flows in both code and modern workflow automation platforms. The current best practice in JavaScript is to use Promises and async/await for non-blocking, readable code. In automation platforms, delay/wait nodes should be used judiciously—configured to maximize reliability and efficiency, and always with an eye toward resource management and clarity of execution.

References

Related Terms

Aggregator

A node that collects outputs from multiple execution paths or loops and combines them into a single ...

ChatGPT

An AI assistant that understands natural conversation and can answer questions, write content, help ...

AI Chatbot

Explore AI chatbots: learn what they are, how they work with NLP, NLU, and LLMs, their types, benefi...

Botpress

A platform for building AI chatbots using a visual drag-and-drop editor, enabling businesses to auto...

×
Contact Us Contact