AutomationFlowsGeneral › Execute Adhoc Queries via n8n Sub-Workflow

Execute Adhoc Queries via n8n Sub-Workflow

Original n8n title: Sub-adhoc Query

Sub-Adhoc Query. Uses executeWorkflowTrigger, executeWorkflow. Event-driven trigger; 4 nodes.

Event trigger★★★★☆ complexity4 nodesExecute Workflow Trigger
General Trigger: Event Nodes: 4 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Sub-Adhoc Query",
  "nodes": [
    {
      "parameters": {
        "inputSource": "passthrough"
      },
      "id": "executeWorkflowTrigger",
      "name": "When Called by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// Transform sub-workflow input to adhoc-query webhook format\nconst input = $input.item.json;\n\n// Support both formats:\n// 1. { body: { query: \"...\", params: {} } }\n// 2. { query: \"...\", params: {} }\nconst query = input.body?.query || input.query;\nconst params = input.body?.params || input.params || {};\nconst agent = input.agent || 'sub-workflow';\nconst description = input.description || 'Sub-workflow query execution';\n\nif (!query) {\n  throw new Error('Query is required. Received: ' + JSON.stringify(input));\n}\n\nreturn [{\n  json: {\n    query: query,\n    params: params,\n    agent: agent,\n    description: description\n  }\n}];"
      },
      "id": "prepare-request",
      "name": "Prepare HTTP Request",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "workflowId": {
          "__rl": true,
          "value": "ssu8GdKQEJM3KbGx",
          "mode": "id"
        },
        "workflowInputs": {
          "mappingMode": "passthrough"
        },
        "options": {}
      },
      "id": "call-adhoc-query",
      "name": "Call Adhoc Query Sub-Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "typeVersion": 1.3,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "// When adhoc-query is called as sub-workflow via executeWorkflow,\n// it returns: { success, results, ... } directly (already normalized by Format Response node)\n// Just pass it through - no extraction needed\nreturn [$input.item];"
      },
      "id": "extract-response",
      "name": "Pass Through Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        300
      ]
    }
  ],
  "connections": {
    "When Called by Another Workflow": {
      "main": [
        [
          {
            "node": "Prepare HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare HTTP Request": {
      "main": [
        [
          {
            "node": "Call Adhoc Query Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Adhoc Query Sub-Workflow": {
      "main": [
        [
          {
            "node": "Pass Through Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "availableInMCP": false
  },
  "staticData": null,
  "tags": []
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Sub-Adhoc Query. Uses executeWorkflowTrigger, executeWorkflow. Event-driven trigger; 4 nodes.

Source: https://github.com/pchambless/wf-monorepo/blob/47cd16469735c59a12b7c76e2552861f899e335d/.n8n/workflows/sub-adhoc-query.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Reagendamiento. Uses executeWorkflowTrigger, redis, n8n-nodes-evolution-api, dataTable. Event-driven trigger; 73 nodes.

Execute Workflow Trigger, Redis, N8N Nodes Evolution Api +2
General

Agendamiento. Uses n8n-nodes-evolution-api, redis, dataTable, executeWorkflowTrigger. Event-driven trigger; 60 nodes.

N8N Nodes Evolution Api, Redis, Data Table +2
General

Prevent concurrent workflow runs using Redis. Uses executeWorkflowTrigger, manualTrigger, stickyNote, executeWorkflow. Event-driven trigger; 43 nodes.

Execute Workflow Trigger, Redis, Stop And Error
General

This workflow sets a small "lock" value in Redis so that only one copy of a long job can run at the same time. If another trigger fires while the job is still busy, the workflow sees the lock, stops e

Execute Workflow Trigger, Redis, Stop And Error
General

Reputation Engine — Site Refresh. Uses httpRequest, executeWorkflowTrigger. Event-driven trigger; 35 nodes.

HTTP Request, Execute Workflow Trigger