Sending email when a new task comment is created

Hello,

I am using Camunda Rest Api with spring boot. I need to send an e-mail when the following endpoint is called:

https://docs.camunda.org/rest/camunda-bpm-platform/7.19/#tag/Task-Comment/operation/createComment

I tried to implement a custom HistoryEventHandler to intercept the comment but it seems that only BPMN elements are handled by Camunda in a HistoryEventHandler, even using a full history level.

There is any way to intercept this comment creation?

Thank you,

Denis.

Hello my friend!
Welcome to forum again! \o/

I believe that for your specific scenario, it makes more sense to create a class implementing a task listner than an event handler.

Because comments are part of the scope of a specific task, I think the correct option is to use task listner.

The event handler is used more for global events, for example, doing something when an instance ends, or when an instance starts.

William Robert Alves

Hello William,

Thank you for answer! Makes sense! What event of a tasklistener can I use to intercept comment?

Denis.

I’m happy to be able to help my friend! :smile:

Huuuum… this will depend on the context of your process, but I believe that “create” or “update” would be the most appropriate.

I leave the Camunda Doc link below, which may help to have a more macro view of this.

William Robert Alves

Olá William,

Agora que vi que você é brasileiro (kkk), então, eu já fiz com tasklistener para create/complete/assignment, porém o desafio está resolver a questão de criação de comentário.

Obrigado

Opaaaa mestre!
Sim sou BR sim! haha \o

Acho que não entendi bem, qual a “questão” que vc precisa resolver referente a criação de comentário.

Não seria quando alguem adicionar um comentário, o task listner iria interceptar isto, e ali no próprio task listner você implementaria a logica de enviar o email para quem necessita?

Ou não entendi bem sua necessidade… se quiser explicar melhor, show!

Se puder, vamos manter a conversa aqui em inglês para que os demais membros do fórum possam entender caso tenham a mesma dúvida! :sweat_smile: :pray:

Tamo junto!
\o/

Hi @denisgmarques ,

sadly I was not able to follow the two last posts, so I am not sure whether your problem is solved.

Regarding HistoryEventListener I also think there is no HistoryEventTye around comments. Tho, as proposed by @WilliamR.Alves , you could react to the update event with a TaskListener. Then, within your TaskListener implementation you could retrieve all comments that are connected the current ask using the TaskSericeImpl#getTaskComments api and possibly check by timestamps.

Note:
Be aware that he proposed api is not part of the core api provided by the interfaces so it might be modified or deleted in the future.That might also be the reason why there is no HistoryEventType or UserOperationLogEntry type

Kind regards
Adagatiya

Thank you my dear @Adagatiya !

I apologize, but our friend discovered that I am Brazilian and started some of the communication in PT-BR, but I have already asked to communicate in English so that everyone who may have the same question can easily find the answers in a language that is easy to understand for everyone! :sweat_smile:

I asked him to explain to us better what idea he has, so that we can tell him a suitable way to do it, in addition to the tips I have already provided previously.

I’m waiting for his response.
Thanks for helping by sharing your knowledge too! :pray: :handshake:

William Robert Alves

Hi Adagatiya,

Thank you for reply. I tried what you said but it seems that non commited comments are no retrieved in getTaskComments method.

Denis.

This thread has a solution: Task comment create history event
I will try it!

Tks.

1 Like