evaluateCondition

The evaluateConditionfunction evaluates the condition of the workflow and returns true or false.

Documentation for F2FSDK.evaluateConditions("workflow_id")

Overview

The F2FSDK.evaluateConditions("workflow_id") function allows you to evaluate the conditions of a specified workflow without triggering its associated actions. This function is asynchronous and returns a promise that resolves to a boolean value, indicating whether the conditions of the workflow are met.


Parameters

  1. workflow_id (required):
      • The unique ID of the workflow, which can be obtained from the F2F dashboard.
      • Ensure the workflow is configured with conditions to evaluate.

Return Value

  • A Promise that resolves to a boolean:
    • true: Indicates that the workflow conditions are met.
    • false: Indicates that the workflow conditions are not met.

Prerequisites

  1. Workflow ID:
      • Navigate to the Workflows section in the F2F dashboard.
      • Create or locate a workflow with defined conditions.
      • Copy the unique workflow_id from the workflow details.
  1. Integration:
      • Ensure the F2F SDK is properly integrated into your website.

Steps to Use

  1. Retrieve Workflow ID:
      • Follow the steps in the dashboard to create or locate a workflow and obtain its workflow_id.
  1. Call the Function:
      • Use the following JavaScript snippet to evaluate the conditions:
// Replace 'your_workflow_id' with the actual ID of your workflow
F2FSDK.evaluateConditions("your_workflow_id").then(result => {
  if (result) {
    console.log("Conditions met!");
  } else {
    console.log("Conditions not met.");
  }
});

Example Use Case

Imagine you have a workflow that displays a floating popup only if a visitor has visited your website more than 3 times. Before triggering the popup, you want to check if the conditions are met.

Code Example:

F2FSDK.evaluateConditions("your_workflow_id").then(result => {
  if (result) {
    console.log("Conditions met. You can proceed with the action.");
  } else {
    console.log("Conditions not met. No action taken.");
  }
});

Notes

  • This function only evaluates the conditions defined in the workflow and does not execute its associated actions.
  • Ensure the workflow_id corresponds to a valid workflow with defined conditions.
  • You can use this function for debugging or conditional logic in your website workflows.

By leveraging F2FSDK.evaluateConditions, you can programmatically verify workflow conditions and build more dynamic, condition-aware user experiences.

Last updated on December 23, 2024