Returning User Task Response

Hi,

In my BPMN I have a chain of user tasks and at each step I want to wait for user input, call an API and return its response to the user and then wait for next user input .

I have created a single rest endpoint. Through this rest endpoint I intend to send the user input. Once I receive a user input I want to resume the same process instance based on the business key which I have created earlier.

How to achieve this?

I think you might be looking at implementing task listeners that can be activated before or after a user task.
https://docs.camunda.org/manual/latest/user-guide/process-engine/delegation-code/#task-listener

Thanks, for the reply Niall.

I don’t want to use the rest APIs provided by Camunda for starting and completing the task, instead I want to do these tasks by the rest endpoint created by me.

I am starting a process using my endpoint; by calling the startProcessInstanceByKey().
private ProcessInstance createInstance(Map<String, Object> request) {//request Sent by the user
Map<String, String> inputRequest = (LinkedHashMap<String, String>) request.get(“variables”);
return camunda.getRuntimeService().startProcessInstanceByKey(
“BPMN_NAME”,“businessKey”,//BUSINESS KEY
Variables.putValue(“request”, request));
}
I want to call an API in the JavaDelegate bound to the task and when I get the API response, I want to mark the task as completed immediately.

I tried doing it but was unable to complete the task via code as I was not able to get the task ID.
delegateExecution.getProcessEngine().getTaskService().complete()

Also when a new request is sent on the same endpoint, I want to resume the same processes event which was created earlier.