Hey team,
I’m building a workflow using @n8n/langchain
AI Agent + HTTP request tool nodes. I want to dynamically inject a privatekey
from an auth request into the headers of downstream tool APIs — but I’m hitting roadblocks.
Goal
When a user selects a tool (like update_meter_status
) via AI Agent, n8n should:
- Call the
authorization_service
(returns aprivatekey
) - Pass that
privatekey
in the headers of the actual tool request - Not show the auth node (
Private Key
) in the AI’s tool list/menu
What I’ve Tried (and why it failed)
- Direct expression:
={{ $node["Private Key"].json[0].privatekey }}
Fails unless node was already executed → gets
undefined
orunexecuted
error - Inline
$http()
in expression:
={{ $http({...}).json[0].privatekey }}
Not supported —
$http
isn’t allowed in expressions - Merge node:
Tried combining AI input + Private Key before tool call
Doesn’t trigger both branches, second input usually unexecuted
- Code node to combine data:
Merged inputs manually
Same issue — one branch unexecuted
- Renaming node as
_internal_
to hide from menu
Still appears in AI tool list
What I’m Looking For
- A way to automatically run an internal auth node before any AI-selected tool executes
- Keep that auth node hidden from tool menu
- Reuse that
privatekey
in all downstream HTTP headers
Any clean solutions for this pattern?
Maybe using workflow context, credentials trick, or hidden pre-hooks?
Really appreciate your guidance — happy to share full workflow JSON too!
Thanks