Start a process when a counter reaches N

Hey all!

New to the Camunda world - awesome platform! :slight_smile:

Let’s say I want to start a process after a user has performed N actions on my app. I see two approaches to this:

  1. Send each event to Camunda, making it increment a counter variable and model the process so that it “really starts” after counter reaches N
  2. Count the events on an external platform, and only trigger a start on Camunda after the counter reaches N

What would you do in this situation? Any other options I’m not considering here?


Might be a good use case for Conditional Event. By using that you could wait until N reaches a specific number and the fire off something.

That is of course provided that the process instance is already started and active. If not then it’s best to have the front end do the counting. :slight_smile:



I would suggest you have already answered your own question - you want to start a process after n events, hence by definition, your counter must be external to the process.

You touch on a couple of guidelines I give my developers and process analysts;

Don’t program in BPMN - I find developers often try to program in BPMN. Hence sending an event to a process just so it can count them is getting awfully close to programming in BPMN.

Be very clear and concise as to when a process starts and when it ends. Hence as stated you have already determined that your process starts after 5 events. If you find you are trying to implement the counting behaviour in your process, then you may be violating my first and this second principle,. If you still think you need to implement it this way, then perhaps you really have two processes. One begins on a first event and ends after 5 events. The other begins when started by your first process.




building on Robs last point of if you really need to “program” it, here is a “programmed” example
In this example the gateway is just used to show three different ways you could execute logic.

Thanks guys! I’m looking forward to using Camunda in production :slight_smile:

By the way, our main use case will be to build user journeys and perform communication tasks across those journeys. If anyone has a similar use case, I’d love to be in touch to exchange best practices!