Corteza Workflow Tutorial

Hi :slight_smile:

I’m just getting started with Corteza Workflows and I’m struggling to translate my requirements into a workflow. Neither the official documentation nor Google have been much help so far. Is there a tutorial that goes beyond the basics and explores the topic in more depth?

Alternatively, how can I build a solid understanding of Corteza Workflows (aside from frustrating trial and error)?

The best place to start is the docs Workflows :: Corteza Docs

Unfortunately, workflows do have a big learning curve.

Ok then maybe you can provide solution for one specific question.

I created an Integration Gateway Endpoint and plugged it to a workflow. The workflow receives the JSON Body of the Request and my first goal is simply to return it back to my requesting part (postman).
To do so I tried to add Default JSON response to the Endpoint:

My workflow is the following:
{
“workflows”: [
{
“handle”: “request_parse_function”,
“enabled”: true,
“meta”: {
“name”: “Request parse in function”,
“description”: “”,
“visual”: null
},
“keepSessions”: 0,
“steps”: [
{
“stepID”: “4”,
“kind”: “termination”,
“ref”: “”,
“arguments”: null,
“results”: null,
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “4”,
“parent”: “1”,
“value”: “Finish”,
“xywh”: [
3280,
2280,
200,
80
]
}
}
},
{
“stepID”: “17”,
“kind”: “function”,
“ref”: “apigwBodyRead”,
“arguments”: [
{
“target”: “body”,
“expr”: “request.Body”,
“type”: “HttpRequestBody”
}
],
“results”: [
{
“target”: “bodyContents”,
“expr”: “body”
}
],
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “17”,
“parent”: “1”,
“value”: “Read request body”,
“xywh”: [
2440,
2280,
200,
80
]
}
}
},
{
“stepID”: “24”,
“kind”: “function”,
“ref”: “logWarn”,
“arguments”: [
{
“target”: “message”,
“value”: “Body contents in KV following”,
“type”: “String”
},
{
“target”: “fields”,
“expr”: “assignedVar”,
“type”: “KV”
}
],
“results”: [],
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “24”,
“parent”: “1”,
“value”: “Output variable”,
“xywh”: [
3000,
2280,
200,
80
]
}
}
},
{
“stepID”: “27”,
“kind”: “expressions”,
“ref”: “”,
“arguments”: [
{
“target”: “assignedVar”,
“expr”: “bodyContents”,
“type”: “KV”
}
],
“results”: null,
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “27”,
“parent”: “1”,
“value”: “Assign body to variable”,
“xywh”: [
2720,
2280,
200,
80
]
}
}
}
],
“paths”: [
{
“parentID”: “17”,
“childID”: “27”,
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “32”,
“parent”: “1”,
“points”: [],
“style”: “exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;”,
“value”: null
}
}
},
{
“parentID”: “27”,
“childID”: “24”,
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “33”,
“parent”: “1”,
“points”: [],
“style”: “exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;”,
“value”: null
}
}
},
{
“parentID”: “24”,
“childID”: “4”,
“meta”: {
“name”: “”,
“description”: “”,
“visual”: {
“id”: “34”,
“parent”: “1”,
“points”: [],
“style”: “exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;”,
“value”: null
}
}
}
]
}
]
}

It returns only empty curly braces {} but not my sent request body. What am I doing wrong? Do I have to specify “output variables” in my workflow? If yes, how?

The result variable can be used for the response

  1. Define the variable in the workflow you use for Processing the request

  2. Use the Response Postfilter in the integration gateway

Nice thanks for the answer.

I think it is not quite accurate though. As far as I tried, the variable in the workflow must have the name “result” and it does not matter what I write into the Input field of the Response filter of the endpoint because it always scans for the “result” variable.

Anyways… I did not find this topic in the official Documentation - what is the source of your answer (or is it just your own knowledge / experience?)

With this configuration the variable foobar will be the response.


I see now that it was never added to the docs, thanks for pointing it out.
It should be added soon.

1 Like

Weird. I tried exact the same before and it did not work… now it does. Thank you for your effort :slight_smile:

1 Like

Ok I have one more small question.

If I search for Records and try to return them to Postman, I get something like that:
“tenants”: [
{
@value”: {
“kcgroupid”: {
@value”: “73…”,
@type”: “String”
},
“rolename”: {
@value”: “user”,
@type”: “String”
}
},
@type”: “Vars”
},

Is it possible in the workflow itself to extract the “@value” of the Record Field and get rid of the “@type” before returning it?

Sure,

Just define a new variable and return that.

Actually thats exactly what I did.

For example the kcgroupid:
image

But it is displayed like this:
image

What am I doing wrong here?

Im guessing the issue is with using arrays since they probably keep the types when pushing.

For example if I use KV

image

Or if i use Any and toJSON
image

image

Consider using join when preparing final array in the results, which will remove the types.

image

Hopefully the array types issue will be resolved in the future.

1 Like