UbiFunctions, Ubidots FaaS (Functions as a Service) module allows users to create their own HTTP API endpoints to perform actions or add functionalities that might fall outside Ubidots built-in features, and need to be tailored to each user application.
As custom user-built endpoints, UbiFunctions can be called via an HTTP webhook to execute any given logic but now, with native UbiFunctions Action in the Events Engine, doing so in a data-driven fashion will be easier than ever with the Event engine.
In this article, you’ll learn how to trigger an UbiFunction using Ubidots’ Events Engine.
Ubidots account: trial or licensed
At least one UbiFunction already created:
NOTE: if you don’t have one yet, follow this article first
Table of Contents
Create a new Event
Configure the Event "If trigger"
Configure the UbiFunction "Then Action"
1. Create a new Event
To begin, create a new event from the "Events" section in the "Data" tab in your Ubidots Navbar.
2. Configure the Event "If Trigger"
Next, configure the Event logic using Ubidots’ “ANDs” / “ORs” operators. For additional details on how to configure conditional and complex Event triggers, check out our Creating Conditional Events and Alerts user guide.
3. Configure the UbiFunction "Then Action"
With the "If trigger" event logic configured, it is now time to create the action – in this case calling an UbiFunction:
Step 1:Select UbiFunction
Step 2: Select the method to trigger the UbiFunction: GET or POST. The UbiFunction must have the same method configuration.
NOTE: when choosing GET, the default “Content-Type: application/json” will disappear.
Step 3: Search for and Select one function in the UbiFunction Name dropdown
Step 4: Add the appropriate headers. POST request require the default “Content-Type: application/json” header.
Step 5: Customize the “Active trigger” and the “Back to normal” messages.
NOTE: These fields always expect a JSON object. When the HTTP method is GET, the JSON is automatically converted to query parameters and appended to the UbiFunction URL.
Step 6: Name the Event and Select the active days and hours.
Step 7: Save the event.