# Your First Workflow: Auto-Log Messages

In this tutorial, you will build a workflow that takes text input, formats it with a template, and logs the result to Drupal's watchdog. This covers the fundamentals you need to build any FlowDrop workflow.

## What You Will Learn

- Adding and configuring multiple nodes
- Connecting data ports between nodes
- Understanding how data flows through edges
- Executing a workflow and inspecting results

## Prerequisites

- FlowDrop installed with core modules enabled ([Installation guide](installation.md))

---

## Step 1: Create a New Workflow

1. Navigate to **Administration > FlowDrop > Workflows** (`/admin/flowdrop/workflows`).
2. Click **+ Add Workflow**.
3. Enter the label **"Article Logger"** and click **Save**.

![Creating the Article Logger workflow](../screenshots/add-workflow-form.png)

## Step 2: Open the Visual Editor

From the workflow listing, click the dropdown on your "Article Logger" workflow and select **Open in Editor**.

## Step 3: Add a TextInput Node

1. Click the **+** button to open the node palette.
2. Find **Text Input** under the **Text & Output** category (or search for it).
3. Click to add it to the canvas.
4. Click on the node to open its configuration panel.
5. Enter some sample text, e.g., `Breaking news: FlowDrop is live!`

![TextInput node on canvas](../screenshots/textinput-config-panel.png)

The TextInput node provides a simple text value as output. It is the starting point for many workflows.

## Step 4: Add a PromptTemplate Node

1. Click **+** again and add a **Prompt Template** node.
2. Click on the node to configure it.
3. In the template field, enter: `Article received: {{ text }}`

![PromptTemplate configuration](../screenshots/node-config-panel.png)

!!! info "Template Syntax"
    PromptTemplate uses Twig syntax. Use `{{ variable_name }}` to insert a value. The variable name must match the name of an input port. When data flows into the port, it replaces the placeholder in the template.

## Step 5: Add a Logger Node

1. Click **+** and add a **Logger** node.

![Logger node on canvas](../screenshots/two-nodes-unconnected.png)

The Logger node writes its input to Drupal's watchdog log, which you can view at **Reports > Recent log messages**.

## Step 6: Connect the Nodes

Draw edges to connect the data flow:

1. **TextInput → PromptTemplate**: Drag from the TextInput output port to the PromptTemplate's `text` input port.
2. **PromptTemplate → Logger**: Drag from the PromptTemplate output port to the Logger's `message` input port.

![Complete workflow with three connected nodes](../screenshots/visual-editor-workflow.png)

Your workflow now reads: _"Take the text input, insert it into the template, and log the result."_

## Step 7: Save and Execute

1. Click **Save** in the editor toolbar.
2. Navigate to **Administration > FlowDrop > Execute** (`/admin/flowdrop/execute`).
3. Click **Execute Workflow**.
4. Select the **Article Logger** workflow from the dropdown.
5. Choose the **Synchronous** orchestrator.
6. Click **Execute**.

The pipeline result page shows the execution status. Each node appears with its status (completed, failed, etc.) and you can click on individual jobs to see their input and output data.

![Successful execution result](../screenshots/pipeline-detail.png)

## Step 8: Check the Logs

Navigate to **Reports > Recent log messages** (`/admin/reports/dblog`) and look for entries from FlowDrop. You should see your formatted message: `Article received: Breaking news: FlowDrop is live!`

![Log entry in Drupal watchdog](../screenshots/drupal-logs-flowdrop.png)

---

## Understanding What Happened

When you executed the workflow, FlowDrop:

1. **Resolved execution order** — determined that TextInput has no dependencies and runs first, then PromptTemplate, then Logger.
2. **Executed TextInput** — produced the text value you entered.
3. **Passed data via edges** — the text flowed through the edge into PromptTemplate's `text` input port.
4. **Executed PromptTemplate** — replaced `{{text}}` with the actual value, producing the formatted string.
5. **Passed data again** — the formatted string flowed into Logger's `message` input port.
6. **Executed Logger** — wrote the message to Drupal's watchdog log.

Each node execution was tracked as a **Job** within a **Pipeline** (one complete run of the workflow).

## Challenge: Extend the Workflow

Try adding branching logic between the PromptTemplate and Logger using an **IfElse** node:

1. Remove the existing edge between PromptTemplate and Logger (select the edge and delete it).
2. Click **+** and add an **IfElse** node from the **Control Flow** category.
3. Click on the IfElse node to open its configuration panel. Set the **condition** to check whether the input text contains a specific word (e.g., `Breaking`).
4. Connect the PromptTemplate output port to the IfElse node's input port.
5. Connect the IfElse node's **True** branch output to the Logger node's input.
6. Add a second **Logger** node and connect the IfElse node's **False** branch output to it.
7. Save and execute the workflow.

You should see only the Logger on the "True" branch execute, since your text contains "Breaking". Try changing the TextInput value to something without that word and re-execute — the other branch should fire instead.

This introduces branching logic — a core concept for building real-world workflows. See [Connecting Nodes](../guide/workflows/connecting-nodes.md) for more on gateway nodes and branches.

## Next Steps

- **[Key Concepts](concepts.md)** — Understand the terminology and architecture
- **[Visual Editor Guide](../guide/workflows/visual-editor.md)** — Learn all editor features
- **[Connecting Nodes](../guide/workflows/connecting-nodes.md)** — Deep dive into ports, edges, and data types
