Map Items and Set Branches
Process several tickets with expressions and an If node, checking missing fields and branch counts.
Today's Goals
- Map upstream fields to a stable ticket shape.
- Branch explicitly for missing fields and unknown types.
- Use item counts to detect loss and duplication.
A workflow that works for one ticket may lose a record when it receives four. n8n's expressions and data nodes let you map fields, while an If node can split valid and invalid cases. The hard part is making the mapping and branching observable.
Plain-Language Walkthrough
Normalize before you classify
Suppose one source uses “message,” another uses “body,” and a third gives a blank string. The AI classifier should not have to guess which field is authoritative. Create a normalization step that emits the same fields for every valid item: source ID, ticket ID, normalized text, language hint, received time, and a source reference. Preserve the original ID and source even when you change field names. Without them, a downstream result cannot be reconciled with the upstream system.
The n8n expressions guide explains when an expression reads values and when a data node is clearer. An expression often reads the current item's JSON; inspect its preview against more than the first sample. A field path that works for ticket one may be undefined for ticket two. Avoid a magic default such as “unknown customer” when the missing field is necessary for routing. Prefer an explicit validation result.
A useful contract says a valid ticket must have a nonempty ID and nonempty text; language may be unknown, because the classifier can still read the text. If ID or text is missing, route the item to a manual error queue with a reason. Do not let it disappear because a filter produced zero items. Count inputs and outputs at each node, including each branch. Four incoming items should reconcile to four outcomes: perhaps three valid and one rejected. If the total is three, something was lost; if it is five, something may have been duplicated.
Interview questions
Why preserve source IDs?为什么要保留原始 ID?
Common in ChinaCommon overseasBasic#normalization#identity🔒 Unlock this chapter to see the answer keys.
How do you detect a lost item?少一条数据如何发现?
Common in ChinaCommon overseasIntermediate#reconciliation#items🔒 Unlock this chapter to see the answer keys.
What should the fallback branch do?默认分支该做什么?
Common in ChinaCommon overseasIntermediate#fallback#data-quality🔒 Unlock this chapter to see the answer keys.
