Describe the problem/error/question
Imagine I have a Http-Request node with a body parameter called “message” that is set to an expression value that holds the “message”, ie. {{ $json.chatwood_message }} or {{ $any_node.item.json.chatwood_message}} or whatever you decide I should use.
The message is set differently depending on the path followed (splitted by a filter node). I.e. if the flow goes for upper path the “message” value is gathered from a webhook parameter like this {{ $(‘Webhook-Chatwood’).item.json.body.content_attributes.submitted_values[0].title }}, but if the flow goes for lower path the “message” value is gathered from a webhook parameter like this {{ $(‘Webhook-Chatwood’).item.json.body.conversation.messages[0].content }}
My problem is:
I don’t know a way to create a “variable” and set the value at any time in the workflow. So I ended up using a Redis node to set the variable and recover it later at future steps, what I’m pretty sure is a ugly implementation.
Worst is the case to split the whole path in 2 and have 2 http-requests nodes having the same parameters except the “message” value that should gather from different nodes.
I also played with the possibility of environment global variables using Code nodes, but it’s like to crack a nut with a sledgehammer.
My question is:
- Is it possible to create a variable (not a constant or read-only variable) and set (re re-set) the value at any point in time/flow, to be use at future steps?
If not…
- What is the best way/practices to solve my problem?
Please share your workflow
Share the output returned by the last node
Information on your n8n setup
- n8n version: 1.62.5
- Database (default: SQLite): SqLite
- n8n EXECUTIONS_PROCESS setting (default: own, main): main
- Running n8n via (Docker, npm, n8n cloud, desktop app): docker
- Operating system: Ubuntu 22.04