> For the complete documentation index, see [llms.txt](https://docs.diaflow.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.diaflow.io/workflow-builder/nodes/apps/python.md).

# Python

<figure><img src="/files/URJCRvld8PtrXRtQf4Ai" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2mIWioZJkDvvl2ZGYb8s" alt=""><figcaption></figcaption></figure>

## Description

**What it does**: This allows you to run Python scripts inside your workflow, giving your chatbot the ability to process data, perform calculations, and even customize responses.

**When to use it?**&#x20;

* **Complex Data Transformations**: Perform custom data manipulations or calculations that aren't directly available in other nodes.
* **Integrate with Custom APIs & Services**: Connect to APIs or services that don't have dedicated Diaflow nodes yet using Python's vast library ecosystem.
* **Advanced Logic & Decision Making**: Implement intricate decision-making processes or custom algorithms within your workflows using Python code.
* **Extend Diaflow Functionality**: Effectively create your own mini-nodes by encapsulating custom Python scripts within a reusable Diaflow node.

## Component settings

| Parameter Name | Description                                               |
| -------------- | --------------------------------------------------------- |
| Method         | <p>Options:<br>- Manual Script<br>- Python File</p>       |
| Code editor    | Input your code editor when choose method = Manual Script |
| Upload File    | Upload File Python when choose method = Python File       |

## Referencing Data from Previous Nodes

To access the output of a previous node inside your Python script, use the **template syntax**:

{{nodeName.output}}

* `nodeName`: The system name (ID) of the node you want to reference (e.g. `weather-0`, `http-1`, etc.).
* `.output`: Refers to the full output object from that node.

**Example usage:**

def run():\
return {{weather-0.output}}

return run()

<figure><img src="/files/waPK6Gbwp9CnpVG3LrXp" alt=""><figcaption></figcaption></figure>

This script will pass the entire output from the node named `weather-0` directly into the Python logic.

**Note:**

* The `{{ }}` Syntax is evaluated **before** the Python code runs. It injects real JSON data at runtime.
* Make sure the referenced node has already executed successfully and produced output.
