Keyword Preset Selector
The substring router that quietly unknots your workflow
- selected_value
- matched_keyword
- matched_index
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 ofkeywordN+presetN.presetNis 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.
animematchesanimesque,facematchesinterface. 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_indexif a preset never seems to fire. - The
0fallback is your friend. Becauseselected_valuecan't tell you whether you fell through topreset_default, wirematched_indexsomewhere visible when you're debugging a row order.
Inputs (44)
| Name | Type | Default | Description |
|---|---|---|---|
| visible_inputs | INT | 52–20 | How many keyword/preset pairs are active (2-20). Slot N uses keywordN/presetN. |
| case_sensitive | BOOLEAN | false | If enabled, keyword matching is case-sensitive. |
| reference_phraseopt | STRING | Text to scan for keywords. Keywords are matched as substrings. | |
| preset_defaultopt | STRING | Default preset value. Output when no keyword matches. | |
| keyword1opt | STRING | Keyword 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). | |
| preset1opt | STRING | Preset value 1 to output when keyword 1 matches. | |
| keyword2opt | STRING | Keyword 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). | |
| preset2opt | STRING | Preset value 2 to output when keyword 2 matches. | |
| keyword3opt | STRING | Keyword 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). | |
| preset3opt | STRING | Preset value 3 to output when keyword 3 matches. | |
| keyword4opt | STRING | Keyword 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). | |
| preset4opt | STRING | Preset value 4 to output when keyword 4 matches. | |
| keyword5opt | STRING | Keyword 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). | |
| preset5opt | STRING | Preset value 5 to output when keyword 5 matches. | |
| keyword6opt | STRING | Keyword 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). | |
| preset6opt | STRING | Preset value 6 to output when keyword 6 matches. | |
| keyword7opt | STRING | Keyword 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). | |
| preset7opt | STRING | Preset value 7 to output when keyword 7 matches. | |
| keyword8opt | STRING | Keyword 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). | |
| preset8opt | STRING | Preset value 8 to output when keyword 8 matches. | |
| keyword9opt | STRING | Keyword 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). | |
| preset9opt | STRING | Preset value 9 to output when keyword 9 matches. | |
| keyword10opt | STRING | Keyword 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). | |
| preset10opt | STRING | Preset value 10 to output when keyword 10 matches. | |
| keyword11opt | STRING | Keyword 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). | |
| preset11opt | STRING | Preset value 11 to output when keyword 11 matches. | |
| keyword12opt | STRING | Keyword 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). | |
| preset12opt | STRING | Preset value 12 to output when keyword 12 matches. | |
| keyword13opt | STRING | Keyword 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). | |
| preset13opt | STRING | Preset value 13 to output when keyword 13 matches. | |
| keyword14opt | STRING | Keyword 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). | |
| preset14opt | STRING | Preset value 14 to output when keyword 14 matches. | |
| keyword15opt | STRING | Keyword 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). | |
| preset15opt | STRING | Preset value 15 to output when keyword 15 matches. | |
| keyword16opt | STRING | Keyword 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). | |
| preset16opt | STRING | Preset value 16 to output when keyword 16 matches. | |
| keyword17opt | STRING | Keyword 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). | |
| preset17opt | STRING | Preset value 17 to output when keyword 17 matches. | |
| keyword18opt | STRING | Keyword 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). | |
| preset18opt | STRING | Preset value 18 to output when keyword 18 matches. | |
| keyword19opt | STRING | Keyword 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). | |
| preset19opt | STRING | Preset value 19 to output when keyword 19 matches. | |
| keyword20opt | STRING | Keyword 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). | |
| preset20opt | STRING | Preset value 20 to output when keyword 20 matches. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| selected_value | STRING | — |
| matched_keyword | STRING | — |
| matched_index | INT | — |