Nodes/AUN ComfyUI Nodes/Keyword Preset Selector
ComfyUI Node

Keyword Preset Selector

The substring router that quietly unknots your workflow

By loz2754·Created 7 months ago·Updated about 12 hours ago· 5
Keyword Preset Selector
    • selected_value
    • matched_keyword
    • matched_index
    visible_inputs5
    case_sensitivefalse
    reference_phrase
    preset_default
    keyword1
    preset1
    keyword2
    preset2
    keyword3
    preset3
    keyword4
    preset4
    keyword5
    preset5
    keyword6
    preset6
    keyword7
    preset7
    keyword8
    preset8
    keyword9
    preset9
    keyword10
    preset10
    keyword11
    preset11
    keyword12
    preset12
    keyword13
    preset13
    keyword14
    preset14
    keyword15
    preset15
    keyword16
    preset16
    keyword17
    preset17
    keyword18
    preset18
    keyword19
    preset19
    keyword20
    preset20

    If the prompt contains X, output Y. That's the whole node - and that's the point.

    AUNKeywordPresetSelector is a keyword-to-value lookup table. Feed it a reference_phrase, and it scans up to 20 keyword/preset rows top to bottom, returning the first preset whose keyword appears in the phrase as a substring (case-insensitive by default). No scoring, no machine learning, no API. Just "does this text contain that word, and if so, give me the thing I attached to it."

    You reach for it the moment your workflow's behavior should follow what the prompt says. Your prompt cycler (AUNPromptCycler or one of the Text Index Switches) emits a label or index for the active prompt - run that label into reference_phrase and this node hands you a preset value: a style phrase to append, a LoRA trigger string, a CFG value or scheduler name as text. Or feed it a captured filename, a wildcard token, anything. Anywhere you catch yourself thinking "if it mentions anime, use preset A, else B," this node is that sentence.

    It's the exact shape of node the AUN pack loves: tiny, deterministic plumbing that turns text analysis into a decision. It looks boring on the canvas. It quietly deletes a pile of index switches from your graph.

    How it works

    The matching engine is shared with its FaceID sibling in the same pack: substring match, case-insensitive by default, first match wins scanning top to bottom. Each keywordN is a comma-separated list - any one keyword matching activates the row. Empty rows are skipped silently. If nothing matches, you get preset_default and a matched_index of 0, which is your "fell through" flag. It returns NaN from IS_CHANGED, so it re-evaluates on every run; a changed phrase always gets re-scanned.

    The inputs that matter:

    • reference_phrase: the text scanned for keywords (substring match, not exact equality).
    • preset_default: what comes out when nothing matches. Empty string if you leave it - set it, or you'll be chasing empty outputs.
    • visible_inputs (2–20): how many keyword/preset rows are active. Then it's just rows of keywordN + presetN. presetN is multiline, so a "preset" can be a full prompt paragraph, not just a token.

    Three outputs: selected_value (STRING - the winning preset), matched_keyword (the exact keyword that fired, empty on fallback), matched_index (INT - 1-based row, or 0 when nothing matched). Wire selected_value into a CLIP Text Encode, a filename builder, or AUN Show Any Multi so you can see which preset won at a glance. matched_index feeds any of the pack's index-driven nodes if you want the choice to drive more than one thing.

    A quick pattern:

    AUNPromptCycler (label) ──▶ AUNKeywordPresetSelector (reference_phrase)
                                     └─ selected_value ──▶ CLIP Text Encode (append style)
                                     └─ matched_index  ──▶ AUN Show Any Multi
    

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/loz2754/AUN-ComfyUI-Nodes
    

    ...or ComfyUI Manager → search "AUN ComfyUI Nodes" → install → restart. Pure Python, no extra dependencies, no model downloads, no API key. The pack's requirements.txt (piexif, opencv-headless, imageio-ffmpeg) exists for the rest of the collection; this node doesn't touch any of it.

    Gotchas

    • Substring matching surprises. anime matches animesque, face matches interface. Since first match wins, put the longest, most specific keywords first - order is your only tiebreaker, so row order is load-bearing.
    • Empty rows are skipped, not errors. A half-configured slot just never matches, and you get no warning. Check matched_index if a preset never seems to fire.
    • The 0 fallback is your friend. Because selected_value can't tell you whether you fell through to preset_default, wire matched_index somewhere visible when you're debugging a row order.
    CategoryAUN Nodes/Prompts

    Inputs (44)

    NameTypeDefaultDescription
    visible_inputsINT52–20How many keyword/preset pairs are active (2-20). Slot N uses keywordN/presetN.
    case_sensitiveBOOLEANfalseIf enabled, keyword matching is case-sensitive.
    reference_phraseoptSTRINGText to scan for keywords. Keywords are matched as substrings.
    preset_defaultoptSTRINGDefault preset value. Output when no keyword matches.
    keyword1optSTRINGKeyword 1 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset1optSTRINGPreset value 1 to output when keyword 1 matches.
    keyword2optSTRINGKeyword 2 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset2optSTRINGPreset value 2 to output when keyword 2 matches.
    keyword3optSTRINGKeyword 3 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset3optSTRINGPreset value 3 to output when keyword 3 matches.
    keyword4optSTRINGKeyword 4 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset4optSTRINGPreset value 4 to output when keyword 4 matches.
    keyword5optSTRINGKeyword 5 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset5optSTRINGPreset value 5 to output when keyword 5 matches.
    keyword6optSTRINGKeyword 6 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset6optSTRINGPreset value 6 to output when keyword 6 matches.
    keyword7optSTRINGKeyword 7 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset7optSTRINGPreset value 7 to output when keyword 7 matches.
    keyword8optSTRINGKeyword 8 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset8optSTRINGPreset value 8 to output when keyword 8 matches.
    keyword9optSTRINGKeyword 9 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset9optSTRINGPreset value 9 to output when keyword 9 matches.
    keyword10optSTRINGKeyword 10 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset10optSTRINGPreset value 10 to output when keyword 10 matches.
    keyword11optSTRINGKeyword 11 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset11optSTRINGPreset value 11 to output when keyword 11 matches.
    keyword12optSTRINGKeyword 12 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset12optSTRINGPreset value 12 to output when keyword 12 matches.
    keyword13optSTRINGKeyword 13 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset13optSTRINGPreset value 13 to output when keyword 13 matches.
    keyword14optSTRINGKeyword 14 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset14optSTRINGPreset value 14 to output when keyword 14 matches.
    keyword15optSTRINGKeyword 15 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset15optSTRINGPreset value 15 to output when keyword 15 matches.
    keyword16optSTRINGKeyword 16 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset16optSTRINGPreset value 16 to output when keyword 16 matches.
    keyword17optSTRINGKeyword 17 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset17optSTRINGPreset value 17 to output when keyword 17 matches.
    keyword18optSTRINGKeyword 18 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset18optSTRINGPreset value 18 to output when keyword 18 matches.
    keyword19optSTRINGKeyword 19 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset19optSTRINGPreset value 19 to output when keyword 19 matches.
    keyword20optSTRINGKeyword 20 to match against the reference phrase. Matched as a substring. Comma-separated to allow multiple keywords on this row (any one matching activates it).
    preset20optSTRINGPreset value 20 to output when keyword 20 matches.

    Outputs (3)

    NameTypeDescription
    selected_valueSTRING
    matched_keywordSTRING
    matched_indexINT