js function access to state #5009
-
Hello, start -> condition (I wrote here a big JS function) -> 2 llm options (works fine) + 3 built-in answers from a JS function. -> 5 end nodes. my issue is that the JS functions need access to a state variable. how should I solve this? Thanks ahead. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
Yes, it pretty much works the same in custom js node: |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Hi.
You can simply access it via $flow.state.STATEVARIABLE
So here I have create a state variable for my flow:
I can simple access it the following in my JS code:
const jwtToken = $flow.state.jwtTOKEN;
When using it in a tool, is is probably good practise to add it to the input schema, so the Agent gives you feedback when something is missing: