> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aseeflow.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Executing automated steps

In this section, you'll learn how to create your first BPMN 2.0 process with the Camunda Modeler and how to execute automated steps. Start by opening the Camunda Modeler.

## Create a new BPMN diagram

Create a new BPMN diagram by clicking **File > New File > BPMN Diagram (Camunda Platform)**.

<img src="https://mintcdn.com/aseeflow/nrz9o5m15i2WLCpp/get-started/quick-start/img/modeler-new-bpmn-diagram.png?fit=max&auto=format&n=nrz9o5m15i2WLCpp&q=85&s=27aefe246cb4f35f73615590d55e948c" alt="Create a new BPMN diagram" width="1200" height="873" data-path="get-started/quick-start/img/modeler-new-bpmn-diagram.png" />

## Start with a simple process

Double-click the start event. A text box opens. Name the start event *Payment Retrieval Requested*.

<Tip>
  When editing labels, you can add line breaks using `Shift + Enter`.
</Tip>

<img src="https://mintcdn.com/aseeflow/nrz9o5m15i2WLCpp/get-started/quick-start/img/modeler-step1.png?fit=max&auto=format&n=nrz9o5m15i2WLCpp&q=85&s=4e48e22d7ea4b241e557bfbb3c34c3d6" alt="Name the start event" width="1200" height="673" data-path="get-started/quick-start/img/modeler-step1.png" />

Click the start event. From its context menu, select the activity shape (rounded rectangle). It is placed automatically on the canvas; drag it to your preferred position. Name it *Charge Credit Card*. Change the activity type to *Service Task* by clicking the activity shape and using the wrench button.

<img src="https://mintcdn.com/aseeflow/nrz9o5m15i2WLCpp/get-started/quick-start/img/modeler-step2.png?fit=max&auto=format&n=nrz9o5m15i2WLCpp&q=85&s=9b249ca6b311130de48063dbc8f515f6" alt="Change the activity to a service task" width="1200" height="673" data-path="get-started/quick-start/img/modeler-step2.png" />

Add an end event named *Payment Received*.

<img src="https://mintcdn.com/aseeflow/nrz9o5m15i2WLCpp/get-started/quick-start/img/modeler-step3.png?fit=max&auto=format&n=nrz9o5m15i2WLCpp&q=85&s=e7d24ae9e4bd32f45ddedd3f2e0b0b2c" alt="Add an end event" width="1200" height="673" data-path="get-started/quick-start/img/modeler-step3.png" />

## Configure the service task

There are different ways to [execute service tasks](/reference/bpmn20/tasks/service-task) with ASEE Flow. In this guide, we'll use the [external task pattern](/user-guide/process-engine/external-tasks). Open the properties panel in the Camunda Modeler and click the service task you just created. Change the **Implementation** to `External` and use `charge-card` as the **Topic**.

<img src="https://mintcdn.com/aseeflow/nrz9o5m15i2WLCpp/get-started/quick-start/img/modeler-step4.png?fit=max&auto=format&n=nrz9o5m15i2WLCpp&q=85&s=9e6f2389485e81e5a6df78bb058f0519" alt="Configure the service task" width="1200" height="673" data-path="get-started/quick-start/img/modeler-step4.png" />

## Configure properties for execution

Because we're modeling an executable process, we should give it an *ID* and set the `isExecutable` property to `true`. On the right-hand side of the canvas you find the properties panel. When you click empty space on the canvas, the panel displays the properties of the process itself.

First, configure an ID for the process. Type *payment-retrieval* in the *Id* field. The ID is used by the process engine as an identifier for the executable process; it's best practice to set it to a human-readable name.

Second, type *Payment Retrieval* in the *Name* field.

Finally, make sure the *Executable* checkbox is checked. If you don't check this box, the process definition is ignored by the process engine.

<img src="https://mintcdn.com/aseeflow/nrz9o5m15i2WLCpp/get-started/quick-start/img/modeler-step5.png?fit=max&auto=format&n=nrz9o5m15i2WLCpp&q=85&s=6d831a28b8beca13435ed9e18878ba90" alt="Configure process properties" width="1200" height="673" data-path="get-started/quick-start/img/modeler-step5.png" />

## Save the BPMN diagram

When you're done, save your changes by clicking **File > Save File As...**. In the dialog, navigate to a folder of your choice and save the diagram as something like `payment.bpmn`.

<Note>
  **Catch up: get the sources of Step-1**

  ```bash theme={null}
  git clone https://github.com/aseeflow/aseeflow-get-started-quickstart.git
  git checkout -f Step-1
  ```

  Or [download as a `.zip`](https://github.com/aseeflow/aseeflow-get-started-quickstart/archive/Step-1.zip).
</Note>

## Implement an external task worker

After modeling the process, we want to execute some business logic. ASEE Flow lets you implement your business logic in different languages — choose whichever suits your project best. In this quick start, we'll show you how to use ready-to-go task clients in:

* [Java](#a-using-java)
* [JavaScript (Node.js)](#b-using-javascript-nodejs)

<Warning>
  **ASEE Flow Run secures the engine REST API by default** — the distribution bundles [WebAdmin](/webadmin). The workers below connect to `/engine-rest` without credentials, so against a default Run distribution they receive `401`.

  For this local quick start, open the REST API by setting `aseeflow.webadmin.disable-rest-security=true` on the Run distribution (or the environment variable `ASEEFLOW_WEBADMIN_DISABLE_REST_SECURITY=true`). For a secured deployment, authenticate the worker to match your configured [authentication mode](/webadmin/authentication) instead. See [WebAdmin security](/webadmin/security#never-leave-the-engine-rest-api-unprotected) for the trade-offs of disabling REST security.
</Warning>

<Tip>
  If you prefer a different programming language, you can also use the [REST API](/user-guide/process-engine/external-tasks) to access API operations over HTTP.
</Tip>

## a) Using Java

In this section, you'll implement an external task worker in Java.

### Prerequisites

Make sure you have the following tools installed:

* JDK 17 or later (see [supported environments](/introduction/supported-environments))
* An IDE for Java projects (for example IntelliJ IDEA, Eclipse, or VS Code)

### Create a new Maven project

Start by creating a new Maven project in your IDE — a simple project (you can skip archetype selection).
Configure the Maven coordinates and, since we're setting up a JAR project, set **Packaging** to `jar`.
You can also create the project directly from the `pom.xml` shown below.

### Add the external task client dependency

Set up the Maven dependency to the external task client. Your `pom.xml` should look like this:

```xml theme={null}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>org.aseeflow.bpm.getstarted</groupId>
	<artifactId>charge-card-worker</artifactId>
	<version>0.0.1-SNAPSHOT</version>

	<properties>
		<aseeflow.external-task-client.version>1.0.0</aseeflow.external-task-client.version>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.aseeflow.bpm</groupId>
			<artifactId>aseeflow-external-task-client</artifactId>
			<version>${aseeflow.external-task-client.version}</version>
		</dependency>
		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<version>1.7.36</version>
		</dependency>
		<dependency>
			<groupId>jakarta.xml.bind</groupId>
			<artifactId>jakarta.xml.bind-api</artifactId>
			<version>4.0.2</version>
		</dependency>
	</dependencies>
</project>
```

### Add the Java class

Next, create an `ExternalTaskClient` that subscribes to the `charge-card` topic. When the process engine encounters a service task configured to be externally handled, it creates an external task instance that our handler reacts to. We use [long polling](/user-guide/process-engine/external-tasks) in the client to make communication more efficient.

Create a package, for example `org.camunda.bpm.getstarted.chargecard`, and add a Java class such as `ChargeCardWorker`:

```java theme={null}
package org.camunda.bpm.getstarted.chargecard;

import java.util.logging.Logger;
import java.awt.Desktop;
import java.net.URI;

import org.camunda.bpm.client.ExternalTaskClient;

public class ChargeCardWorker {
  private final static Logger LOGGER = Logger.getLogger(ChargeCardWorker.class.getName());

  public static void main(String[] args) {
    ExternalTaskClient client = ExternalTaskClient.create()
        .baseUrl("http://localhost:8080/engine-rest")
        .asyncResponseTimeout(10000) // long polling timeout
        .build();

    // subscribe to an external task topic as specified in the process
    client.subscribe("charge-card")
        .lockDuration(1000) // the default lock duration is 20 seconds, but you can override this
        .handler((externalTask, externalTaskService) -> {
          // Put your business logic here

          // Get a process variable
          String item = externalTask.getVariable("item");
          Integer amount = externalTask.getVariable("amount");

          LOGGER.info("Charging credit card with an amount of '" + amount + "'€ for the item '" + item + "'...");

          // Complete the task
          externalTaskService.complete(externalTask);
        })
        .open();
  }
}
```

### Run the worker

Run the Java application by right-clicking the `ChargeCardWorker` class and choosing **Run as Java**. Keep the worker running throughout this quick start guide.

### Next step

Once your worker is running, [continue to deploy your process and start some instances](/get-started/quick-start/deploy).

<Note>
  **Catch up: get the sources of Step-2a**

  ```bash theme={null}
  git clone https://github.com/aseeflow/aseeflow-get-started-quickstart.git
  git checkout -f Step-2a
  ```

  Or [download as a `.zip`](https://github.com/aseeflow/aseeflow-get-started-quickstart/archive/Step-2a.zip).
</Note>

## b) Using JavaScript (Node.js)

In this section, you'll implement an external task worker in Node.js.

### Prerequisites

Make sure you have the following tools installed:

* Node.js >= v16 ([download here](https://nodejs.org/en/download/))
* An editor for JavaScript files

### Create a new Node.js project

```bash theme={null}
mkdir charge-card-worker
cd ./charge-card-worker
npm init -y
```

### Enable ES modules

Add the following `"type"` field to your `package.json`:

```json theme={null}
{
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  }
}
```

### Add the external task client JS library

```bash theme={null}
npm install camunda-external-task-client-js
npm install -D open
```

### Implement the Node.js script

Create an `ExternalTaskClient` that subscribes to the `charge-card` topic. Create a JavaScript file such as `worker.js`:

```javascript theme={null}
import { Client, logger } from 'camunda-external-task-client-js';

// configuration for the Client:
//  - 'baseUrl': url to the Process Engine
//  - 'logger': utility to automatically log important events
//  - 'asyncResponseTimeout': long polling timeout (then a new request will be issued)
const config = { baseUrl: 'http://localhost:8080/engine-rest', use: logger, asyncResponseTimeout: 10000 };

// create a Client instance with custom configuration
const client = new Client(config);

// subscribe to the topic: 'charge-card'
client.subscribe('charge-card', async function({ task, taskService }) {
  // Put your business logic here

  // Get a process variable
  const amount = task.variables.get('amount');
  const item = task.variables.get('item');

  console.log(`Charging credit card with an amount of ${amount}€ for the item '${item}'...`);

  // Complete the task
  await taskService.complete(task);
});
```

### Run the Node.js script

```bash theme={null}
node ./worker.js
```

Keep the worker running throughout this quick start guide.

### Next step

Once your worker is running, [continue to deploy your process and start some instances](/get-started/quick-start/deploy).

<Note>
  **Catch up: get the sources of Step-2b**

  ```bash theme={null}
  git clone https://github.com/aseeflow/aseeflow-get-started-quickstart.git
  git checkout -f Step-2b
  ```

  Or [download as a `.zip`](https://github.com/aseeflow/aseeflow-get-started-quickstart/archive/Step-2b.zip).
</Note>
