I’ve got a great read for you today!
Our brilliant Dimitris from the Solutions Team sat down and wrote a piece about using functions on Make. Since there’s quite a bit to cover, we’ll be posting in a couple of parts.
Why not dive right in?
Fundamentally, the goal of automations is to move data between apps. However, once you start building more complex automations you realize that simply moving data from one place to the other is not always that useful. In many cases data needs to be transformed, constructed or deconstructed along the way in order to achieve the expected outcomes.
Functions are what makes this possible, and the aim of this article is to give you a beginner-friendly introduction so you can realise their power and start utilizing them in your automations.
To access Make scenario functions, you simply need to click on any module field in which you want to add data.
A small window will pop-up on the side, where you will first see a list of all available data elements from previous scenario modules, as well as four tabs where all functions can be accessed from.
Before diving into different function categories, let’s first build a scenario that will help with demonstrating different function use-cases.
This is a simple scenario that aims to retrieve all new submissions from a form and create a row for each one in a Google Sheet.
The form belongs to a website development agency and allows prospects to request a proposal by entering their project details. Here is a breakdown of the form fields:
The form fields and their responses are nicely organised in a collection, which can be mapped to subsequent modules, such as the Google Sheets > Add Row module, included in this scenario.
However, simply passing the raw data from the form submission to the Google Sheet doesn’t help much when it comes to creating a proposal. A member of the agency will still have to manually review the request and create a proposal from scratch each time.
The goal is to automate the process so the proposal is automatically calculated and generated based on the form inputs of the prospect. In the next sections, as well in the upcoming articles of this series, we will be exploring the ways in which this solution can be achieved using functions.
General functions are mostly used for conditional statements. For example, in the above use-case, the service that the prospect selects is in the form of a sentence. This makes the Typeform more engaging.
However, when it comes to a scenario making logical decisions based on the selection, or organising the data in a manner that is easy to see, it will be better to summarise the service names to:
- ‘E-Commerce’ for ‘I want a website for my e-commerce business’
- ‘Informational’ for ‘I want an informational website’
- ‘Landing Page’ for ‘I want a landing page for a product I’m selling’
- ‘Blog’ for ‘I want a blog’
This can be achieved dynamically using functions.
At the Service field on the Google Sheet module, instead of simply mapping the value of the ‘Please select what you would like to achieve’ data element from the Typeform module, we can instead have an if function which checks if the value is equal to ‘I want a website for my e-commerce business’. If it is, the value of the module field will be set to E-Commerce instead.
In the above field, the
if function takes an expression as an input. An expression is simply a statement that evaluates to either true or false.
Let’s take a look at some generic expression examples:
1 < 3
- This expression evaluates to true, since 1 is less than 3.
- Notice how we are using the < operator which is part of the General functions.
(4+1) > 9
- This expression evaluates to false, since 5 is not larger than 9.
- Notice how we are using the > operator which is part of the General functions.
1 + 1 = 2
- This expression evaluates to true, since 1 + 1 is equal to 2.
- Notice how we are using the = operator which is part of the General functions.
Hello = Hi
- This expression evaluates to false, since the word Hello is not the same as Hi.
- Notice how we are using the = operator which is part of the General functions. In the previous example, this operator was used for an arithmetic comparison whereas now it is used for a string comparison. This is unique to Make so you don’t have to use multiple different operators based on the data type.
Similarly, in our use case, if the value of the Typeform field is equal to the one we have specified on the right-hand side of the
= operator, then the expression evaluates to true.
When the expression evaluates to true, the
if function will assign the value after the first; as the value of the module field. If the expression evaluates to false then the
if function will assign the value after the second ; as the value of the module field, which in this case will be ‘no match’.
However, ‘no match’ is not a useful value when the expression evaluates to false. Therefore,
if function is not ideal for this use case, as we need a way to summarise the other four service options the prospect might select on the form.
To achieve this we can utilize a more powerful version of the
if function, known as the
switch function is very similar to an
if function, with the difference that the expression can be evaluated against a list of values, instead of just one value.
Here’s a colour-coded version of the above screenshot to help you understand how a matched expression value-case gets replaced with a new value.
For example, in the case where the Typeform field selection is equal to ‘I want a website for my e-commerce business’, the
switch function will evaluate to the first case (i.e. the red one). The module field value will then be replaced with ‘E-Commerce’ since this is the resulting value for that particular case.
Similarly, if the Typeform field selection is equal to ‘I want a blog’, the
switch function will evaluate to the third case (i.e. the purple one) and the module field will be replaced with ‘Blog’.
switch function can have as many cases as you want. There are no limitations.
In summary, the if and switch functions combined with operator functions are the most commonly used functions in the General category and can help make your automations more simple and less repetitive.
In the next part of this series we’re taking a look at Math functions.
They are also important, as they allow you to calculate values based on data retrieved from your scenario modules.
The goal of the following episode is to dynamically calculate the price of the proposal based on the prospect’s form inputs.