In the first two articles of this series you learned how to execute workflows, how to control the flow and take different paths depending on the context, and how workers execute their individual code in a task. And of course, these were rather theoretical or unrealistic examples so far. Now I would like to present you a use case, which hopefully can be useful for some people: controlling manual tasks with todo lists.
They still exist, more often than you might think: manual processes. For example, a human being has to release a process, or complete a task that has not been automated so far.
How do you like the following case: a developer starts a new job in a company. There are tasks that have to be done before, at and after the start. These include things like
- Create an employee file
- Create accounts for different services
- Send welcome package
- Instruct employees
All activities that are mostly performed by humans. Wouldn't it be nice if this process is modeled and all responsible persons get corresponding entries on their Trello board to get things done? And wouldn't it be even better if the process is notified when the todo entry is done?
Well, I want that!
Not so much is needed to get there. Essentially, it's the following points:
- Trello API Key
- Trello Webhook
- Worker that creates new todo entries
- Worker that reacts to completed Todos
Trello is a great tool to organize and collaborate on tasks. For example, there might be a Trello board, that is processed by several people with shared tasks.
To use our example with Trello we need three things:
- Trello Account
- Trello API Key and Token (available at https://trello.com/app-key)
The API Key and the Token are necessary to communicate with the Trello API. For our example we want to implement two actions:
- Create a new Trello Card.
- Get notified when something changes on a Trello board.
This task should of course be executed by a worker. The following controller takes care of the communication with the Trello API:
What is still missing is the integration of the controller into the worker:
The basic implementation should already look familiar to you from the last article. It should be emphasized that the list and the name are not static. The parameter
idList is the ID of the trello list on which the new entry should be created. The name is the title of the new card. At the end the id of the created card is written back to the process context.
Our goal is to be notified when something changes on a board. If Trello cards are moved to
Done, our process should be notified. For this purpose Trello offers Webhooks. All we have to do is to provide an HTTP endpoint which is called by Trello when something changes.
For this we provide the following endpoint:
Two special features to which we would like to respond:
We check whether a card has been changed:
payload.action.type === 'updateCard' &&
And we check if the cards are on the
Done list after the change:
payload.action.data.listAfter.name === "Done";
The Id of the card that has changed is shown above:
const id = payload.action.data.card.id;
We use this Id as
CorrelationKey to the Message Event in the process, so that the correct instance reacts accordingly.
Finally, the only thing missing is the creation of the webhook for Trello. We can set this up using the Trello API. For this we send a
POST request to the API with the following query parmeters:
key: API Key
token: API Token
idModel: The id of the Trello board for which we want to get changes.
description: A description of the webhook.
callbackUrl: This is our HTTP Entpoint
POST request looks like this:
It's time to put all the pieces together! For this we model a process with a service task to create a new Trello card and a Message Event waiting for a Trello card to be completed.
You can see the whole thing in action here:
In the video two browser windows are arranged one below the other. In the upper window there is a tab with Restzeebe and Operate, in the lower window you can see the Trello Board that is used. The following happens:
Restzeebe: Starting a new process instance with the BPMN Process Id
Trello Board: A new Trello Card is created with the title
Nice!. So the worker has received a new task and created a new Trello Card via the Trello API accordingly.
- Operate: A running process instance is visible, which waits in the Message Event.
Trello Board: We complete the Trello Card by moving it to the
- Operate: The process instance is no longer in the Message Event, but is completed. The Trello Webhook signaled the change and our backend sent a message to the Workflow Engine.
Of course, the process is very simple, but it should only be the proof of concept. Since the Worker was implemented generically, we can configure lists freely. From the upper simple process we can model a process that sets up todos when a new employee signs his contract:
The worker shown above is only a very first iteration. It can of course become even more generic, so ideally someone who has nothing to do with the technical implementation can design and modify the process.
And of course I don't have to mention that Trello is just an example. Trello can be replaced by any other task management tool that offers an API:
- Github Issues
- Many others
I hope it helped you and you can re-use the use case in your context! I hope it helped you and you can re-use the use case in your context! I'm a big fan of automation so you have plenty of time for other things to put on your todo list ;)