Ask AI
Skip to main content

Execute action

Function: Execute action

This function allows you to run another pre-defined action from within your current workflow or action. It's like calling a sub-routine or a nested process. You can pass specific information to the action you're executing and retrieve its results. This is useful for reusing common logic, breaking down complex processes, or integrating different parts of your application.

Input

  • Action: The specific action you want to execute. This is a required input.
  • Action parameters: Any specific information or values that the selected action needs to perform its task. The available parameters will change depending on the 'Action' you choose.
  • Mode: Determines how the action will run.
    • Default (runs synchronously): The current workflow will pause and wait for the executed action to complete before continuing.
    • Asynchronous execution: The executed action will run in the background, allowing the current workflow to continue immediately without waiting.
    • Asynchronous with frontend answer: The executed action will run in the background, and if it produces any user interface updates, those will be sent to the user's screen.
  • Cache results: If set to 'True', the results of this action will be stored temporarily. If the same action is run again with the exact same 'Action parameters' within the cache duration, the stored results will be used instead of running the action again. This can speed up your application. The default value is False.
  • Cache TTL: The duration, in milliseconds, for which the action's results will be cached. This input only appears if 'Cache results' is set to 'True'. The default value is 60000 milliseconds (1 minute).

Output

  • Action outputs: The results or data produced by the action that was executed. The specific outputs will depend on the 'Action' you chose to run.

Execution Flow

Real-Life Examples

Example 1: Reusing a Customer Validation Process

  • Scenario: You have a complex workflow for onboarding new customers, and part of that involves validating their contact information. You've already built a separate action called "Validate Customer Contact" that checks email format, phone number validity, and address completeness. You want to use this validation in multiple places without rebuilding it.
  • Inputs:
    • Action: "Validate Customer Contact"
    • Action parameters:
      • customerEmail: "john.doe@example.com"
      • customerPhone: "+15551234567"
      • customerAddress: "123 Main St, Anytown, USA"
    • Mode: "Default (runs synchronously)"
    • Cache results: False
  • Result: The "Validate Customer Contact" action runs, checking the provided details. If all details are valid, the "Action outputs" might include isValid: True. If there are issues, isValid: False and validationErrors: ["Invalid email format"] might be returned. Your current workflow then proceeds based on these validation results.

Example 2: Sending a Welcome Email Asynchronously

  • Scenario: After a user successfully registers, you want to send them a welcome email. Sending emails can sometimes take a few seconds, and you don't want the user to wait for this before seeing their confirmation page. You have an action called "Send Welcome Email".
  • Inputs:
    • Action: "Send Welcome Email"
    • Action parameters:
    • Mode: "Asynchronous execution"
    • Cache results: False
  • Result: The "Send Welcome Email" action is triggered to run in the background. Your main registration workflow immediately continues to display the confirmation page to the user, without waiting for the email to be fully sent. The "Action outputs" for this execution might not be immediately available to the current workflow, but the email will be sent.

Example 3: Displaying Product Recommendations with Caching

  • Scenario: On your e-commerce product page, you have an action called "Get Product Recommendations" that fetches personalized suggestions based on the current product. This action can be resource-intensive. You want to display recommendations quickly and avoid re-calculating them if the same product is viewed multiple times within a short period.
  • Inputs:
    • Action: "Get Product Recommendations"
    • Action parameters:
      • productId: "PROD-XYZ-123"
      • userId: "USER-ABC-456"
    • Mode: "Default (runs synchronously)"
    • Cache results: True
    • Cache TTL: 300000 (5 minutes)
  • Result:
    • First time: The "Get Product Recommendations" action runs, fetches recommendations, and stores them in the cache for 5 minutes. The "Action outputs" will contain a list of recommended products, which are then displayed on the page.
    • Subsequent times (within 5 minutes, same product/user): The action checks the cache, finds the stored recommendations, and immediately returns them without running the full recommendation logic again. The "Action outputs" will be the same list of recommended products, displayed instantly.
    • After 5 minutes or with different product/user: The cache entry expires or doesn't match, so the action runs again, fetches new recommendations, and updates the cache.