
Description
The Copy Data To Context Node copies the contents of theinput.data object into the Context object. The input.data object exists only for the current input. The Context object persists for the whole session, so the copy keeps the values available on later inputs.
Use this Node when a channel or an earlier Node places structured data in the Input object. The Node stores every key at once, so you don’t need a separate Add To Context Node for each key.
The Node handles the data as follows:
- Copies top-level keys from input.data to Context. Nested objects and arrays retain their structure.
- Merges into Context. Keys that are absent from
input.dataremain unchanged. - Replaces existing values. For example, a new
orderIdvalue overwrites the stored value. - Resolves keys that contain a dot as nested paths. For example, the data key
user.idwrites tocontext.user.id. - Copies nothing when
input.datais empty. The Flow continues with the next Node.
The
input.data object contains the data submitted with the input. Common sources include:- The
datafield of a REST Endpoint request. - The data payload of a Webchat message.
- The Data Payload parameter for Webchat start behavior or Voice Gateway call events.
- Any Node that writes to the Input object.
Parameters
This Node has no parameters. The Input object determines which keys the Node writes and which values it stores.Examples
Copy Customer Details at Session Start
To test copying customer details frominput.data to Context in the Interaction Panel:
- Go to Settings > Input.
- Activate Show data input. The JSON data payload field appears under the message field on the Test tab.
- In the Debug Mode section, activate Debug mode to see a
Copied <key> to contextmessage for each copied key. - Enter the following JSON in the JSON data payload field and send the message. You can send the payload without message text.
- Add a Copy Data To Context Node at the start of the Flow.
- Go to the Context tab and verify that
customerId,cart, andlocalewere copied. - You can reference these values later with CognigyScript, for example,
{{context.customerId}}or{{context.cart.total}}.
Replace Existing Context Values
The Copy Data To Context Node replaces existing Context values wheninput.data contains a key with the same name.
For example, before the Node runs, the Context contains:
input.data:
customerId and cart with the values from input.data. The locale key remains unchanged because it is not included in the current input.data.
Alternatives
- To store a single value under a key that you choose, use the Add To Context Node.
- To store a found Slot instead of Input data, use the Copy Slots to Context Node.