Skip to main content
Version: 8.8 (unreleased)

Intrinsic functions

Intrinsic functions are transformations you can use to preprocess connector input data before invoking a connector.

  • Intrinsic functions are JSON structures you can define in element template input fields.
  • Intrinsic functions are executed in the connector runtime.
note

You can only use intrinsic functions with outbound connectors as they transform data obtained from process variables.

Use cases

A common use case is to transform a Camunda document to a specific format when using a REST connector.

For example:

  • You have a Camunda document containing some data in JSON format.
  • You want to send this data in the HTTP request body to a REST API using a connector.

The REST connector is capable of handling documents, but the data format in which the document is sent by default may not match the format expected by the REST API.

In this example, the document in the Camunda document store is structured as follows, with the document reference stored in the document process variable:

{
"name": "John Doe",
"age": 30
}

The REST API expects the data in the following format:

{
"user": {
"name": "John Doe",
"age": 30
}
}

In this example, you can use the getText intrinsic function to extract the text content from the document and insert it into the request body. The resulting JSON structure of your connector's input would be as follows:

{
"user": {
"camunda.function.type": "getText",
"params": [ document ]
}
}
  • document is the process variable that contains the document reference.
  • The getText function extracts the text content from the document and inserts it into the request body as a string.
note
  • You can use intrinsic functions with any outbound connector to execute an operation with a connector input.
  • Intrinsic functions are executed in the connector runtime.

Available functions

The following prebuilt functions are available:

base64

The base64 function accepts a document or a string. It encodes the document content or string to Base64 format.

{
"camunda.function.type": "base64",
"params": [ myDocument ]
}

The createLink function accepts a document and an optional TTL (time-to-live) value. It creates a temporary pre-signed link to the document in the Camunda document storage. The link is returned as a string.

  • Pre-signed links can only be created for documents that are stored in cloud storage (for example, AWS S3 or Google Cloud Storage), but not local or in-memory storage.
  • The optional TTL parameter must be a valid ISO 8601 duration string.
  • If not provided, the default TTL is 1 hour.
{
"camunda.function.type": "createLink",
"params": [ myDocument, "PT1H" ]
}

getText

The getText function accepts a document and an optional encoding parameter. It extracts the text content from the document and returns it as a string.

  • The optional encoding parameter specifies the character encoding to be used when extracting the text.
  • If not provided, the default encoding is UTF-8.
{
"camunda.function.type": "getText",
"params": [ myDocument, "UTF-8" ]
}

Create a custom function

In Self-Managed deployments, you can create custom intrinsic functions by implementing the IntrinsicFunctionProvider interface included with the Connector SDK, and registering it in the connector runtime.

  • The custom function is implemented as a Java method inside the IntrinsicFunctionProvider implementation class.
  • The method must be annotated with the @IntrinsicFunction annotation. The method arguments are transformed into a list of intrinsic function parameters.
import io.camunda.document.Document;
import io.camunda.intrinsic.IntrinsicFunction;
import io.camunda.intrinsic.IntrinsicFunctionProvider;
import java.util.Base64;

public class MyFunctionProvider implements IntrinsicFunctionProvider {

@IntrinsicFunction(name = "concat")
public String execute(String s1, String s2) {
return s1 + s2;
}
}