Set Action in Saasio
In Saasio, actions are used to define the behavior and flow of your app when certain interactions occur. Actions can be attached to different elements in your app, providing dynamic behavior such as user authentication, data updates, page navigation, custom interactions, and API calls. This article will guide you through setting up actions, explaining the different action categories, and detailing how to use conditions and workflow controls.
Action Categories
Saasio supports five main categories of actions, each designed for specific purposes.
Note: Actions are executed sequentially. If an error occurs at any step, the workflow execution will stop immediately.
1. Account Actions
Account actions handle authentication and user management tasks, including logging in and logging out users. These actions are essential for managing user access and maintaining secure app functionality.
- Examples:
- Login: Trigger the login process for users.
- Logout: Log the user out of the app.
2. Data Actions
Data actions are used to manage data in your app, allowing you to create, update, and delete records in your database. These actions are typically used when users interact with forms, buttons, or other UI components that manipulate data.
- Examples:
- Create Data: Add new records to your database.
- Update Data: Modify existing records.
- Delete Data: Remove data from your database.
3. Navigation Actions
Navigation actions allow you to control the flow of the user's experience, such as reloading the current page or redirecting the user to another page. These actions are useful for controlling the app's navigation without requiring page refreshes.
- Examples:
- Reload Page: Refresh the current page.
- Go to Another Page: Navigate to a different page within your app.
Note: Navigation actions cannot have other actions after them in the workflow. They dictate the app's navigation flow and should be used strategically to prevent unnecessary page changes.
4. Custom Actions
Custom actions offer flexibility, allowing you to define specific behaviors for elements in your app. You can use them to show or hide elements, set data in the app's state, or even perform other custom operations that do not fall into the other categories.
- Examples:
- Show/Hide Element: Toggle the visibility of an element based on conditions.
- Set Data in State: Store or update data within the app's state.
Note: Custom actions can be added after any action in the sequence, giving you more flexibility in how the app behaves.
5. API Actions
API actions enable you to interact with external services or APIs directly from your app. These actions are used to make API calls, retrieve data, and update external systems based on user input.
- Examples:
- Make API Call: Trigger an API request to an external service.
- Set API Response: Store the response from an API in your app’s state.
How to Set an Action
To set an action in Saasio, follow these steps:
Select the Element: First, select the element in the editor that you want to attach an action to. Only native elements and ShadCN components are eligible to have actions assigned.
Open the Logic Tab: After selecting the element, open the Logic tab in the editor. Here, you will find all available actions that can be added to the selected element.
Choose an Action: Under the five categories (Account, Data, Navigation, Custom, and API), select the action you want to add to the element. Each category has different types of actions available.
Set Conditions: Each action has an optional condition field. This condition determines when the action should run. You can specify conditions based on user input, data state, or other app behaviors.
Configure Workflow Control: In addition to setting conditions, you can specify whether the action should stop the workflow if the condition is met. This option ensures that if a condition is fulfilled, the workflow will halt, preventing any subsequent actions from being executed.
Workflow Execution Order
The workflow in Saasio runs sequentially, meaning that actions are processed one after the other in the order they are defined.
Action Eligibility
Not all elements in your app are eligible to have actions assigned to them. Only native elements and Shadcn UI components can have actions attached. These elements provide the necessary structure to interact with actions like data manipulation, user authentication, and navigation.