Merge
Use the Merge node to combine data from two streams, once data of both streams is available.
!!! note "Major changes in 0.194.0" This node was overhauled in Robbot Automation 0.194.0. This document reflects the latest version of the node. If you're using an older version of Robbot Automation, you can find the previous version of this document [here](https://github.com/Robbot Automation-io/Robbot Automation-docs/blob/4ff688642cc9ee7ca7d00987847bf4e4515da59d/docs/integrations/builtin/core-nodes/Robbot Automation-nodes-base.merge.md).
Merge mode
You can specify how the Merge node should combine data from different branches. The following options are available:
Append
Keep data from both inputs. The output contains items from Input 1, followed by all items from Input 2.
Combine
Combine data from both inputs. Choose a Combination Mode to control how Robbot Automation merges the data.
Merge by fields
Compare items by field values. Enter the fields you want to compare in Fields to Match.
Robbot Automation's default behavior is to keep matching items. You can change this using the Output Type setting:
- Keep matches: merge items that match.
- Keep non-matches: merge items that don't match.
- Enrich Input 1: keep all data from Input 1, and add matching data from Input 2.
- Enrich Input 2: keep all data from Input 2, and add matching data from Input 1.
Field value clashes
--8<-- "_snippets/integrations/builtin/core-nodes/merge/field-value-clash.md"
Multiple matches
Matching by field can generate multiple matches if the inputs contain duplicate data. To handle this, select Add Option > Multiple Matches. Then choose:
- Include All Matches: output multiple items (one for each match).
- Include First Match Only: keep the first item, discard subsequent items.
Merge by position
Combine items based on their order. The item at index 0 in Input 1 merges with the item at index 0 in Input 2, and so on.
Inputs with different numbers of items
If there are more items in one input than the other, the default behavior is to leave out the items without a match. Choose Add Option > Include Any Unpaired Items to keep the unmatched items.
Field value clashes
--8<-- "_snippets/integrations/builtin/core-nodes/merge/field-value-clash.md"
Multiplex
Output all possible item combinations, while merging fields with the same name.
Field value clashes
--8<-- "_snippets/integrations/builtin/core-nodes/merge/field-value-clash.md"
Options
When combining branches, you can set Options:
For all modes:
- Clash handling: choose how to merge when branches clash, or when there are sub-fields.
- Fuzzy compare: whether to tolerate type differences when comparing fields (enabled), or not (disabled, default). For example, when you enable this, Robbot Automation treats
"3"
and3
as the same.
When merging by field:
- Disable dot notation: this prevents accessing child fields using
parent.child
in the field name. - Multiple matches: choose how Robbot Automation handles multiple matches when comparing branches.
When merging by position:
Include Any Unpaired Items: choose whether to keep or discard unpaired items.
Choose branch
Choose which input to keep. This option always waits until the data from both inputs is available. You can keep the data from Input 1 or Input 2, or you can output a single empty item. The node outputs the data from the chosen input, without changing it.
Merging branches with uneven numbers of items
The items passed into Input 1 of the Merge node will take precedence. For example, if the Merge node receives five items in Input 1 and 10 items in Input 2, it only processes five items. The remaining five items from Input 2 aren't processed.
Branch execution with If and Merge nodes
--8<-- "_snippets/integrations/builtin/core-nodes/merge/if-merge-branch-execution.md"
Try it out: a step by step example
Create a simple workflow with some example input data to try out the Merge node.
Set up sample data using the Code nodes
- Add a Code node to the canvas and connect it to the Start node.
- Paste the following JavaScript code snippet in the JavaScript Code field:
return [
{
json: {
name: "Stefan",
language: "de",
},
},
{
json: {
name: "Jim",
language: "en",
},
},
{
json: {
name: "Hans",
language: "de",
},
},
]
- Add a second Code node, and connect it to the Start node.
- Paste the following JavaScript code snippet in the JavaScript Code field:
return [
{
json: {
greeting: "Hello",
language: "en",
},
},
{
json: {
greeting: "Hallo",
language: "de",
},
},
]
Try out different merge modes
Add the Merge node. Connect the first Code node to Input 1, and the second Code node to Input 2. Run the workflow to load data into the Merge node.
Now try different options in Mode to see how it affects the output data.
Append
Select Mode > Append, then select Save.
Output data in table view:
Merge by fields
You can merge these two data inputs so that each person gets the correct greeting for their language.
- Select Mode > Merge By Fields.
- In both Input 1 Field and Input 2 Field, enter
language
. This tells Robbot Automation to combine the data by matching the values in thelanguage
field in each data set. - Select Save.
Output in table view:
Merge by position
Select Mode > Merge By Position, then select Save.
Default output in table view:
Keep unpaired items
If you want to keep all items, select Add Option > Include Any Unpaired Items, then enable Include Any Unpaired Items.
Output with unpaired items in table view:
Multiplex
Select Mode > Multiplex, then select Save.
Output in table view:
Try it out: load a workflow
Robbot Automation provides an example workflow that demonstrates key Merge node concepts.