Send a customised mail to the user task assignee with the user task url to work when a user task is created

Hi,

Working on a use case to send a customised mail to the user task assignee with the user task url to work when a user task is created. I don’t find any way to meet this requirement in Camunda 8 Self Managed. Can anyone have done or worked in this can help me?

Thanks in Advance
SG.

Hello my friend!

I don’t know if this really meets your expectations, but although I don’t have much knowledge of Camunda 8, I know that it has connectors for several very useful things, including sending emails.

Take a look at this connector here, and see if it works for you!

I hope this helps!

William Robert Alves

@WilliamR.Alves

Thanks for your response. I just checked that Sendgrid is an external service connector which is not within Camunda. Client may not want to sign up another api key for sending mail. Are there any options like Task Listener which was there in camunda 7 or anything such type which can be used to send mail in camunda 8 user task?

Thanks
SG

Creating an external task to do this with a library like JavaMail (if you work with Java, or some other library available), wouldn’t that be an option?

I believe that in Camunda 8 we do not have task listeners available yet unfortunately.

As I said before, I don’t have as much knowledge about Camunda 8 as some of our colleagues here on the forum.

Perhaps some of the great experts on Camunda 8, like @hassang , may have a more appropriate answer than mine to help you.

William Robert Alves

Hi @WilliamR.Alves @hassang

I am exactly looking for an option with Java. How I can call a java service task to send a mail or something like that as and when a user task is created to the assignee.

Thanks
SG

All user tasks in Camunda 8 have the same task type - io.camunda.zeebe:userTask - so if you create a job worker that is listening for that type, it will trigger every time a task is created. However, it is triggered when the task is created, not when the task is assigned, so you need to ensure that the task is already assigned by your process.

Some users have done similar things if you search the forum. Here’s one thread related to this: Job worker for user task

1 Like

Hello!

I think that you might be able to satisfy your use case if the user task assignee is computed before the task is created. So when the user task is indeed created it will be assigned to the user, and not to a group. Now you can attach a non-interrupting timer event that fires 1 second after task creation with a flow to your service task which in turn is implemented in Java

Hi @nathan.loding Thanks for your response.

I have written this.

	@JobWorker(type = "io.camunda.zeebe:userTask", autoComplete=false)
	public void  mailFromUserTask(final JobClient client, final ActivatedJob job) {
		LOGGER.info("client - " + client);
		LOGGER.info("job - " + job);
	}

This is getting called when a task i getting created and I can see the JobClient and ActivatedJob is getting printed. This is fine but I want to get here the task instance with task variables. i.e. task assignee, task instance id. The reason behind is to send a mail from here to assignee with task url to work by him. Can you please provide any example how I get the generated task detail here?

Thanks & Regards
S

There are multiple ways to accomplish this. The ActivatedJob class has a getVariables method, and you can fetch most of the details of the task through that class (JavaDoc). You can also use the processInstanceKey from the job to query the Tasklist API and pull down the task details directly from there.

The community created zeebe-simple-tasklist that has a similar implementation: it has a job worker that listens for user tasks. You can look at that code to get some ideas also: https://github.com/camunda-community-hub/zeebe-simple-tasklist/blob/05fe39db6a8869a0b62db50f113c7dcc032cc057/src/main/java/io/zeebe/tasklist/UserTaskJobHandler.java#L42

1 Like

Hi @nathan.loding

Thanks for your help.

Regards
S