Domino effect with software

101 course on webhooks and crowdsourcing

16 August 2018

Post by Daniel Lombraña

Cover photo by Public Domain Pictures

Reading time ~ 9 minutes

GIFs & memes ~ 0

arrow_back Back to entries

Everyone has played as a kid with a domino. And everyone at some point has tried to build one of this amazing domino effect:

via GIPHY

You usually started like this

via GIPHY

And you master it.

via GIPHY

The domino effect is also known as a chain effect, and it is defined as: “the cumulative effect produced when one event sets off a chain of similar events”. One domino piece falls and makes another one to fall, and this goes on and on until all the pieces are down (or one piece doesn’t fall).

At some point you might master dominos, so want to try something more challenging like a Rube Goldberg machine.

via GIPHY

A Goldberg machine is defined as “a machine intentionally designed to perform a simple task in an indirect and overcomplicated fashion. Often, these machines consist of a series of simple devices that are linked together to produce a domino effect, in which each device triggers the next one, and the original goal is achieved only after many steps.”

Amazing, isn’t it? There are people from all over the world building these machines to have fun and learn new skills. Dominos and Goldberg machines are tangible objects; you can touch them, you can build with them. However, here at Scifabric, we work with the intangible: software and we love chain reactions and Goldberg machines, so can we develop systems that behave like them?

The answer is yes, and by far we are not the creators of them. We’ve re-used it, and this comes from the very early days of computing. Actually, it comes from the Unix world:

  • Write programs that do one thing and do it well.
  • Write programs to work together.
  • Write programs to handle text streams, because that is a universal interface.

Does it ring the bell? (Yes, I know, a bad joke, but who could resist!)

The case is that this philosophy has its roots in the open source community, and many developers are building nowadays microservices (or ecosystems as we call them) to develop small services to work together via APIs. With these interfaces, you can then chain actions, and achieve a goal after several (or many) steps have been completed. In web development, this is usually referred to as workflows or pipelines. Also, as you can imagine, we build PYBOSSA to be able to perform these chained actions so we can create very simple (or complex) workflows for crowdsourcing, microtasking or citizen science projects.

Workflow

For us, a workflow is just a way of chaining actions to get a desired output or outcome. Imagine that you want to achieve the following scenario: “I want to receive an email when a text has been transcribed with the final result (as an attachment) and in the body the statistical analysis” or “When a task has been completed, a group of experts of my team will review the result before publishing into our production server.”

While it might sound difficult at first, with PYBOSSA is easy, as we have designed it in a way that you can create whatever you want. However, how you can achieve it? Moreover, is it possible to do it in real time? We have seen that Goldberg machines work in real time, as soon as an action happens we have a reaction, so we would expect the same with software, right?

Webhooks solutions

Wikipedia defines a Webhook as this:Webhooks are “user-defined HTTP callbacks.” They are usually triggered by some event, such as pushing code to a repository[3] or a comment is posted to a blog.

In our case, the event that triggers the callback is whenever a task from a published project has been completed. What does it mean being completed? It means that the task has collected all the classifications, analysis, etc. for it. By default, PYBOSSA gets 30 different responses for each task, but this number can be modified whenever you want. We set it up to 30, so you can do an excellent statistical analysis.

For example, let’s imagine that we have modified a task to require ten answers instead of the 30. The server only has nine (saved in the database), but when the tenth classification is sent, PYBOSSA will mark the task as completed, trigger the webhooks callback so another service can do the statistical analysis. In other words, we’ve started the domino effect.

As we want to provide a robust solution for your statistical analysis, PYBOSSA creates for you an empty result for the given task, where you can store if you wish to, your report. Nice, right?

With this, you should have now an overview of how PYBOSSA webhooks solution work.

A template for starting with webhooks

We’ve developed for you an open solution that shows how you can handle the webhooks with a microservice.

The template has been created as an example for a project where you are doing image classification. The project is asking people to classify images, and there’re typically two or more options to choose from. When a task is completed, the template will analyze for you which is the most voted classification and save it back in the server. For example, if you are asking your users if the photo has a green dog in it, and the answers are yes or no, the template will tell you which is the most voted answer.

In our documentation, we explain how you can install and run the server, so we will not be covering it here, as what we want is to show you what you can achieve with this solution.

Ideas for workflows

One of the main aims of this article is to explain the potential of PYBOSSA and its tools. Why? Because we get asked lots of times if it is possible to create a complex workflow to achieve a goal with the crowd.

Thus, in the next sections, we will explain the top 3 most asked questions about workflows and how you can solve them with our technology.

Validation by experts

via GIPHY

We get asked this a lot. Is it possible to get only a few persons from our team to review the final results before publishing them into our production servers? The answer is yes, you can.

All you have to do is creating one project for the volunteers, and another one for your team. The last one can be password protected, so only your team could access it. Then, the workflow would be like this: when a task is completed in the volunteer’s project, the webhook will be called. The microservice will get the notification, it will download the task and its associated task runs (classifications), run the statistical analysis, if the quality of the report is good, it will create a new task in the team’s project for them to review. Moreover, with our Onesignal library you can send a push notification to those users to notify them about a new item to review.

Then, the new task can be reviewed by the team, and they can answer an elementary question like: Do we publish this information into production? As before, you can use the webhooks to do the analysis, and if the majority agrees, then, it will be published into production via the webhooks solution.

Real-time notifications to keep the users engaged

via GIPHY

PYBOSSA has a third-party integration with OneSignal web push notifications.

Web push notifications allow users (anonymous and authenticated) to subscribe to notifications from a given project. The exciting part of this solution is that Android and iOS phones can subscribe as well. This means that users will get a standard notification, like a WhatsApp, with action buttons, info, pictures, etc. Nice, right?

As this allows you to communicate with anonymous users as well, it is pretty handy to keep your community engaged. As an example of this solution, we build it for our Sr. Alérgeno project. In this project, we are asking Spanish speaking people to read labels from food products. Why? Because we want to classify them as gluten-free or with gluten. The reason behind this project is that in Spain there’s not a public list of products that are gluten-free, and we want to remove this barrier.

When a product is classified, if the user has been subscribed to these notifications, she will get in her phone a notification with a picture of the product that has been classified and its result: gluten-free or not. If the user touches the notification, it will open the web browser to get the result of the classification. In this way, we keep the community engaged without having the users to visit our site all the time.

How did we build it? Obviously, with the webhooks solution. When a task is completed, the statistical analysis is done, and with that result, it sends the push notification via the OneSignal service. Simple and useful!

Giving badges to your users

via GIPHY

We get this question a lot: is it possible to give badges to the users if they answered the question correctly? And the answer, obviously, is yes.

When the webhooks template downloads the answers submitted by the users, it can discover who answered right or wrong based on the statistical analysis. Imagine, that 95% of the volunteers responded yes to a question. Then, all you have to do is filtering which users answered yes, and based on that use the PYBOSSA API to get the user object and give him/her a badge.

As an extra step, you can build on the previous case and notify the users that got the badge via web-push notifications.

In summary, with our technology, you can build simple or complex workflows without problems. It is up to you to decide how elaborated it is to meet your goals.

Share this blog post: