Your First Flow
Welcome to Jetty! In this guide, you'll create your first workflow using a simple echo task that demonstrates the core concepts of flows, steps, and path expressions. By the end of this tutorial, you'll understand how to:
- Create a new flow in the Jetty interface
- Configure workflow steps and activities
- Use path expressions to pass data between components
- Run your workflow and view the results
What We're Building
We'll create a simple "echo" workflow that takes a text input and outputs the same text. While basic, this example demonstrates all the fundamental concepts you'll use in more complex workflows.
Here's the complete flow configuration we'll be creating:
{
"init_params": {
"text": "hello, Jetty!"
},
"step_configs": {
"hello": {
"activity": "text_echo",
"text_path": "init_params.text"
}
},
"steps": [
"hello"
]
}
Understanding the Flow Structure
Before we create the flow, let's understand each part:
init_params
Initial parameters that provide input data to your workflow. In our case:
"text": "hello, Jetty!"- This sets up our input text that will be echoed
step_configs
Configuration for each step in your workflow. Our hello step includes:
"activity": "text_echo"- Specifies which activity function to run"text_path": "init_params.text"- A path expression that tells the step where to find its input data
steps
An ordered list of step names to execute:
["hello"]- Execute only the "hello" step we configured above
Path Expressions Explained
The "text_path": "init_params.text" is a path expression - a powerful feature that lets you reference data from different parts of your workflow.
Path expressions follow the pattern: source.path.to.value
init_params.text- Get thetextvalue from the initial parametersstep_name.outputs.result- Get a result from a previous step's outputprevious_step.inputs.prompt- Reference what was passed to a previous step
In our echo example, init_params.text retrieves the "hello, Jetty!" string we defined in the initialization parameters and passes it to the text_echo activity.
Step 1: Create a New Task
- Navigate to Jetty and log in to your account
- Click "Create Task" to start building your first workflow
- Fill in the Basic Information:
- Collection: Leave as your default collection (e.g., "jettyiodev")
- Task Name: Enter
echo-tutorial - Version: Leave as
1.0.0 - Description: Enter "My first echo workflow to learn Jetty basics"
Step 2: Configure the Workflow
In the Workflow Configuration section, you'll see a JSON editor. Replace the default content with our echo flow configuration:
{
"init_params": {
"text": "hello, Jetty!"
},
"step_configs": {
"hello": {
"activity": "text_echo",
"text_path": "init_params.text"
}
},
"steps": [
"hello"
]
}
What This Configuration Does:
- Sets up input data - The
init_paramssection defines our initial text - Configures a step - The
hellostep uses thetext_echoactivity - Uses a path expression -
text_pathtells the echo activity to get its input frominit_params.text - Defines execution order - The
stepsarray specifies that only thehellostep should run
Step 3: Save and Run Your Flow
- Click "Create Task" to save your workflow
- Navigate to the "Run Flow" tab
- Review the run parameters - You should see:
{
"text": "hello, Jetty!"
}
# Sync execution (waits for completion)
curl -X POST "$JETTY_API_URL/api/v1/run-sync/jettyiodev/echo-tutorial" \
-H "Authorization: Bearer $JETTY_API_TOKEN" \
-F 'init_params={"text": "hello, Jetty!"}'
# Async execution (returns immediately)
curl -X POST "$JETTY_API_URL/api/v1/run/jettyiodev/echo-tutorial" \
-H "Authorization: Bearer $JETTY_API_TOKEN" \
-F 'init_params={"text": "hello, Jetty!"}'
This makes it easy to integrate Jetty workflows into your applications, scripts, and automation pipelines.