Decision icon

Decision

Make collective decisions based on different methods

Overview

This node performs collective decision-making based on input votes using various methods. It is useful in scenarios where multiple inputs or opinions need to be aggregated into a single decision outcome, such as polling, approval workflows, or consensus checks.

The node supports different decision strategies:

  • Simple Majority: Decision passes if "yes" votes outnumber "no" votes.
  • Threshold: Decision passes if "yes" votes meet a specified threshold (percentage or absolute number).
  • Consensus: Decision passes if the percentage of "no" votes is below a blocking limit.
  • Custom Logic: Decision passes based on a user-defined JavaScript condition involving vote counts.

Practical examples include:

  • Approving a document if more than 50% of reviewers vote yes (Simple Majority).
  • Releasing a feature only if at least 10 team members approve (Threshold with absolute number).
  • Proceeding with a plan only if less than 10% oppose it (Consensus).
  • Using complex rules like "yesVotes > noVotes * 2" for nuanced decisions (Custom Logic).

Properties

Name Meaning
Decision Method The method used to decide the outcome. Options: Simple Majority, Threshold, Consensus, Custom Logic.
Vote Field Name of the field in each input item containing the vote value.
Yes Value The string value representing a positive vote.
No Value The string value representing a negative vote.
Abstain Value The string value representing an abstention vote.
Threshold (Shown if method = Threshold) The threshold value for the decision, either a percentage or an absolute number.
Threshold Type (Shown if method = Threshold) Whether the threshold is a percentage of valid votes or an absolute number of yes votes.
Blocking Percentage (Shown if method = Consensus) Maximum allowed percentage of "No" votes for consensus to be reached.
Custom Condition (Shown if method = Custom Logic) A JavaScript expression that returns true or false based on variables: yesVotes, noVotes, abstainVotes, totalVotes.
Advanced Options Collection of additional options:
- Detailed Results Whether to return detailed results of all votes.
- Include Original Items Whether to include the original input items in the output.

Output

The node outputs two possible branches:

  • Decision Passed (first output): Contains a JSON object summarizing the decision result when the decision criteria are met.
  • Decision Failed (second output): Contains a similar JSON object when the decision criteria are not met.

The JSON output includes:

  • summary: An object summarizing the decision method, total votes, counts of yes/no/abstain votes, and whether the decision passed.
  • Optionally, if enabled:
    • votes: Detailed breakdown of all individual votes.
    • originalItems: The original input items provided to the node.

The node does not output binary data.

Dependencies

  • Requires input data items containing vote information in a specified field.
  • Uses internal helper functions for counting votes and evaluating custom conditions.
  • No external API or service dependencies.
  • No special environment variables or credentials needed.

Troubleshooting

  • Error: "No votes to process."
    Occurs if the input data array is empty. Ensure the node receives input items with vote data.

  • Error: "No valid votes found. All votes are abstentions."
    Happens when all votes match the abstain value, leaving no yes/no votes to evaluate. Check the vote values and configuration.

  • Error: "Unknown decision method"
    Indicates an invalid or unsupported decision method was selected. Verify the "Decision Method" property.

  • Custom Logic errors
    If the custom JavaScript condition has syntax errors or references undefined variables, the node may fail. Validate the expression carefully.

  • Threshold with zero valid votes
    When using threshold or consensus methods, if there are no valid votes (non-abstain), the node throws an error. Make sure votes are correctly classified.

Links and References

Discussion