Camunda Node.js External Task Client 0.2.0 Released

  • Blog
  • >
  • Camunda Node.js External Task Client 0.2.0 Released

We are so excited to announce a new alpha release of camunda-external-task-client-js,
an Node.js module that makes it possible to handle your BPMN Service Tasks.

This release is focused on making it more flexible to handle variables.
It improves setting variables and brings up two major features:

  • setting local variables
  • support for Date & File typed variables

The following example will illustrate these features and show how they can be used.


A Workflow for Handling Orders

1. Setup

  • first, make sure to have Camunda running
  • download the following model
    and deploy it using the Camunda Modeler
  • create an invoice.txt file with some data and place it in the same folder as the script
  • install camunda-external-task-client-js from npm using:
    npm install -s camunda-external-task-client-js


    yarn add camunda-external-task-client-js

2. Node.js Service Task Implementation

const {
} = require("camunda-external-task-client-js");

// configuration for the Client:
//  - 'baseUrl': url to the Workflow Engine
//  - 'logger': utility to automatically log important events
const config = { baseUrl: "https://localhost:8080/engine-rest", use: logger };

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

// subscribe to the topic: 'invoiceCreator'
client.subscribe("invoiceCreator", async function({ task, taskService }) {
  // Put your business logic
  // complete the task
  const date = new Date();
  const invoice = await new File({ localPath: "./invoice.txt" }).load();
  const minute = date.getMinutes();
  const variables = new Variables().setAll({ invoice, date });

  // check if minute is even
  if (minute % 2 === 0) {
    // for even minutes, store variables in the process scope
    await taskService.complete(task, variables);
  } else {
    // for odd minutes, store variables in the task local scope
    await taskService.complete(task, null, variables);

3. Results

The terminal output should be:

✓ subscribed to topic invoiceCreator
✓ polled 1 tasks
✓ completed task 21d19522-3e4c-11e8-b8df-186590db1cd7

Moreover, the added variables should be available in Cockpit in the history view of the process instance:

Cockpit History View

Documentation & More Detailed Examples

This example illustrates a basic usage of the new alpha release of camunda-external-task-client-js.
To find out more about this release, you can check out the documentation
or get the example running.


Your feedback is extremely important, so don’t hesitate to share it with us by:

Try All Features of Camunda

Related Content

Achieve our first certification as a Camunda Certified Professional—Developer.
We've been working hard to reduce the job activation latency in Zeebe. Read on to take a peek under the hood at how we went about it and then verified success.
2023 was quite a year for Zeebe, and the team has been hard at work improving performance. Get an overview of all the latest technical improvements.