Integration with Control Flow Example
Connecting two API endpoints together
Overview
In this guide, we'll show you how to extend a simple integration by adding query params, dynamic headers, and control flow to a multi-step workflow execution. We'll use Laminar Keywords to run workflows conditionally.
Data Transformation Examples
JavaScript Version
JQ Version
Key Components
Data Extraction: Access data from previous steps using
step_1.data.users
Filtering: Filter users based on spending threshold
Dynamic Parameters: Add query params and headers based on user data
Workflow Execution: Use
lam.workflowId
to specify target workflow
Best Practices
Use meaningful variable names
Keep transformations focused on a single purpose
Add comments for complex logic
Test transformations with sample data
Watch the demo
Video outline
In this video, we show you how to extend the simple integration example. We'll be adding query params, dynamic headers, and control flow to the our multi-step workflow execution. We'll use a Laminar Keyword to run a workflow depending on if a condition is met.
Objective
To send data individually for each user by making a POST request to a destination, dynamically adding query parameters and headers, and incorporating control flow in the workflow execution.
Key Steps
Create a new flow in Laminar named "Determine if should send user" with no source to execute control flow logic using a Laminar Keyword.
Use jq to extract data from the first step by accessing the key:
.step_1.data.users
.Pass the users array to a new key in an object using
.users
fromstep1.data.users
.Add query parameters and headers dynamically using
lam.queryParams
andlam.headers
.Include a body using
lam.body
with the desired object data.Create a new workflow called "Recursively Send Data" to send requests for each user in the user array.
Use the
lam.result
syntax to execute a workflow by ID for each user.Implement conditions using an if statement to filter data based on specific attributes like total spent.
Cautionary Notes
Ensure proper syntax and structure while adding query parameters, headers, and body data.
Verify workflow IDs and payload data for accurate execution.
Double-check conditions and statements to filter data correctly.
Tips for Efficiency
Use
lam.workflowId
andlam.payload
to iterate over users and pass data to the specified workflow.Utilize if statements to apply conditions for filtering data based on specific attributes.
Test the workflow execution to ensure accurate data transmission and control flow implementation.
Data Transformation
We transformed our first JSON with control flow using this JQ:
Last updated
Was this helpful?