PlaceholdersParsers
Logical Parser
Conditional logic parser with OR and AND modes for evaluating boolean expressions in placeholders.
The Logical Parser allows you to create conditional logic within placeholders by evaluating multiple boolean expressions. It supports two modes: OR logic (returns true if any expression matches) and AND logic (returns true only if all expressions match).
Syntax
{parser(expression|expression|...):true_message|false_message}Structure
- Expressions: Multiple boolean conditions separated by pipes (
|) - Payload: A message split by a pipe (
|) containing the true/false responses - The text before the first pipe in the payload is returned when conditions are met
- The text after the first pipe is returned when conditions are not met
Modes
OR Mode (Any Match)
Returns the true message if any of the expressions evaluate to true.
Aliases:
any(primary)orunion
Syntax:
{any(expression|expression|...):true_message|false_message}How it works:
- Evaluates each expression separated by
| - If any expression is
true, returns the text before the first pipe in the payload - If all expressions are
false, returns the text after the first pipe in the payload
Examples:
{any({args}==hi|{args}==hello|{args}==hey):Hello {user}!|How rude.}- If
{args}ishi,hello, orhey→ Returns:Hello Mr. Priyansh#2063! - If
{args}is anything else → Returns:How rude.
{any({a}==1|{b}==2):One or two matched.|No match.}- If
{a}==1is true OR{b}==2is true → Returns:One or two matched. - If both are false → Returns:
No match.
AND Mode (All Match)
Returns the true message only if all of the expressions evaluate to true.
Aliases:
all(primary)andintersection
Syntax:
{all(expression|expression|...):true_message|false_message}How it works:
- Evaluates each expression separated by
| - If all expressions are
true, returns the text before the first pipe in the payload - If any expression is
false, returns the text after the first pipe in the payload
Examples:
{all({args}>=100|{args}<=1000):You picked {args}.|You must provide a number between 100 and 1000.}- If
{args}is52→ Returns:You must provide a number between 100 and 1000.(fails first condition) - If
{args}is282→ Returns:You picked 282.(both conditions pass) - If
{args}is1500→ Returns:You must provide a number between 100 and 1000.(fails second condition)
{all({x}==a|{y}==b):Both matched.|One or more did not match.}- If
{x}==ais true AND{y}==bis true → Returns:Both matched. - If either condition is false → Returns:
One or more did not match.
Notes
- The payload must contain a pipe (
|) to separate true/false messages - In OR mode, expressions are evaluated left to right; evaluation may stop once any expression is true (short-circuit behavior)
- In AND mode, all expressions are evaluated; every expression must be true for the parser to return the first message
When to Use Which Mode
| Scenario | Use This Mode | Example Use Case |
|---|---|---|
| Match any of multiple values | OR (any) | Greeting detection: hi, hello, or hey |
| Require all conditions to pass | AND (all) | Validation: number must be between 100 and 1000 |
| Optional conditions | OR (any) | Check if user has any of several roles |
| Mandatory requirements | AND (all) | Verify user has all required permissions |
Quick Reference:
- OR mode (
any): "If any of these are true, do this" - AND mode (
all): "If all of these are true, do this"