Getting Started Integromat - DigiBP/digibp.github.io GitHub Wiki

This getting-started illustrates how an iSaaS, in this case, Integromat, can be used to integrate services and store data.

This iSaaS guide is a follow-up of the Service Integration guide.

This guide relies on the previously configured settings, as part of the Workflow Getting Started guide, and knowledge gained in the Service Integration guide.

Contents:

Scenario

This guide relies on a very basic scenario where customer data will be firstly stored in and secondly retrieved from Google Sheets, in two processes.

The case data is identified by a business key. The service tasks are connected to two Integromat scenario endpoints create-customer-data and read-customer-data as shown in the following animation:

1. Modelling the Workflow

From a starting point, you may model the following workflow:

Please note that the iSaaS pool is not executable and not BPMN specification compliant - this is just for illustration and may in practice be collapsed.

A final version of the process model can be downloaded from here: isaas-service-task.bpmn. Please note that you may have to update the service URLs.

2. Data Structure

As an additional preparation step, you may define a data structure using Google Sheets as follows:

Business Key First Name Last Name Date Created Date Read

3. iSaaS Endpoint: create-customer-data

First, place a custom webhook module into the create-customer-data scenario and retrieve the data structure by sending a POST request from Postman including the execution of the following pre-request script:

// Connector-START • Camunda HTTP Connector JavaScript emulation:
eval(pm.environment.get("camunda"));
// Connector-END

// Test-Data-START • Initialise process variables, and (optionally) business key and/or process id:
firstName = "Andreas";
lastName = "Martin";
execution.setBusinessKey("case-001");
// Test-Data-END

// Service-Task-Input-START • Camunda HTTP Connector Input Parameter payload Script:
out = JSON.stringify({
    "firstName": firstName,
    "lastName": lastName,
    "businessKey": execution.getBusinessKey()
});
// Service-Task-Input-END

// Body-START • Postman Body {{payload}}:
payload.set(out);
// Body-END 

Then you may set a timestampCreated variable, which will be used to indicate when the data record has been created:

Add a new row to your sheet by mapping the variables:

Finally, run the Postman request again to verify that the scenario works.

4. iSaaS Endpoint: read-customer-data

Similar to above, start the read-customer-data scenario custom webhook module and retrieve the data structure by sending a GET request including the following URL query parameter: https://hook.integromat.com/xyz/?businessKey=case-001.

Also similar to above, you may set a timestampRead variable, which will be used to indicate when the data record has been read at the lastly.

Then, retrieve the corresponding sheet row by using the businessKey as filtering value:

You may update the retrieved row with the timestampRead variable:

Finalise the scenario with a Webhook response module, which returns the retrieved data:

And define the following response JSON body:

{
   "firstName":"{{2.columnfirstname}}",
   "lastName":"{{2.columnlastname}}",
   "sheetURL":"{{2.sheetUrl}}"
}

The number 2. in the JSON body refers to the module in the Integromat scenario, which is maybe different in your scenario.

Finally, run the GET request again in Postman including a test script as exemplarily described as follows to verify that the scenario works:

// Connector-START • Camunda HTTP Connector JavaScript emulation:
eval(pm.environment.get("camunda"));
// Connector-END

// Service-Task-Output-START • Camunda HTTP Connector Output Parameter firstName Script:
object = JSON.parse(response);
firstName = object.firstName;
// Service-Task-Output-END

// Service-Task-Output-START • Camunda HTTP Connector Output Parameter lastName Script:
object = JSON.parse(response);
lastName = object.lastName;
// Service-Task-Output-END

// Service-Task-Output-START • Camunda HTTP Connector Output Parameter sheetURL Script:
object = JSON.parse(response);
sheetURL = object.sheetURL;
// Service-Task-Output-END

// Test-START • Postman Test:
pm.test("Test firstName: " + firstName, function() {
    pm.expect(firstName).to.include("");
});
pm.test("Test lastName: " + lastName, function() {
    pm.expect(lastName).to.include("");
});
pm.test("Test sheetURL: " + sheetURL, function() {
    pm.expect(sheetURL).to.include("http");
});
// Test-END

4. Service Integration and Deployment

Similarly, do the service integration as described in the Service Integration guide.

The GET request including the businessKey as URL query parameter can be realised as follows:

In a Camunda environment where dependency injection and/or spring beans are available such as in Camunda Spring Boot, the current businessKey can be retrieved by using ${execution.getBusinessKey()}.

Now you are ready to deploy your process and test if it works as expected.