Learning Timeline
Key Insights
Context Retention Logic
Without the `-r` flag and Session ID, questions like 'Why is one of them down?' will fail because the AI treats every request as a brand new conversation. The Session ID links the interactions.
Prompts
Initial Status Query
Target:
Claude Code
how many access points are up right now
Contextual Follow-up
Target:
Claude Code
Why is one of them down?
Step by Step
Generating a Session UUID in n8n
- Click the '+' button to add a new node.
- Search for and select the 'Code' node.
- Ensure the language is set to 'JavaScript' in the node settings.
- Input a JavaScript function to generate a random UUID (Universally Unique Identifier).
- Execute the node to generate the ID variable.
Initiating a Persistent AI Session
- Open the configuration for the node executing the Claude Code command.
- In the command input field, type your initial prompt (e.g., 'how many access points are up right now').
- Append the flag `--session-id` to the end of the command string.
- Drag and drop the UUID variable from the previous Code node into the command field after the flag.
- Ensure there is a space between the flag and the variable.
- Click 'Execute Node' to run the initial query.
Resuming Context in Follow-up Steps
- Create or configure a new command node for the follow-up interaction.
- Enter a context-dependent prompt (e.g., 'Why is one of them down?').
- Append the `-r` (resume) flag to the command string.
- Map the *same* UUID variable from the initial Code node after the `-r` flag.
- Click 'Execute Node' to process the prompt using the history from the previous step.