|
| 1 | +--- |
| 2 | +sidebar_position: 1 |
| 3 | +title: Creating Your First Workflow |
| 4 | +description: A step-by-step guide for defining, executing, and validating a basic "Hello World" workflow in FlowSynx. |
| 5 | +--- |
| 6 | + |
| 7 | +# Creating Your First Workflow |
| 8 | +This guide provides a structured introduction to creating and executing a basic workflow in FlowSynx. |
| 9 | +The example demonstrates how to define workflow components in JSON, initiate an execution using the CLI or API, and review the resulting output. |
| 10 | + |
| 11 | +## Objectives |
| 12 | + |
| 13 | +By the end of this guide, you will understand: |
| 14 | + |
| 15 | +- How to construct a minimal JSON-based workflow definition |
| 16 | +- How tasks and dependencies form a directed acyclic graph (DAG) |
| 17 | +- How to execute workflows using the Dashboard, CLI, or REST API |
| 18 | +- How to verify execution status and inspect generated output |
| 19 | + |
| 20 | +## 1. Defining a Basic “Hello World” Workflow |
| 21 | + |
| 22 | +FlowSynx workflows are defined using a structured JSON schema. A workflow generally contains: |
| 23 | + |
| 24 | +- **Metadata** — high-level information such as the workflow name and description |
| 25 | +- **Tasks** — individual units of execution, typically backed by plugins |
| 26 | +- **DAG Definition** — declaring dependencies among tasks |
| 27 | +- **Execution Parameters** — plugin settings, retry options, and other controls |
| 28 | + |
| 29 | +The following example represents a minimal workflow containing a single task that writes a text file to the local file system. |
| 30 | + |
| 31 | +### Example: Minimal Hello World Workflow |
| 32 | + |
| 33 | +```json |
| 34 | +{ |
| 35 | + "name": "Hello World Workflow", |
| 36 | + "description": "A minimal FlowSynx workflow example", |
| 37 | + "tasks": [ |
| 38 | + { |
| 39 | + "name": "Hello world", |
| 40 | + "type": "", |
| 41 | + "parameters": { |
| 42 | + "operation": "write", |
| 43 | + "path": "results/test.txt", |
| 44 | + "data": "Hello, FlowSynx!", |
| 45 | + "overwrite": false |
| 46 | + }, |
| 47 | + "dependencies": [], |
| 48 | + } |
| 49 | + ] |
| 50 | +} |
| 51 | +``` |
| 52 | + |
| 53 | +Save the workflow as: |
| 54 | + |
| 55 | +``` |
| 56 | +hello-world.json |
| 57 | +``` |
| 58 | + |
| 59 | +## 2. Workflow Structure Overview |
| 60 | + |
| 61 | +This section describes how FlowSynx interprets the key components of the workflow. |
| 62 | + |
| 63 | +#### name |
| 64 | + |
| 65 | +Specifies the display name of the workflow. This value is shown in the Dashboard, logs, and execution listings. |
| 66 | + |
| 67 | +```json |
| 68 | +"name": "Hello World Workflow" |
| 69 | +``` |
| 70 | + |
| 71 | +#### tasks |
| 72 | + |
| 73 | +The tasks array defines all executable units. Each task includes: |
| 74 | + |
| 75 | +- `name`: a unique identifier within the workflow |
| 76 | +- `type`: the plugin or built-in handler to execute |
| 77 | +- `parameters`: input values required by the specified plugin |
| 78 | +- `dependencies`: optional list of task names indicating execution order |
| 79 | + |
| 80 | +In this example: |
| 81 | +- `type` is empty (`""`), which instructs FlowSynx to use the built-in Local File System plugin. |
| 82 | +- `dependencies` is empty, so the task executes immediately. |
| 83 | + |
| 84 | +## 3. Executing the Workflow |
| 85 | + |
| 86 | +Workflows may be executed through several FlowSynx components: |
| 87 | + |
| 88 | +- The FlowSynx Dashboard |
| 89 | +- The API |
| 90 | +- The CLI (optional) |
| 91 | +- Triggers and automation rules |
| 92 | + |
| 93 | +The following sections demonstrate execution using the CLI and the REST API. |
| 94 | + |
| 95 | +### 3.1 Executing via CLI (flowctl) |
| 96 | + |
| 97 | +Ensure the flowctl command-line tool is installed. For installation instructions, refer to: |
| 98 | +[Install Flowctl](/docs/getting-started/flowctl-based-installation) |
| 99 | + |
| 100 | +#### Run from a JSON file |
| 101 | + |
| 102 | +``` |
| 103 | +flowctl workflows executions execute -f ./hello-world.json |
| 104 | +``` |
| 105 | + |
| 106 | +### 3.2 Executing via REST API |
| 107 | + |
| 108 | +The REST API provides full programmatic control for managing workflows. |
| 109 | +Any standard HTTP client (Postman, HTTPie, curl, etc.) may be used. |
| 110 | + |
| 111 | +For detailed API documentation, refer to: |
| 112 | +[Add new Workflow](/docs/reference/flowsynx/api/workflow#add-new-workflow) |
| 113 | + |
| 114 | +#### Step 1: Add the Workflow |
| 115 | + |
| 116 | +##### Endpoint |
| 117 | + |
| 118 | +``` |
| 119 | +POST http://localhost:6262/workflows/Add |
| 120 | +Content-Type: application/json |
| 121 | +``` |
| 122 | + |
| 123 | +##### Request Body |
| 124 | +Use the same JSON used in the [hello-world-workflow](/docs/getting-started/quickstarts/creating-your-first-workflow#example-hello-world-workflow-minimal) |
| 125 | + |
| 126 | +##### Example Response |
| 127 | + |
| 128 | +```json |
| 129 | +{ |
| 130 | + "data": { |
| 131 | + "id": "586bc7b0-499b-4b01-9510-93ac643ad8bb", |
| 132 | + "name": "Hello World Workflow" |
| 133 | + }, |
| 134 | + "messages": [ |
| 135 | + "The workflow has been added successfully." |
| 136 | + ], |
| 137 | + "succeeded": true, |
| 138 | + "generatedAtUtc": "2025-11-15T14:40:27Z" |
| 139 | +} |
| 140 | +``` |
| 141 | + |
| 142 | +Record the workflow `id` value — you will need it to execute the workflow. |
| 143 | + |
| 144 | +#### Step 2: Execute the Workflow |
| 145 | + |
| 146 | +##### Endpoint |
| 147 | + |
| 148 | +``` |
| 149 | +POST http://localhost:6262/workflows/<UUID>/executions |
| 150 | +Content-Type: application/json |
| 151 | +``` |
| 152 | + |
| 153 | +##### Example Response |
| 154 | + |
| 155 | +```json |
| 156 | +{ |
| 157 | + "data": { |
| 158 | + "workflowId": "586bc7b0-499b-4b01-9510-93ac643ad8bb", |
| 159 | + "executionId": "0878cda6-6df8-44d0-9e4b-1ecbe5c190f1", |
| 160 | + "startedAt": "2025-11-15T14:41:06Z" |
| 161 | + }, |
| 162 | + "messages": [ |
| 163 | + "Workflow '586bc7b0-499b-4b01-9510-93ac643ad8bb' executed successfully!" |
| 164 | + ], |
| 165 | + "succeeded": true, |
| 166 | + "generatedAtUtc": "2025-11-15T14:41:06Z" |
| 167 | +} |
| 168 | +``` |
| 169 | + |
| 170 | +### 3.3 Viewing Results |
| 171 | + |
| 172 | +After execution completes, navigate to the `results/` directory. |
| 173 | +You should find the generated file: |
| 174 | + |
| 175 | +``` |
| 176 | +results/test.txt |
| 177 | +``` |
| 178 | + |
| 179 | +The file should contain the following content: |
| 180 | + |
| 181 | +``` |
| 182 | +Hello, FlowSynx! |
| 183 | +``` |
0 commit comments