Automate your manual tasks with Camunda and Trello!
Tags: camunda, zeebe, trello, automation
Published: 2020-12-10 16:24:20

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

Let's start!

## Why Trello?

[Trello](https://trello.com/) 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.

## Setup

To use our example with Trello we need three things:

- Trello Account
- Trello API Key and Token (available at [https://trello.com/app-key](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:

1. Create a new Trello Card.
2. Get notified when something changes on a Trello board.

## Create Trello Card

This task should of course be executed by a worker. The following controller takes care of the communication with the **Trello API**:

{% gist https://gist.github.com/urbanisierung/fbc3303426dd070c4c2c91470fe91a7a %}

What is still missing is the integration of the controller into the **worker**:

{% gist https://gist.github.com/urbanisierung/75a3e2c3750a5e130707cfee9752cee6 %}

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.

## Set up a Webhook

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](https://developer.atlassian.com/cloud/trello/guides/rest-api/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:

{% gist https://gist.github.com/urbanisierung/6d0f895a7ce0a8c8b28d908f19217c5f %}

Two special features to which we would like to respond:

We check whether a card has been changed:

```js
payload.action.type === 'updateCard' &&
```

And we check if the cards are on the `Done` list after the change:

```js
payload.action.data.listAfter.name === "Done";
```

The Id of the card that has changed is shown above:

```js
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

Finally the `POST` request looks like this:

```bash
POST https://api.trello.com/1/webhooks?key=xxx&token=xxx&idModel=xxx&description=restzeebe&callbackURL=xxx
```

## Let's model the process

**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.

![simple process](https://dev-to-uploads.s3.amazonaws.com/i/x3vu9e3zg76mx3gvx4f5.jpg)

You can see the whole thing in action here:

{% youtube FRNMKZAz-AM %}

In the video two browser windows are arranged one below the other. In the upper window there is a tab with [Restzeebe](https://restzeebe.app) and **Operate**, in the lower window you can see the **Trello Board** that is used. The following happens:

1. **Restzeebe**: Starting a new process instance with the BPMN Process Id `trello`.
2. **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.
3. **Operate**: A running process instance is visible, which waits in the Message Event.
4. **Trello Board**: We complete the Trello Card by moving it to the `Done` list.
5. **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.

## Now comes the wow-effect (hopefully)

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**:

[![new employee process](https://dev-to-uploads.s3.amazonaws.com/i/bt9oio1p853upo77snze.jpg)](https://cawemo.com/share/d0634247-d7ab-489f-a918-ac67dcbb4816)

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
- Jira
- Todoist
- 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 ;)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/86lkk9r8mqt06gn79vld.jpg)

---

Let me know if the article was helpful! And if you like the content follow me on [Twitter](https://twitter.com/urbanisierung), [LinkedIn](https://www.linkedin.com/in/adamurban/) or [GitHub](https://github.com/urbanisierung) :)

---

<span>Header Photo by <a href="https://unsplash.com/@agk42?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alex Knight</a> on <a href="https://unsplash.com/s/photos/wow?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>

<span>Last Photo by <a href="https://unsplash.com/@maxsaeling?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Max Saeling</a> on <a href="https://unsplash.com/s/photos/task?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>