Camunda - how to get task name using Zeebe API?

Hello everyone, I have a process in camunda, it has a Zeebe API, as I understand it, the backend communicates with camunda through it. I need, that by userId and Instance Id, I would give the name of which task this user is currently on. ” - at this stage the user is now. I looked at how Ui is formed - there is a giant xml that is very inconvenient to parse, and this is not obtained through the Zeebe API, I think there is a more normal way.

return zeebeClient
            .newCreateInstanceCommand()
            .bpmnProcessId(startSimpleParameters.processName)
            .version(version)
            .variables(variables)
            .requestTimeout(timeout)
            .send()
            .await()

and expected to be able to get the current task the user is working on and its name from the schema.
9084c8be254cc96a97d2a67ac32954916605d871

I think you posted your question in the wrong forum.

Hi @Lomovskoy and welcom to the forum,

As already mentioned by @fml2, you posted your Camunda 8 related question in the Camunda 7 category. It would be great, if you can change the category to the correct one.

Zeebe is the process engine at the heart of Camunda 8 (see architecture). It has an API and can have exporters, which export events to different data sinks. In Camunda 8, an Elasticsearch Exporter is shipped by default. All frontend applications (Tasklist, Operate, and Optimize) access Elasticsearch indices instead of Zeebe.

To get User-Task related information, you can use different methods:

I hope this information helps you to find a solution.

Thanks I will try to dig in this direction. So far, in the debug mode, I could not find the necessary methods. I’ll try to move the question if I figure out how (

I don’t know how to change the category of a post, I can only create a new one, but I can’t delete this one(

No worries. I changed it for you!

1 Like

No unfortunately I’m still sitting on this task, I found out that in the response from Zebbe the client, there is no field with the task name. I need to at least pull out the user’s tasks knowing his id. Maybe you know how to do it? Everything I found doesn’t work.

I was so desperate that I started writing from the GPT chat, all of its options assume that I either know the type of task, or do not work at all (but I do not know the type of task, I have to get the task to at least get its id if there is no name.

List<Job> jobs = client.newJobWorker()
    .jobType("my-task")
    .handler((jobClient, job) -> {
        // обработка задачи
        jobClient.newCompleteCommand(job.getKey())
            .send()
            .join();
    })
    .open();
Job job = client.newJobWorker()
    .jobType("my-task")
    .handler((jobClient, job) -> {
        // обработка задачи
        jobClient.newCompleteCommand(job.getKey())
            .send()
            .join();
    })
    .timeout(Duration.ofMinutes(1))
    .open();
JobWorker worker =
        client.newWorker().jobType("task-type").handler((jobClient, job) -> {
          String jobName = job.getCustomHeaders().get("name");
          System.out.println("Processing job " + job.getKey() + " with name " + jobName);
          jobClient.newCompleteCommand(job.getKey()).send().join();
        }).open();
List<Job> userTasks = jobClient.newActivateJobsCommand()
    .jobType("user-task")
    .workerName("worker-name")
    .maxJobsToActivate(100)
    .variables("{\"assignee\":\"" + userId + "\"}")
    .send()
    .join()
    .getJobs();
client.newCreateInstanceCommand()
  .bpmnProcessId("process-id")
  .variables(variables)
  .send()
  .join();
List<Task> tasks = client.tasks()
  .taskAssignee("user-id")
  .list();

None of this works

Am I understanding your query correctly?

“For a given user, the task is to get all available User Tasks that that user can complete”

If so, there’s a subtle nuance that is glossed over a fair bit in the documentation: User Tasks are accessed via Operate, not via the Zeebe Gateway. Operate runs its own DB, and listens to events that are exported from Zeebe to know when there are user tasks. This is where User/Task assignments happen… In the Zeebe cluster, they are just “User Tasks”. Operate has its own set of APIs (REST and GraphQL) that you can access to find tasks based on a user-id.

1 Like

Not certainly in that way. My task is this.
A new user has joined the team. He sends an application for onboarding through a bot with Rocket chat. Zebbe client starts the onboarding process.

return zeebeClient
                .newCreateInstanceCommand()
                .bpmnProcessId(startParameters.processName)
                .version(zeebeProperties.version)
                .variables(variables)
                .requestTimeout(zeebeProperties.timeout)
                .send()
                .await()

He gets an answer.
“Onboarding started, process ID: 4503599631556252”
After that, he goes through different stages of onboarding.
My task is that the manager can send a request through the bot, and look through the user’s identifier on which active onboarding task in the camunda he is.

Are you saying that Zebbe’s client does not have such an opportunity, so I did not find it? I need to connect to the web where is the user data stored? In principle, I initially wanted to do this on the backend lead, insisted that I would use the already integrated zebbe client.

Perhaps I could get the active task by process ID, but only the user knows it, and not his manager who needs it.

You would like to identify where - in a process - the token(s) is/are sitting, based on searching for a specific process instance, not knowing the process identifier.

Is that a more accurate description of the ask?

I’m not 100% sure where the requests will need to go (Zeebe vs Operate vs Optimize):

  1. Identify all processes started based on a specified initiator
  2. Select appropriate process from results
  3. Get active task(s) for that process
  4. Render / Visualize result

I think these are all things that Operate does, so it’s clearly possible. But it might require querying the Operate DB rather than the Zeebe cluster directly.

1 Like

yes, you understood me correctly. Horsho I’ll try to figure out how to find the base from this application and you can get it, thanks. So, I’ll look for what Operate and Optimize are :)))))