# Persist data across node executions

**URL:** <https://community.n8n.io/t/persist-data-across-node-executions/217722>\
**Category:** Questions\
**Created:** [November 7, 2025, 8:05am UTC](https://community.n8n.io/t/persist-data-across-node-executions/217722 "2025-11-07T08:05:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adibudithi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/adibudithi/32/133807_2.png) [@adibudithi](https://community.n8n.io/u/adibudithi)\
**Post date:** [November 7, 2025, 8:05am UTC](https://community.n8n.io/t/persist-data-across-node-executions/217722/1 "2025-11-07T08:05:08Z")

</div>

## Describe the problem/error/question

How do I persist data across node executions?

I’m building a simple chatbot node that connects to a chat trigger. I need to store previous messages to send to the AI every execution.

I don’t want to use Code nodes or any other nodes. I want it all in one node.

I’ve tried saving to `this.getWorkflowStaticData` but nothing ever saves.

## Please share your workflow

## Share the output returned by the last node

who are you  
I’m Claude, an AI assistant created by Anthropic. I’m here to help with a wide variety of tasks like answering questions, helping with analysis and research, creative writing, math and coding problems, or just having a conversation. Is there something specific I can help you with today?  
are you sure  
I don’t have context for what you’re asking me to be sure about, since this appears to be the start of our conversation. Could you clarify what specific topic or claim you’d like me to address? I’m happy to discuss whatever you have in mind and share how confident I am about different aspects of it.

## Information on your n8n setup

- **n8n version:** 1.117.3
- **Database (default: SQLite):** default
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):** default
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** npm
- **Operating system:** WSL

---

<div class="post-metadata">

**Author:** ![Mookie\_Lian](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mookie_lian/32/100252_2.png) [@Mookie\_Lian](https://community.n8n.io/u/Mookie_Lian)\
**Post date:** [November 7, 2025, 8:21am UTC](https://community.n8n.io/t/persist-data-across-node-executions/217722/2 "2025-11-07T08:21:20Z")

</div>

If I understood you correctly, you just need a memory(refer to image). Use Simple Memory to store previous interactions within the workflow. For production you have to use Postgres or Redis.

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/e/6/e63a5d8db83ae84bdce803933fcbdc90f9c235c4.jpeg)

Note: Chat trigger has `sessionId`parameter, which you can use as memory key as follows: `{{ $json.sessionId }}` or `{{ $('When chat message received').item.json.sessionId }}`. Simple Memory already uses it in default. For other memories, you have to point it out manually.

---

<div class="post-metadata">

**Author:** ![adibudithi](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/adibudithi/32/133807_2.png) [@adibudithi](https://community.n8n.io/u/adibudithi)\
**Post date:** [November 7, 2025, 8:59am UTC](https://community.n8n.io/t/persist-data-across-node-executions/217722/3 "2025-11-07T08:59:28Z")

</div>

Thanks for the reply Mookie.

I’ve used the AI Agent before but that’s not exactly what I’m trying to do. Let me try to explain.

I’m building custom nodes for my company. We offer AI hosting. I want this node to preserve chat history by itself. Use it like a simple chatbot. Just a couple messages until it is refreshed.

You mentioned `sessionId`. Is there a way to access the chat trigger session data from inside the execute function of my custom node? I want to retrieve the session history and send it to the AI manually so it can generate the next response.

---

<div class="post-metadata">

**Author:** ![Mookie\_Lian](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mookie_lian/32/100252_2.png) [@Mookie\_Lian](https://community.n8n.io/u/Mookie_Lian)\
**Post date:** [November 7, 2025, 9:21am UTC](https://community.n8n.io/t/persist-data-across-node-executions/217722/4 "2025-11-07T09:21:06Z")

</div>

Ah, didn’t realize your were creating a custom node 😅

I just checked the nodes base of n8n. They mention `memory?: BaseChatMemory` more than once in functions. Also here is a code snippet for loading chat history, from the same file:

```auto
async function loadChatHistory(
	memory: BaseChatMemory,
	model: BaseChatModel,
	maxTokensFromMemory?: number,
): Promise<BaseMessage[]> {
	const memoryVariables = await memory.loadMemoryVariables({});
	let chatHistory = memoryVariables['chat_history'] as BaseMessage[];

	if (maxTokensFromMemory) {
		chatHistory = await trimMessages(chatHistory, {
			strategy: 'last',
			maxTokens: maxTokensFromMemory,
			tokenCounter: model,
			includeSystem: true,
			startOn: 'human',
			allowPartial: true,
		});
	}

	return chatHistory;
}

```

You can view the complete file from [here](https://github.com/n8n-io/n8n/blob/master/packages/%2540n8n/nodes-langchain/nodes/agents/Agent/agents/ToolsAgent/V3/execute.ts#L4).

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [February 5, 2026, 9:21am UTC](https://community.n8n.io/t/persist-data-across-node-executions/217722/5 "2026-02-05T09:21:46Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
