Skip to main content

Run Apache Airflow DAG and retrieve XCom value

Workflow preview

Workflow preview
100%
Run Apache Airflow DAG and retrieve XCom value preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Run Apache Airflow DAG and Retrieve XCom Value What this workflow does This workflow integrates the Apache Airflow API [DAGRun](https://airflow.apache.org/docs/apache airflow/2.10.5/stable rest api...

Best for

  • Engineering automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.stopanderror, n8n-nodes-base.if, n8n-nodes-base.switch, n8n-nodes-base.executeworkflowtrigger, n8n-nodes-base.wait, n8n-nodes-base.set

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Antonio Cheong.

Original n8n.io source

1.1 Workflow description

Title
Run Apache Airflow DAG and retrieve XCom value
Workflow name
Run Apache Airflow DAG and retrieve XCom value

Run Apache Airflow DAG and Retrieve XCom Value

What this workflow does

This workflow integrates the Apache Airflow API DAGRun and XCom. It enables n8n to trigger Airflow DAGs and retrieve the execution results.

Preparation:

  1. Update Airflow API Link Prefix

    • Navigate to the airflow-api node.
    • Update the prefix of the Airflow API link in the format: http(s)://ip:port.
    • Example: https://airflow.example.com
  2. Configure Authentication

    • Go to the Airflow: dag_run node.
    • Update the Basic Auth credentials with your Airflow username and password.
    • Repeat this step for Airflow: dag_run - state and Airflow: dag_run - get result nodes.

    Security Note: Using Basic Authentication requires storing credentials in plaintext. If possible, consider using API Keys or Tokens for enhanced security.

    • An example is setting Airflow's API Authentication to basic_auth. Choose other authentication methods if needed.
    • Ensure the user account has the following permissions: can create on DAG Runs, can read on DAG Runs, can read on XComs, can edit on DAGs, and can read on DAGs.

How to Use:

To execute this workflow, use the Execute Sub-workflow node with the following input parameters:

  • dag_id: The DAG ID (name) in Airflow that you want to trigger.
  • task_id: The Task ID (name) from which you want to retrieve the XCom return_value.
  • conf: Input data for the Airflow DAG run.
  • wait: Delay (in seconds) between each Airflow: dag_run - state check.
  • wait_time: The maximum time (in seconds) to wait for Airflow: dag_run - state before returning an error.

Output:

  • The workflow returns the XCom result from Airflow: dag_run - get result.
  • The XCom return_value is stored in the value field.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Airflow: dag_run

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 2 - Airflow: dag_run - state

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 3 - count

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 4 - dag run fail

Type / Role
n8n-nodes-base.stopAndError - stopAndError
Config choices
Version 1

Block 5 - if state == queued

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 6 - dag run wait too long

Type / Role
n8n-nodes-base.stopAndError - stopAndError
Config choices
Version 1

Block 7 - Airflow: dag_run - get result

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 8 - Switch: state

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 9 - in data

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1.1

Block 10 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 11 - If count > wait_time

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 12 - airflow-api

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

3. Summary Table

Workflow Run Apache Airflow DAG and retrieve XCom value
Complexity intermediate
Nodes 12
Categories Engineering
Author Antonio Cheong
Published 27 Feb 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/3026/3026.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Run Apache Airflow DAG and retrieve XCom value do?

Run Apache Airflow DAG and Retrieve XCom Value What this workflow does This workflow integrates the Apache Airflow API [DAGRun](https://airflow.apache.org/docs/apache airflow/2.10.5/stable rest api...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.