Retrieve User Context


You need to retrieve data from the user’s context for use in your existing flow.


There are two ways that you can retrieve and store input as context. 1. Use the Change node to set the taken input and store it for later use as a $referenceable variable. Click here for an example using a Change node. 2. Use the Switch node to check if expected context is already there. If the context is null, then you can use a Change node as described previously, otherwise, you can use the context that is there.


User context lives at msg.payload.context. The change node can be used to set the value, to, so that it can be referenced as $name. For example, create a Dialogue node which asks the user for their name, connect it to an Input node, and connect that Input node to a setContext node that looks something like this:

Now connect that setContext node to a Change node:

You can now reference the user’s name by calling $name. For example in a Dialogue node placed after the Change node, you could now put:

If is not always available a switch node checking that it is not null can be use to switch up what message is used:

Example using a Switch node

Save user name

[{"id":"e7f9ac15.f89fa8","type":"start","z":"36a987e3.d6314","name":"Start","x":160,"y":240,"wires":[["8a9e250.5133cd8"]]},{"id":"59d7df2f.898b4","type":"change","z":"36a987e3.d6314","name":"","rules":[{"t":"set","p":"","pt":"msg","to":"","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":220,"wires":[["abf6cd38.6e3088"]]},{"id":"abf6cd38.6e3088","type":"dialogue","z":"36a987e3.d6314","name":"","message":"Hi there $name!","messageType":"str","displayTimer":1.5,"enableDisplay":false,"x":760,"y":220,"wires":[[]]},{"id":"8a9e250.5133cd8","type":"switch","z":"36a987e3.d6314","name":"","property":"","propertyType":"msg","rules":[{"t":"nnull"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":240,"wires":[["59d7df2f.898b4"],["f7000c3e.64262"]]},{"id":"f7000c3e.64262","type":"dialogue","z":"36a987e3.d6314","name":"","message":"Hi there!","messageType":"str","displayTimer":1.5,"enableDisplay":false,"x":760,"y":260,"wires":[[]]}]