John and his gym

We know that getting started with Protokol isn't an easy task. Here we will talk about some important things inside the platform, and some more complex things, maybe complex but easy to pick up once you start using them.

First of all, let's clear some things up on what Protokol is. So, Protokol in the base is a data management platform that provides an easy way to store and manage your data. On the other hand, data is very broad, and some data means nothing in one format, and in the other format, it makes more sense. Keeping in mind that, we give you a way to store and represent your data in the way you want it to.

When we look from another point of view, storing and managing data is some kind of a process. Protokol provides automation of these processes by providing users with a user-friendly workflow editor.

Let's just do some simple examples, let me tell you the story.

The story

We have our close friend John, and he is the gym owner. First of all, John wants to manage his customers. He creates a new component called Customers, using Protokol admin console, navigates to settings, and adds a couple of fields, like, name, email, address, and birthday. He wants to know some basic information about his customers. He decides this is enough for now.

Now he can test his component in the development environment, he can add some customers to see how it works. For him, it seems that it works well and he proceeds to deploy his component to the live environment.

Great, he is now collecting basic information about people that are coming to the gym and everything looks good, or, just for now.

The gym is growing bigger and bigger, and John needs some help, so he decides to hire someone. On the first day of work, he is showing his new worker the Protokol platform and teaches him how to use it. But he realizes that he doesn't want to give access to the admin console to anyone. John creates new roles for his workers and assigns them under those roles, they can now operate in limitations that John defined.

As the business goes well, John thinks he can add more customer fields, and automate some processes.

Let's automate

John was thinking that he can add some customer identification numbers so he can keep track of his customer easily, he can also send a welcome email to newly registered and, he can send emails to his customers about new stuff going in the gym.

First of all, we can start with a customer identification number, John doesn't want to input this every time he creates a new customer. There are two ways he can approach this issue. In Protokol we have something called mutators and actions.

The mutators

Types of mutations

Like in the image above, we can get pretty much a good sense of what mutators are. In the case of John, he wants to generate customer identification numbers when he starts with the creation of new customers. For these cases, our platform provides you with a code editor, where you can create your own expressions that will be evaluated.

if (value === null || value == "") {
    return Math.floor(Math.random() * 10000)
}
Expression executed for GET mutator

John added the following expression to his GET mutator, now, the customer identification number is generated every time John starts to create a new customer.

The actions

The actions aren't automatically triggered and they demand user action, hence the name.

Create new action

Let's simulate the same behavior from mutators but only using actions. We have 2 things to keep in mind: Display Condition, and Action.

Display condition is an expression that is evaluated and must return a boolean. The platform will know should action will be visible or not (This applies to create and edit page).

if (model.customer_id === null || model.customer_id == "") {
    return true
}
Display condition for action

We create display condition for our action that we want it to only be visible when Customer ID isn't set.

Action is an expression that will be evaluated when action button is clicked. We want action to generate a Customer ID and store it inside the customer_id field.

model.customer_id = Math.floor(Math.random() * 10000)
Action expression

Now we can save it, and our action should be visible on create or edit page, depending on how display condition is evaluated.

Action visible on create/edit page

Now, when we cleared this out of the way, let's talk about the event flow chart.

The event flow chart

The event flow chart is the tool provided by Protokol that is providing way to react to events that happen on platform and an interactive way to bring automation to the next level.

When we speak about John, he would like to send a welcome email to his newly registered customers. He can do this by using the event flow chart.

First, he needs to define what event he wants to react to. There are 3 built-in events: Create, Update, Delete.

John starts by creating an event by double-clicking or on the plus sign in the top left corner.

Add event node with create event

Next, he wants to create an operation node for sending emails.

Create operation node for sending emails

There are multiple operation nodes but they are not part of this walkthrough.

Different actions for node prompt for different data, in our case there are some of the fields that we can input.

Notice how we are using mustache syntax inside the email field, this will be a placeholder. In the end, placeholders will be bound to the current model that the event is triggered for.

It is possible to use HTML for the email body, but John doesn't have any template yet, so he is sending a simple message.

Welcome {{name}}, we are glad you are with us. Your ID number is: {{customer_id}}.
Body of the email

In order for everything to work now, he needs to connect his event to the operation node and his welcome email is ready to be sent.

Conclusion

With a little bit of knowledge and our help, John was able to create fully functional software to help him and his business grow. To integrate people and processes into his business without much trouble. Now John has an interface to build on, and continue expanding his business and unique use case, with us by his side.

Strahinja Djuric

Strahinja Djuric

CTO & Co-Founder of Protokol, passionate about his work and enjoying creating new and innovative stuff.