Running a Conductor Workflow
Published: 2021-12-05 20:50:29

In this article we will explore how we can run a really simple workflow using Netflix Conductor. 

Read more about Conductor here: https://github.com/Netflix/conductor

> Visit our codebase and give us a star, it helps! :)

Conductor can orchestrate HTTP services out of the box without implementing any code.  We will use that to create and run our first workflow.

To follow the steps in this article we will need to have Conductor running on your local. We can do that by following the [steps here](https://orkes.io/content/docs/getting-started/install/running-locally-docker)

## 1. Configuring our First Workflow

This is a sample workflow that we can leverage for our test.

```json
{
  "name": "first_sample_workflow",
  "description": "First Sample Workflow",
  "version": 1,
  "tasks": [
    {
      "name": "get_population_data",
      "taskReferenceName": "get_population_data",
      "inputParameters": {
        "http_request": {
          "uri": "https://datausa.io/api/data?drilldowns=Nation&measures=Population",
          "method": "GET"
        }
      },
      "type": "HTTP"
    }
  ],
  "inputParameters": [],
  "outputParameters": {
    "data": "${get_population_data.output.response.body.data}",
    "source": "${get_population_data.output.response.body.source}"
  },
  "schemaVersion": 2,
  "restartable": true,
  "workflowStatusListenerEnabled": false,
  "ownerEmail": "example@email.com",
  "timeoutPolicy": "ALERT_ONLY",
  "timeoutSeconds": 0
}
```

This is an example workflow that queries a publicly available JSON API to retrieve some data. This workflow doesn’t require any worker implementation as the tasks in this workflow are managed by the system itself. This is an awesome feature of Conductor. For a lot of typical work, we won’t have to write any code at all.

To configure the workflow, head over to the swagger API of conductor server and access the metadata workflow create API:

[http://localhost:8080/swagger-ui/index.html?configUrl=/api-docs/swagger-config#/metadata-resource/create](http://localhost:8080/swagger-ui/index.html?configUrl=/api-docs/swagger-config#/metadata-resource/create)

If the link doesn’t open the right Swagger section, we can navigate to Metadata-Resource
→ `POST /api/metadata/workflow`

Paste the workflow payload into the Swagger API and hit Execute.

Now if we head over to the UI, we can see this workflow definition created:
http://localhost:5000/workflowDef/first_sample_workflow

![Conductor UI - Workflow Definition - Visual Flow](https://github.com/orkes-io/docs/blob/main/static/img/tutorial/uiWorkflowDefinitionVisual.png?raw=true)

## 2. Running our First Workflow

Let’s run this workflow. To do that we can use the swagger API under the workflow-resources

[http://localhost:8080/swagger-ui/index.html?configUrl=/api-docs/swagger-config#/workflow-resource/startWorkflow_1](http://localhost:8080/swagger-ui/index.html?configUrl=/api-docs/swagger-config#/workflow-resource/startWorkflow_1)

![Swagger UI - Metadata - Workflow - Run](https://github.com/orkes-io/docs/blob/main/static/img/tutorial/metadataWorkflowRun.png?raw=true)

Let's specify our workflow name `first_sample_workflow` and Hit **Execute**!

Conductor will return a workflow id.

You can find more options on how to run workflows [here](https://orkes.io/content/docs/how-tos/starting-workflows)

Ok, we should see this running and get completed soon. Let’s go to the UI to see what happened.

To load the workflow directly, use this URL format:

```
http://localhost:5000/execution/<WORKFLOW_ID>
```

Replace `<WORKFLOW_ID>` with our workflow id from the previous step. We should see a screen like below. Click on the different tabs to see all inputs and outputs and task list etc. Explore away!

![Conductor UI - Workflow Run](https://github.com/orkes-io/docs/blob/main/static/img/tutorial/workflowLoaded.png?raw=true)


## Summary

In this blog post — we learned how to run a sample workflow in our Conductor installation. Concepts we touched on:

1. Workflow creation
2. System tasks such as HTTP
3. Running a workflow via API

Thank you for reading, and we hope you found this helpful. Please feel free to reach out to us for any questions and we
are happy to help in any way we can.

### Who are we?

We are founding engineers of Netflix Conductor who has got together to form [Orkes Inc.](https://orkes.io) - a company focused on helping developers to adopt and use Netflix Conductor for building distributed systems at scale and with reliability. 

Join our [slack channel](https://join.slack.com/t/orkes-conductor/shared_invite/zt-xyxqyseb-YZ3hwwAgHJH97bsrYRnSZg) to reach us and talk about your use-cases. We would love to talk to you!