API response events
This article assumes that you are already familiar with sensor events. If not, please refer to this guide.
“API response event” is a new type of external event, similar to “Sensor” and “Datasource events”. These can be set up anywhere where an “API call” is happening.
- It can be an “Action” bound to a “Sensor event”.
- It can be a widget click type on the “Other” tab on some widgets, in the “Jump” section. (Where you would choose “Jump to” or “Popup”.)
- It can also be a “Submit action” of a “Submit button”.
“API response events” are unique for every API call, but they can be copied and pasted between instances.
On the top of the window you will need to set the “Main property name”. You should design your API in a way that the response will always have this property.
In the “Main property value” column you can set up the different possible values of this always present property, that you want to handle.
If an “Action” is not “Final”, multiple actions with the same “Main property value” will be executed until one “Final” is not triggered.
If you turn on “Use regular expressions for values”, similar to “Sensor events”, all values will be treated as regular expressions and it will be checked whether the the value provided in the main property name field matches one of these.
Available action types have an overlap with “Sensor event action types”, so please refer to that section for more information.
The only difference is with “Interact widget”, because “API response actions” can interact with not only interactive widgets, but also with any widget that can be bound to a “Datasource”. Mostly useful with “Text” and “Image” widgets.
For example, you can create a system with an RFID sensor and an API that sends back the details of the selected product or employee or guest, etc. In this case, you would set up your “Sensor action” similar to this example. Your API will be called as “POST” and the body will contain 3 fields: “id”, “event” and “value”. Depending on your sensor, either event or value will hold the RFID being scanned. Your API should respond with an object that contains a field, such as “RFID_RESPONSE_CODE” and all the fields for the different widgets on the details page. It could be “name”, “image_name”, “price” or “room number”, etc. Don’t forget to turn OFF ”Final” for all these “Actions”, so all the widgets can receive their values.
Your “API response actions” would look similar to this. You widgets can be positioned and formatted like any normal widgets. This will only change their value. Images work the same way as data bound images, so any value that would be valid in a data field bound to an image is valid here as well.