How to use webhooks to update variables and trigger logicblocks in Apilio

Webhooks can be used to update your Apilio data and evaluate your Logiblocks from other apps and services, for example: iOS shortcuts (Siri), Tasker, Zapier, and many more.

In this post we’ll see how we can use these handy URLs to update your data in Apilio from any third party service or apps that can handle webhooks.

Webhooks URLs are in the show view for any variable or Logicblock

These urls are always displayed in the “show” view for any element.

Update boolean variables via webhooks

Variables in Apilio store data from devices, apps or services. With webhooks, you’ll be able to update your boolean variable to true, to false or to toggle it (if it was true, it will be set to false, and if it was false, it will be set to true).

Update string variables via webhooks

String variables can be cleared via webhooks (delete the data they store) or you can set them to a different value. You’ll need to append &value=new_value to the end of the URL, where “new_value” is the new string you’d like to update the variable to.

Update numeric variables via webhooks

Numeric variables can be set via webhooks and you can also do a couple of mathematical operations with them: add a number to the current data stored, or subtract a number from the value. In all these three cases, you’ll need to append &value=some_value at the end, where some_value is the number you wish to update the numeric variable to, or that you wish to add/subtract.

Evaluate a Logicblock via webhooks

You can have any external app launch a Logicblock automatically by using this webhook. This is useful for example to use a widget on your phone to launch a Logicblock manually. You’ll find it in the show view of your Logicblock, at the end of the page.

Activate or deactivate a Logicblock via webhooks

We’ve added two new capabilities via webhooks, so you can automate if you wish to deactivate a specific logicblock.

You can use this to for example, deactivate a specific Logicblock when you are away on holiday, and then make it active again when you are back home. You can also use this to manually deactivate/activate a specific Logicblock from your phone.

Examples using webhooks

:bulb: Related articles

1 Like

works great @Anna thank you :bowing_man:

Please could we add multiply and divide as well as add and subtract to the numeric variable featues?

@pebneter, @Anna

Would it be possible to retrieve the status of a condition (true/false) via webhook? That can be very useful for Tuya-based conditions.

2 Likes

We are working on an update and extension to the REST API (https://documenter.getpostman.com/view/7602053/S1TSZeSA?version=latest).
Can you elaborate from which system you would want to get that state information?

1 Like

For example, door sensors.

I have a Siri shortcut which runs when I say “What’s the status of the garage door?”

I have currently implemented it through a logicblock which checks the status of the door (positive if closed, negative if open)

My Siri shortcut calls that logicblock through a webhook, parses the JSON result, and shows the result via notification and also voice (in case I am asking via HomePod or CarPlay)

I even have a Siri shortcut that checks both garage gates and informs about their status. See it in action in this video: https://www.dropbox.com/s/4bztrjhy4qiana6/2021-03-09%2015.37.20.mp4?dl=0

3 Likes

Thanks for this @teknofilo! Amazing! :clap: But Dropbox is reporting the link as deleted?

Try again, I deleted the file by misstake

1 Like

Works great now thanks!

Impressive stuff - thanks for sharing! :star_struck:
I never took the time to check out iOS Shortcuts in details, and I must say it’s way more powerful than expected.

2 Likes

I am not very familiar with it, so I had to “google” every line of code. Being used to other languages like PHP, I find it a little bit complicated.

1 Like