K
Docs
API ReferencePiecesCoalesce
🎯

Coalesce

base.coalesceBase SetLogic

Sets a spark from a primary template, or falls back when the primary is empty. Perfect for /profile user_p: use the mentioned user's ID when provided, otherwise the invoker's ID — without duplicating Save Sparks on each branch.

When to use this
  • Pair with Merge when both branches should run identical downstream pieces
  • Use input.options.user_p.id for USER spell inputs — not the bare object unless you need it
  • Empty means missing, blank text, or a USER pick with no id

On the canvas

This is what Coalesce looks like when you place it on your flow. Each field below is something you configure in the inspector panel.

🎯
Coalesce
base.coalesce
Logic
namerequired
profile_user_id
primaryrequired
{{input.options.user_p.id}}
fallbackrequired
{{input.user.id}}

Config fields

FieldTypeReqWhat it does
name
profile_user_id
textyesSpark name 🏷️
primary
{{input.options.user_p.id}}
textyesTry this first ✨
fallback
{{input.user.id}}
textyesOtherwise use 🛟

Output ports

outputSpark is set — continue the flow
📐

In TypeScript, this would be…

Not something you need to write — just a look at what Kitcord does for you.

TypeScript
const profileUserId =
  input.options.user?.id ?? interaction.user.id;
// {{profile_user_id}} — primary spark or fallback