I have extended the functionality of service task by adding some few attributes in schema json.
Props like
{
"name": "type",
"description": "Type of service. Supported is Method Call and API Call",
"isAttr": true,
"type": "String"
},
{
"name": "apiUrl",
"description": "Url to hit if API Call type",
"isAttr": true,
"type": "String"
},
{
"name": "apiPayload",
"description": "Payload for API call",
"isAttr": true,
"type": "String"
},
Now it can call an api as well based on type.
And i am using bpmn-engine to execute the bpmn flow xml.
But on agi side how can i handle this? In case of service method call, to save the result variable i have used extension like this
function bpmnSaveServiceResultToVar(bpmnActivity) {
// if there is no result from service execution then return
if (!bpmnActivity.behaviour.resultVariable) {
return;
}
// when this particular activity ends then assign it to a variable
bpmnActivity.on(EVENT_TYPES.BPMN.END, ({ environment, content }) => {
const ivrVar = environment.variables.ivrVar;
// Set the output of the service component into the defined result variable
set(ivrVar, bpmnActivity.behaviour.resultVariable, content.output[0]);
});
}