How to build a Calculator with Integromat?
How to build a custom Calculator with Integromat and return values anywhere, like as HTML on a website or in a chatbot.
Watch the video or read the guidelines below. 👇
The quick answer is: Integromat offers a wide range of constructs and scenarios for you to create a calculator with Integromat. With the help of variables, flow controls, conditional operators, and arithmetic operators, you can calculate the results of any formula you can imagine. Integromat is one of the best online software development platforms that not only offers a wide range of constructs for you to create a calculator with Integromat, but also offers an intuitive and easy-to-use web-based dashboard where you can re-configure your formulas and create new ones! Now, how can you create a calculator with Integromat where you just input the weight, height and metric or anything that you need for the formula in the URL, press enter and get an output like this?
If you want to learn how to set this up yourself, then continue reading below.
Table of Contents
- How to make calculations with Integromat
- Different ways to display the results of calculations
How to make calculations with Integromat
In this article I will show you exactly how you can make calculations with Integromat, which you can use for any kind of integration. You send data to Integromat from any kind of source, do the calculation inside of Integromat and then pass back whatever value you want. In this case I’m using the BMI, which is calculated by the weight, the height, and then of course, depending on the unit – metric or imperial.
Here is what the scenario would look like.
The scenario makes use of a webhook where you send certain parameters. For example, let’s send 80 as weight, which is in kilograms. Then send the height of 1.8, which is in meters. And the unit is metric because I’m in Europe. So I use metric for this example.
But in the whole scenario there is a separate path for calculating in imperial units so you can make it fully dynamic. In any case the unit is imperial, then the route goes the other path using the correct formula .
Let’s get into the actual formula. The formula for the BMI is weight divided by the height multiplied by height. This is how I set it up in Integromat using the value passed from the webhook. In the webhook data we get the parameters you’ve previously seen in the URL.
We can then use them further as the Variable value inside of our Set variable module.
This is what we get as an output. 24.69, and then all these decimals here and then we want to send it back into the browser.
Different ways to display the results of calculations
1. Number Only
I prepared different return values possible to set up. The first one is simply sending the number back. It says, “Your BMI:”, and then it rounds the metrics to two decimals because of course, we don’t want to have the full value with a long list of numbers after the decimal point. To cut off everything after the two decimal places is slightly tricky. It’s a little workaround. Multiply the number by 100 first, so that would be 2,469.13. Then we round it normally because the rounding function will always round it to full numbers to integers. So it would be rounded to 2,469. Divide it by 100 again. We get back the original number, which is 24.69. And that’s how the rounding is done for a certain amount of decimals. If you want to have more decimals, then you can use 10,000, for example.
You can return these values to wherever you want. You can add these to a Google sheet or do whatever you want with these or use these in a chatbot. For example, if you want to do advanced calculations or other parameters in your chatbot, you can pass the values from your chatbot to Integromat, do the calculation on Integromat, then send the result back into the chatbot and display it in a message.
2. Number with Category
Another way to set up the value is including a category.
Above you could see a bunch of formulas with the BMI range of what is counted as severely underweight, underweight, normal, overweight, obese, and so on. I’ve already implemented these ones like the standard numbers for the BMI, and we’re doing it by layering a bunch of “if” functions. So “if” the actual BMI that we got out of our formula is lower than 16 then it is considered as “Severely Underweight”, and if it’s not under 16, then we check the next “if” function. If it’s between 16 and 18.4, then it’s “Underweight”, and then we continue to do this until we have covered all of the different categories available. So the next one is between 18.4 and 24.9 which is “Normal”. 24.9 up to 29.9 is “Overweight”. You get the point. At the end is just the else. So if it’s not between 34.9 and 39.9, which means if it doesn’t match any of the previous expressions, then it’s definitely over the 39.9, and then it’s “Morbidly Obese”.
At the very end after functions, type in additional brackets to make sure that all gray brackets are closed meaning all functions got the necessary brackets. Where there are brackets without a gray background anymore, then you’re good to go. Removed the unnecessary brackets and keep the proper ones.
Running the scenario we get the category. This also gives the possibility to do more with the number got out from the calculation. You can use a specific number and not a number range. The switch function may be used, which is quite handy for these use cases, and then give that back as value to whatever source you have or wherever you want to send that value, for example, a chatbot.
If you want to display the results on a browser, you can use HTML in the webhook response. This is the structure to use.
There’s the documentary HTML header, then the body with normal HTML text. Make sure that if you’re using HTML tags, the new lines won’t work anymore if you just type them inside of the editor. You have to use <br> for new lines. Use font size for styling and align tags. That way the text will be big and centered.
And here are the texts for the BMI results and the BMI category.
The same setup is used in the other path using units in imperial. Only the calculation is slightly different. You just have to set the unit to imperial when you send the data.
This is how you can create any kind of calculation within Integromat and return the value to wherever you want to have it.
In case you want to learn more about how to use Integromat functions, for example, layering the “if” functions or using advanced math functions and doing all these kinds of things. Then check out my Integromat Functions Cheat Sheet. It walks you through all the available functions on Integromat, explains them, shows you examples how to use them, and gives you copy and paste ready functions that you can paste into the Integromat modules as workable functions. Use them right away. They’re super helpful. I really recommend checking this out because it helps so much in speeding up the learning progress in Integromat.