Action Blocks
Action Blocks are essential building building blocks for creating automations within your Zorp app.
They allow you to define the specific actions that will be executed when an automation is triggered. Each Action Block consists of multiple conditions and actions, and all conditions within an Action Block must be met (return true) for the actions in the Action Block to be executed.
Types of Conditions
Conditions within an Action Block are essential to determine whether the actions should be executed or skipped. They allow you to create dynamic and flexible automations that respond to specific criteria or situations within your Zorp app.
There are three types of conditions you can add to an Action Block:
Expression Condition: An Expression Condition allows you to write a JavaScript expression that returns a boolean value, either true or false. If the expression evaluates to true, the actions within the Action Block will be executed. If the expression evaluates to false, the actions will be skipped.
REST API condition: A REST API Condition enables you to call an external API and use the API response to determine if the actions within the Action Block should be executed. If the API returns a specific value or meets certain criteria, the actions will be executed; otherwise, they will be skipped.
Location Check condition: A Location Check Condition allows you to compare the user’s current location with a predefined location or area. If the user’s location matches the specified criteria, the actions within the Action Block will be executed. If not, the actions will be skipped.
In cases where you have multiple conditions within an Action Block, these conditions will be executed in sequence. The next condition in the sequence will only be executed if the current condition returns true. If any of the conditions returns false, the remaining conditions will be skipped, and the actions within the Action Block will not be executed. This approach allows you to create complex conditional logic within your automations.
If all conditions within the Action Block return true, the actions will be executed. If any condition returns false, the actions will be skipped.
By using sequential conditional execution, you can create powerful and flexible automations that respond to specific scenarios or combinations of criteria within your Zorp app. This enhances the app’s overall functionality and provides a more engaging and dynamic user experience.
Types of Actions
There are several types of actions you can add to an Action Block:
REST API Action: This action allows you to make HTTP requests to external APIs, enabling integration with various systems or databases. You can use this action to fetch, update, or delete data from an external system, or interact with your own internal APIs.
Push Notification: Send a push notification to a specific user or group of users. You can customize the notification’s content, including the title, message, and any additional data you’d like to include. Update Data Fields: Use this action to update data fields within your app, either by setting them to a specific value or by performing calculations or transformations on their current values.
In Zorp, an Action Block can contain multiple actions, allowing you to perform several tasks as part of a single automation. The actions within an Action Block are executed in the sequence they are defined. If an action encounters an error and the “Exit on error” indicator is enabled, the subsequent actions in the current Action Block, as well as the following Action Blocks, will not be executed. This feature ensures that your automation only proceeds when all actions are successful, preventing potential issues caused by incomplete or erroneous data.
Here’s an example of using multiple actions in an Action Block:
Task creation and assignment: In a project management app, when a new task is created, you may want to perform several actions as part of the automation, such as:
- Create the task in your internal system using a REST API action.
- Assign the task to the appropriate team member based on their role or workload.
- Send an email notification to the assignee informing them of the new task.
- In this case, you can create an Action Block with three actions in sequence. If the “Exit on error” indicator is enabled and an error occurs while creating the task or assigning it, the email notification will not be sent, ensuring that users are not informed about tasks that haven’t been successfully created or assigned.
By using multiple actions within an Action Block and utilizing the “Exit on error” feature, you can create more robust and error-resistant automations, ultimately improving the efficiency and reliability of your Zorp app.
Multiple Action Blocks in an Automation
In Zorp, an automation must have at least one Action Block to define the actions that will be performed when the automation is triggered. However, you can also include multiple Action Blocks within a single automation to enable complex and flexible logic based on different sets of conditions. Why Use Multiple Action Blocks?
Having multiple Action Blocks in an automation allows you to execute different sets of actions based on different conditions. Each Action Block contains its own set of conditions and actions, allowing you to create separate branches of logic within a single automation.
This can be useful for handling different scenarios or combinations of criteria within your Zorp app, as the automation can respond to multiple situations with different actions.
Some examples of when to use multiple action blocks
-
Task assignment based on user role: In a task management app, you may want to assign tasks to different users based on their role. You can create an automation with two Action Blocks: one for assigning tasks to managers if a certain condition is met (e.g., the task is high priority), and another for assigning tasks to regular team members if the condition is not met.
-
Dynamic notifications: In a sales app, you may want to send different types of notifications based on the customer’s purchase history. You can create an automation with multiple Action Blocks: one for sending a promotional notification to customers who have made a purchase within the last month, another for sending a different notification to customers who have not made a purchase in over a month, and so on.
-
Conditional data synchronization: In an inventory management app, you may want to update different databases or systems based on specific conditions. For example, you can create an automation with multiple Action Blocks: one for updating your internal ERP system if the item is in stock, another for updating a third-party system if the item is out of stock, and yet another for sending an alert to the warehouse manager if the stock level is below a certain threshold.