How to Execute Different Flows Based on Approval Status in Core The Approval Component?

Hello,

I am currently using the Core The Approval component in my workflow. I understand that if an item is approved, it will move on to the next step as indicated in the “Wait Approval” component. However, I am curious to know if there is a way to trigger a different flow if the item is declined.

Is it possible to bifurcate the workflow depending on whether an item gets approved or declined?

Looking forward to your guidance.

Best regards,
Alonso

Hi @Alonso_Zurera

This is a topic where it’s not intuitive we have couple of action items to improve it :smiley:

The Wait for Approval It just returns in the body whether it’s approved or not, you will have to add branch piece to check if response is approved or not.

I dont understand how to make it. I see the output in the wat approval piece is not the same but i dont know how to branch.
Could you help me with this test flow I created

{
  "id": "M8UpqHzUzOGgfgDOB5xTq",
  "created": "1696246470409",
  "updated": "1696246470409",
  "name": "Create Approval Links",
  "description": "",
  "tags": [],
  "pieces": [
    "@activepieces/piece-schedule",
    "@activepieces/piece-approval",
    "@activepieces/piece-tags"
  ],
  "blogUrl": "",
  "template": {
    "displayName": "Create Approval Links",
    "trigger": {
      "name": "trigger",
      "valid": true,
      "displayName": "Every Hour",
      "nextAction": {
        "name": "step_1",
        "type": "PIECE",
        "valid": true,
        "settings": {
          "input": {},
          "pieceName": "@activepieces/piece-approval",
          "actionName": "create_approval_links",
          "inputUiInfo": {},
          "pieceVersion": "~0.1.0"
        },
        "nextAction": {
          "name": "step_3",
          "type": "PIECE",
          "valid": true,
          "settings": {
            "input": {},
            "pieceName": "@activepieces/piece-approval",
            "actionName": "wait_for_approval",
            "inputUiInfo": {},
            "pieceVersion": "~0.1.0"
          },
          "nextAction": {
            "name": "step_2",
            "type": "BRANCH",
            "valid": true,
            "settings": {
              "conditions": [
                [
                  {
                    "operator": "BOOLEAN_IS_TRUE",
                    "firstValue": "{{step_3}}"
                  }
                ]
              ],
              "inputUiInfo": {}
            },
            "displayName": "Branch",
            "onFailureAction": {
              "name": "step_5",
              "type": "PIECE",
              "valid": true,
              "settings": {
                "input": {
                  "name": "no"
                },
                "pieceName": "@activepieces/piece-tags",
                "actionName": "add_tag",
                "inputUiInfo": {},
                "pieceVersion": "~0.0.1"
              },
              "displayName": "Add Tag"
            },
            "onSuccessAction": {
              "name": "step_4",
              "type": "PIECE",
              "valid": true,
              "settings": {
                "input": {
                  "name": "yes"
                },
                "pieceName": "@activepieces/piece-tags",
                "actionName": "add_tag",
                "inputUiInfo": {},
                "pieceVersion": "~0.0.1"
              },
              "displayName": "Add Tag"
            }
          },
          "displayName": "Wait for Approval"
        },
        "displayName": "Create Approval Links"
      },
      "type": "PIECE_TRIGGER",
      "settings": {
        "pieceName": "@activepieces/piece-schedule",
        "pieceVersion": "~0.1.1",
        "triggerName": "every_hour",
        "input": {
          "run_on_weekends": false
        },
        "inputUiInfo": {}
      }
    },
    "valid": true
  },
  "userId": null,
  "imageUrl": null,
  "featuredDescription": "",
  "isFeatured": false
}

At the end I caputre the output of the wait approval with a code snipped.

export const code = async (inputs) => {
  if (inputs.approval.approved === true) {
    return true;
  } else {
    return false;
  }
};

And later use this output in the branch

Thanks for the help! Issue resolved

You are correct, It’s not showing the output in test step, I opened ticket in Github to fix it for future users.

I am glad you have it fixed! :smiley:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.