if I want to store key value data for n8n other workflow to use but dont have access to…
- User
if I want to store key value data for n8n other workflow to use but dont have access to redis what can I do
Assistant
Storing Key-Value Data for n8n Workflows Without Redis
If you don't have access to Redis but need to store key-value data that can be accessed across n8n workflows, here are several alternatives:
1. n8n Built-in Options
- n8n Variables: Use n8n's variable feature to store data that persists between workflow executions
- Workflow Data: Store data in n8n workflow data (though this has limitations for cross-workflow access)
2. Database Options
- SQLite: Lightweight database that can be used without a server
- PostgreSQL/MySQL: If you have access to a database server
- MongoDB: For document-based storage
3. File-based Storage
- JSON files: Store data in JSON files on the n8n server
- n8n's Filesystem node: Read/write data to files
4. External Services
- Supabase: Provides a PostgreSQL database with a REST API
- Firebase Realtime Database: Cloud-hosted NoSQL database
- AWS DynamoDB: Managed key-value store service
- Airtable: Spreadsheet-database hybrid with API access
5. Self-hosted Options
- Etcd: Distributed key-value store
- LevelDB: Fast key-value storage library
Implementation Example
For a simple solution using JSON files:
-
Create a workflow with an "Execute Command" node to write data:
codeecho '{"key": "value"}' > /path/to/data.json -
In another workflow, read the data:
codecat /path/to/data.json -
Parse the JSON response to access your key-value data
The best option depends on your specific requirements for persistence, performance, and complexity.
- User
how can I save a json file on the server so that another workflow can use it
Assistant
Saving JSON Files on n8n Server for Cross-Workflow Use
Here's a step-by-step guide to save JSON data to a file on your n8n server that can be accessed by other workflows:
Method 1: Using the Write Binary File Node
- User
help me adjust this code so that each item generated has a key, one that says description and anoter one that says content: const input = $json.graph; // access the 'graph' array inside the first item
const descriptions = {}; const decodedContents = {};
for (const entry of input) { const key = Object.keys(entry)[0]; const value = entry[key];
descriptions[key] = value.description; decodedContents[key] = value.decodedContent; }
// Return two outputs: one with descriptions, one with decodedContents return [ { json: descriptions }, { json: decodedContents } ];
Assistant
Adjusted Code for Structured Items with Description and Content
Here's the adjusted code that will generate items where each has both a description and content key:
javascriptconst input = $json.graph; // access the 'graph' array inside the first item // Create an array to hold our structured items const structuredItems = []; for (const entry of input) { const key = Object.keys(entry)[0]; const value = entry[key]; // Create a new item with the key as identifier and both description and content fields structuredItems.push({ json: { key: key, description: value.description, content: value.decodedContent } }); } // Return all items as separate outputs return structuredItems;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.