Build an API Processing Workflow with Orkes Conductor
In this tutorial, you’ll build an API processing workflow using Orkes Conductor that takes a city name as input, retrieves real-time weather data, analyzes the temperature, and returns a simple travel suggestion.
This is a common pattern for API orchestration where external services are queried and results are processed to deliver a personalized outcome.
The API processing workflow
In this tutorial, you’ll build a workflow that includes two HTTP tasks and one JSON JQ Transform task.
The first HTTP task fetches the city’s coordinates based on user input using a free API. The second HTTP task uses those coordinates to retrieve the city's current weather. The JSON JQ Transform task evaluates the current weather data returned by the API and generates travel suggestions.
Here’s what the workflow looks like:
Follow along using the free Developer Edition. If you don’t have an account yet, sign up to get started.
Step 1: Create a workflow in Orkes Conductor
Orkes Conductor lets you define workflows as JSON, through SDKs, APIs, or the UI.
Use the provided JSON below to create the workflow quickly, or build the workflow from scratch.
- Create workflow using the provided JSON via Conductor UI
- Build it from scratch using Conductor UI
To create a workflow using Conductor UI:
- Go to Definitions > Workflow from the left navigation menu on your Conductor cluster.
- Select + Define workflow.
- In the Code tab, paste the following code:
{
"name": "simple_weather_travel_suggestion",
"description": "Takes city input, fetches weather, and returns a simple travel suggestion",
"version": 1,
"tasks": [
{
"name": "get_coordinates",
"taskReferenceName": "get_coordinates",
"inputParameters": {
"http_request": {
"uri": "https://geocoding-api.open-meteo.com/v1/search?name=${workflow.input.city}&count=1",
"method": "GET"
}
},
"type": "HTTP"
},
{
"name": "get_weather",
"taskReferenceName": "get_weather",
"inputParameters": {
"http_request": {
"uri": "https://api.open-meteo.com/v1/forecast?latitude=${get_coordinates.output.response.body.results[0].latitude}&longitude=${get_coordinates.output.response.body.results[0].longitude}¤t_weather=true",
"method": "GET"
}
},
"type": "HTTP"
},
{
"name": "set_suggestion",
"taskReferenceName": "set_suggestion",
"inputParameters": {
"input": {
"temperature": "${get_weather.output.response.body.current_weather.temperature}"
},
"queryExpression": "if (.input.temperature > 30) then {suggestion: \"Too hot.\"} elif (.input.temperature < 10) then {suggestion: \"Too cold. Be ready for shivers.\"} else {suggestion: \"Weather is good. You can travel now.\"} end"
},
"type": "JSON_JQ_TRANSFORM"
}
],
"inputParameters": [
"city"
],
"outputParameters": {
"city": "${workflow.input.city}",
"temperature": "${get_weather.output.response.body.current_weather.temperature}",
"suggestion": "${set_suggestion.output.result.suggestion}"
},
"schemaVersion": 2
}
- Select Save > Confirm.
Build it from scratch yourself
- Go to Definitions > Workflow from the left navigation menu on your Conductor cluster.
- Select + Define workflow.
- Enter a name and description for the workflow.
- Add your first task:
- Add an HTTP task and rename it to get_coordinates.
- Select Method as GET, and set the URL as https://geocoding-api.open-meteo.com/v1/search?name=${workflow.input.city}&count=1.
- Add your second task:
- Add another HTTP task and rename it to get_weather.
- Select Method as GET, and set the URL as https://api.open-meteo.com/v1/forecast?latitude=${get_coordinates.output.response.body.results[0].latitude}&longitude=${get_coordinates.output.response.body.results[0].longitude}¤t_weather=true.
- Add your third task:
- Add a JSON JQ Transform task and rename it to get_coordinates.
- In Script Params, add a parameter with Key as input, Value as
{ "temperature": "${get_weather.output.response.body.current_weather.temperature}" }
, and Type as Object/Array. - Set the JQ expression as
if (.input.temperature > 30) then {suggestion: \"Too hot.\"} elif (.input.temperature < 10) then {suggestion: \"Too cold. Be ready for shivers.\"} else {suggestion: \"Weather is good. You can travel now.\"} end
.
- In the Workflow tab, set the Input parameters to city.
- In the Workflow tab, set the following Output parameters:
Parameter | Value |
---|---|
city | ${workflow.input.city} |
temperature | ${get_weather.output.response.body.current_weather.temperature} |
suggestion | ${set_suggestion.output.result.suggestion} |
- Select Save > Confirm.
Step 2: Execute workflow
To test the workflow:
- From your workflow definition, go to the Run tab.
- Set the input parameter. For example:
{
"city": "Zurich"
}
- Select Execute.
This initiates the workflow and takes you to the workflow execution page.
Once the workflow is completed, check the Workflow Input/Output tab to view the city’s current weather and travel suggestions.