Rule Actions

In Nected, you can use rule actions to automate database operations based on specific conditions, enabling you to integrate with various database types, including MySQL, PostgreSQL, MongoDB, RedShift and so on along with REST API, Slack and Google Sheet. These operations can be performed using static queries or tokenized queries, providing flexibility and customization for your needs.

Trigger DB as Rule Actions

Triggering a database as a rule action in Nected involves a series of steps that are generally consistent across different types of databases like PostgreSQL, MySQL, MongoDB, Redshift, MS SQL Server and so on. Here's a simplified guide on how to trigger a database as a rule action, assuming that you have already completed the database integration, dataset creation, and rule creation steps:

  1. Open the Rule Editor: You can tigger DB as rule action, in both SimpleRule as well as in DecisionTable. So, open the rule editor where you want to add the action.

  2. Go to the Result section: After opening the rule editor, go to the result section. In the result section, there are two options, Then & Else. You can add actions for both of them.

  3. Now, here either you can use the prebuid datasets, or you can create a new one.

      1. Inside this editor modal, you can write queries to customize the action. You can also edit the dataset by clicking on the pen🖊️ icon.

      2. This will redirect you directly to the connectors page where you can configure your connector. And after configuring, come back to this same editor, and here you can click the refresh ↻ button. Then you can see the connector in the dropdown list.

  4. Next, configure the connection settings for your database, including host, port, username, password, and other required details.

  5. After filling all the connector details click on the Test Connection and check if the connector is working properly or not i.e. credentials are correct for your connectors. And after that publish the connection in staging first by clicking "Publish in Staging" and then repeat the same thing in production. Then finally publish it in production by clicking on Publish in Production button.

    1. Insert Operations: Specify the details of the new record you want to insert. This can be done by writing a SQL query for relational databases like PostgreSQL and MySQL, or a BSON query for MongoDB.

    2. Update Operations: Define the criteria for the records that need to be updated and specify the new values. Again, this will be in the form of a SQL or BSON query, depending on the database.

  6. Use Tokenized Queries (Optional): If you want the operation to be dynamic, based on the output data of the rule or other custom inputs, you can use tokenized queries. This involves using placeholders in your query that get replaced with actual values when the rule is executed.

  7. Test the Rule Action: Before finalizing, it’s important to test the rule action to ensure it works as expected. This might involve checking if the database operation is carried out correctly when the rule is triggered.

  8. Save and Activate the Rule: Once you are satisfied with the configuration, save the changes and ensure the rule is activated. This will enable the database operation to be automatically triggered whenever the conditions defined in the rule are met.

  9. Monitor the Rule Execution: After activation, monitor the rule to ensure it is executing as expected. This might involve checking the database for changes or using any logging features provided by Nected.

By following these steps, you can effectively trigger a database operation as a rule action in Nected, automating data manipulation tasks based on specific conditions or events. This process enhances the interactivity and responsiveness of your application by integrating real-time database operations with rule-based logic.

Triggering REST API as Rule Action

If you have a REST API server, then you can use a REST API action in a rule to update your source database.

Note: All production rules must be run securely using an API, but you can choose to run a staging rule either using an API or directly on the Nected platform.

Follow this procedure to add REST API action in a rule:

  1. Log into Nected with your Email ID and password.

  2. Click Rules in the left navigation to open the Rules page.

  3. Click + Create Rule button on the Rules page and select SimpleRule or DecisionTable. The rule configuration form opens. Define the condition and configuration for your rule.

  4. Click Add Action and select the REST API connector for your database. The action REST API configuration form opens.

  5. Provide the following information for the REST API action:

    The following list describes the options on the REST API action window:

    1. URL Path – The base URL for the REST API.

    2. Method – The REST API method, which can be GET, POST, PUT, PATCH, or DELETE.

    3. Headers – The authentication header retrieved from the REST API connector. You can add more headers using the Add Headers option. You can also add query parameters using the Add Query Parameters option.

    4. Content Type – The type of the content that you want to update, which can be HTML, Text, JavaScript, JSON, XML, FORM, or FORM URL encoded.

    5. The REST API data or body, which contains the information that you want to insert or update in your database.

    6. Save – Save the REST API action information.

  6. Trigger the rule using an API.

Trigger Google sheet as Action

Triggering a Gsheet as a action in Nected involves a series of steps. Here's a simplified guide on how to trigger a Gsheet as a rule action, assuming that you have already completed the Gsheet integration and rule creation steps:

  1. Select the Gsheet Operation: Nected provides you with 2 options i.e Add Single Row and Update Rows which includes inserting new records or updating existing records, respectively.

  2. Configure the Operation Details:

    1. For Add Operation: Select the spreadsheet by clicking on add sheet. Now choose a worksheet present from the selected spreadsheet . Addtionally define whether your first row in sheet serves as headers or not.

  3. Test the Rule Action: Before finalizing, it’s important to test the rule action to ensure it works as expected. This might involve checking if the Gsheet operation is carried out correctly when the rule is triggered.

  4. Save and Activate the Rule: Once you are satisfied with the configuration, save the changes and ensure the rule is activated. This will enable the Gsheet operation to be automatically triggered whenever the conditions defined in the rule are met.

  5. Monitor the Rule Execution: After activation, monitor the rule to ensure it is executing as expected. This might involve checking the database Gsheet for changes or using any logging features provided by Nected.

Last updated