Replay an AI Workflow in n8n
Build a tamper-evident audit trail and replay past AI workflow runs.
Introduction
30 Second Summary
A decision can look obvious today but feel baffling a month later. Without a record of what happened, disagreement turns into guesswork.
In this project, you will build a local n8n workflow with a replayable audit trail for model answers. Its linked records reveal changes to stored history.
What You'll Build
Picture opening an audit table that tells the complete story behind a model answer from last month.
By the end of this project, you'll have:
- A working question workflow that turns each question into a model-generated answer.
- A tamper-evident audit table whose hash chain points to the exact row where stored history changed. Each row captures the timestamp, node, input, output, model name, and token count.
- A replay view that places a stored answer beside a fresh result from the same input.
- Secret Mission: An optional challenge to push your workflow auditing skills further.
Are there any prerequisites?
You need Node on your laptop plus a model API key. The local automation costs nothing, while several small model calls may cost a few cents in total.
Before We Start
Your audit trail needs a dependable place to run before it can capture any decisions. A local n8n instance keeps the workflow data on your laptop while you build.
Node.js supplies the runtime for the local editor. An OpenAI credential gives the later model node permission to make requests.
In this step, get ready to:
- Prepare a supported local runtime.
- Start the n8n workflow editor.
- Ready the workspace for model workflows.
Choose a supported Node.js runtime
n8n uses Node.js to run on your laptop. The npm installation supports Node.js versions from 20.19 through 24.x.
- Press Cmd+Space on macOS or the Windows key on Windows to open system search.
- Type Terminal on macOS or PowerShell on Windows into the search bar.
- Press Enter to open the terminal.
- Reveal your installed Node.js version by running this command:
node -v
What does this command do?
The node command prints the installed Node.js version. That result tells you whether your laptop can run the local n8n installation.
✔️ My version is supported
Your runtime is ready if the result falls between 20.19 and 24.x. You can continue to the n8n installation.
ⓧ I see an unsupported version
Your installed version falls outside the range supported by this n8n installation. Install the supported Node.js LTS release before continuing.
- Visit the official Node.js download page.
- Choose the v24.21.0 LTS installer for your operating system.
- Run the downloaded installer using its default options.
- Close the terminal after the installation finishes.
- Reopen the terminal through system search.
- Repeat the version check from above.
You should now see a version in the supported range.
ⓧ Command not found
Node.js is not installed yet. Its official installer also provides npm for installing n8n.
- Visit the official Node.js download page.
- Choose the v24.21.0 LTS installer for your operating system.
- Run the downloaded installer using its default options.
- Close the terminal after the installation finishes.
- Reopen the terminal through system search.
- Repeat the version check from above.
You should now see a version in the supported range.
Launch your local workflow editor
The n8n editor provides the canvas where you build each workflow. Installing it globally makes its command available from your terminal.
The first installation can take a few minutes while npm downloads the required packages. A stream of package names during this process is expected.
- Install n8n globally by running this command:
npm install n8n -g
What does this command do?
- The npm command downloads the n8n package.
- The -g flag makes the n8n command available across your terminal sessions.
The terminal returns to its prompt when the installation finishes. Your local n8n command is now available.
Installation not completing?
If npm is unavailable, return to the Node.js check above. Reinstall the supported LTS release before retrying.
If the installation reports a permissions problem, repair Node.js with its official installer. Help me troubleshoot this n8n installation.
Starting n8n keeps the terminal occupied while the editor is running. Leave this terminal open until you finish working on the project.
- Start your local n8n instance by running this command:
n8n start
What does this command do?
- The n8n start command launches the workflow editor on your laptop.
- The process remains active in this terminal while n8n is available.
- The editor uses local port 5678.
The first launch can take a few moments while n8n prepares its local data. Wait until the terminal indicates that the editor is ready.
- Enter http://localhost:5678 in your browser address bar.
- Press Enter to load the local editor.
- Enter your details on the signup screen.
- Use a password with at least eight characters.
- Include at least one number in the password.
- Include at least one capital letter in the password.
- Click Next to create the owner account.
You should see the n8n workspace in your browser. Your local instance is now accepting editor requests.
Local editor not loading?
Keep the terminal running because closing it stops the local instance. Confirm that the address uses port 5678.
Wait for the startup process to finish before refreshing the browser. Help me diagnose the local n8n connection.
Secure model access and check the workspace
An n8n credential stores authentication details for an external service. The later workflow can reference the saved credential without placing the secret on its canvas.
Protect your API key
Handling a live API key can feel risky. Keep the key on your device while moving it from OpenAI into n8n.
Never paste the key into a validation response. Never include the full key in a screenshot.
- Open the OpenAI API keys page in a separate browser tab.
- Log in to your OpenAI account or create an account.
- Select Create new secret key.
- Copy the new key when OpenAI reveals it.
OpenAI displays the full secret only when you create it. Transfer it directly into the credential form before closing the key dialog.
- Return to the n8n browser tab.
- Select Create in the upper-left corner of the side menu.
- Select Credential.
- Choose OpenAI as the service.
- Paste the copied key into the API Key field.
- Leave the Organization ID field blank unless your account belongs to multiple organizations.
- Save the credential using the control in the credential modal.
n8n tests the credential when you save it. You should see the OpenAI credential listed with its key hidden.
Credential not saving?
Confirm that you pasted the same key OpenAI revealed during creation. Generate a new key if the original value is no longer available.
Only add an Organization ID when your account requires one. Help me troubleshoot this OpenAI credential.
A data table stores structured records inside n8n. Your audit workflow uses this area later to keep its history readable.
Before you check, predict whether the local workspace now exposes controls for both workflows and data tables.
- Return to your personal project Overview in n8n.
- Open the Create menu.
- Confirm that the menu offers an option to create a workflow.
- Dismiss the menu by clicking outside it.
- Select the Data tables tab.
- Confirm that Create Data table is available in the top-right corner.
You should see the Data tables page with its creation control. This confirms that the local workspace has the storage feature required for the audit trail.
Your local n8n workspace is running with secure model access. Next, you will build the first workflow and watch it answer a question.
Build and Run the Model Workflow
Before an audit trail can tell a useful story, the workflow needs a real model decision to capture. This first run becomes the baseline for every record you add later.
Your local n8n instance already has an OpenAI credential. You will connect one question to an LLM so its answer becomes the first observable workflow result.
In this step, get ready to:
- Create the named workflow input.
- Connect the question to an OpenAI model.
- Run the workflow once.
Create the Workflow Input
A Manual Trigger gives you a controlled starting point for each test. An Edit Fields node supplies the exact question that each run receives.
- Switch back to the local n8n browser tab from earlier.
- Select Create workflow in the side menu.
- Select Add first step on the empty canvas.
- Search for Manual Trigger.
- Select Manual Trigger.
- Select the workflow title in the canvas header.
- Enter Replayable AI Workflow as the workflow name.
Your draft now has a controlled starting point. n8n saves the workflow changes while you work.
- Hover over Manual Trigger on the canvas.
- Select the Add node connector.
- Search for Edit Fields.
- Select Edit Fields.
- Select the new node on the canvas.
- Press F2 to rename the selected node.
- Enter Set Question as the node name.
The main path now starts with Manual Trigger followed by Set Question.
- Double-click Set Question to open its details.
- Set Mode to Manual Mapping.
- Select Add fields under Fields to Set.
- Enter question in Name.
- Select Fixed for Value.
- Enter What is a hash chain? in Value.
- Close the node details.
The fixed field gives every test run the same starting input. This makes later comparisons meaningful.
- Select Set Question on the canvas.
- Select Execute step.
You will see one output item containing the question field. Its value is What is a hash chain?.
What Is the Input Record?
Edit Fields creates one JSON item with a named field. The field keeps the question separate from the nodes that process it.
Each downstream node receives that item as its input. The question now has a visible path through the workflow.
Question Missing from the Output?
Confirm that Mode is set to Manual Mapping. Check that the field name is exactly question.
Make sure the value uses Fixed mode. Help me troubleshoot the Set Question output.
Connect the Chain and Model
A Basic LLM Chain turns the incoming question into a model prompt. An OpenAI Chat Model supplies the model that generates the answer.
Why Separate the Prompt and Model?
The chain owns the prompt mapping. The model sub-node owns the provider-specific configuration.
This separation keeps the question flow visible on the canvas. Later audit records can describe each responsibility clearly.
- Hover over Set Question on the canvas.
- Select the Add node connector.
- Search for Basic LLM Chain.
- Select Basic LLM Chain.
- Select the new chain node on the canvas.
- Press F2 to rename the selected node.
- Enter Answer Question as the node name.
- Double-click Answer Question to open its details.
The main workflow path now ends at Answer Question. Its prompt still needs to read the field created by the previous node.
- Set Prompt to Define below.
- Switch Prompt (User Message) to Expression mode.
- Enter {{ $json.question }} as the prompt expression.
- Close the node details.
The prompt now reads the question field from Set Question. Changing that field later changes the model input without rebuilding the chain.
- Select the language-model connector beneath Answer Question.
- Search for OpenAI Chat Model.
- Select OpenAI Chat Model.
- Select the OpenAI credential from earlier under Credential to connect with.
- Set Model to gpt-4o-mini.
- Close the model details.
The canvas now shows the model attached beneath Answer Question. The main path remains Manual Trigger followed by Set Question followed by Answer Question.
Model Node Not Connecting?
Confirm that you added the model from the language-model connector beneath Answer Question. A model placed on the canvas without that connection cannot power the chain.
Check that the credential from earlier is selected. Help me check this n8n model connection.
✔️ My workflow matches
Your draft is ready for its first complete execution.
ⓧ I'd like to double check the setup
- The workflow is named Replayable AI Workflow.
- Manual Trigger connects to Set Question.
- Set Question is an Edit Fields node.
- Set Question defines question as What is a hash chain?.
- Set Question connects to Answer Question.
- Answer Question is a Basic LLM Chain.
- Answer Question uses {{ $json.question }} as its prompt.
- OpenAI Chat Model connects beneath Answer Question.
- OpenAI Chat Model uses gpt-4o-mini.
- The workflow remains a draft.
Run the Workflow
The complete workflow is ready for its first model decision. This run proves that the fixed question reaches the configured model.
This sends one short request through your OpenAI credential. You control the timing because the Manual Trigger only starts when you execute the workflow.
Before you run it, what kind of explanation do you expect the model to return for the question?
- Select Execute Workflow in the canvas header.
You will see a successful status on each node in the main path. The execution view keeps the result available for inspection.
- Select Answer Question in the execution view.
You will see a model-generated explanation of a hash chain in the output. The wording may vary because the answer comes from the model.
That first successful answer is now your baseline. Your workflow can produce a decision that the next step can record.
No Model Answer in the Output?
Confirm that Answer Question uses the prompt expression {{ $json.question }}. Check that Set Question still outputs the question field.
Return to OpenAI Chat Model if the run reports a credential or model problem. Confirm that the credential from earlier is selected with gpt-4o-mini. Help me troubleshoot this model execution.
Your workflow can now answer a stored question. Next, you will write one audit row for that action.
Record the First Audit Entry
Your first model answer proved that your n8n workflow can respond to a question. That result still lives inside one execution.
An audit trail gives each action a durable record. This step creates the first record beside your workflow.
In this step, get ready to:
- Create the audit table with fields for the model action.
- Add a writer that inserts one audit row after each answer.
- Run the workflow to inspect the first stored record.
Create the audit table
A Data Table stores structured rows inside n8n. Your table needs enough context to identify the run that produced each answer.
- Select the Data tables tab in your n8n project.
- Click the split button in the top right corner.
- Select Create Data table.
- Enter AI Audit Trail in the Name field.
- Select From scratch.
You will see an empty table where each header defines one part of the audit record.
- Use Add Column to create String fields for runId, nodeName, input, output, model, previousHash, and rowHash.
You should see seven text headers across the table.
- Use Add Column to create timestamp with the Date type.
- Use Add Column to create tokenCount with the Number type.
The empty table now has nine columns. Its structure is ready for the first model-action record.
Why use three field types?
- The text fields preserve identifiers plus readable model data.
- The date field keeps each action tied to a moment in time.
- The number field keeps token usage ready for later comparisons.
Configure the audit writer
A separate writer keeps the audit schema independent from answer generation. Each successful model action can become its own row.
The existing OpenAI Chat Model supplies the model context for that row. The writer also carries forward the question plus its generated answer.
- Return to Replayable AI Workflow in the n8n browser tab.
- Select the main output connector on Answer Question.
- Add a Data Table node from the node picker.
- Rename the new node Write Audit Record.
The canvas now shows Write Audit Record directly after Answer Question.
- Set Resource to Row.
- Set Operation to Insert.
What does Insert do?
The insert operation adds a new row for every incoming item. Answer Question sends one item during this test.
- Set Data table to From list.
- Select AI Audit Trail.
The node now points to the table you created.
- Set Mapping Column Mode to Map Each Column Manually.
The mapping area now lists the columns from AI Audit Trail.
- Map runId to the built-in $execution.id value.
- Map timestamp to the built-in $now value.
The field previews should show an execution identifier plus the current time.
- Set nodeName to Answer Question.
- Map input from the question field in Set Question.
The input preview should show What is a hash chain?.
- Map output from the answer value shown under Answer Question.
- Set model to gpt-4o-mini.
The output preview should contain the generated explanation from the model.
- Map tokenCount from the total token count shown for the OpenAI Chat Model action.
- Leave previousHash plus rowHash empty.
What will the row preserve?
- The runId identifies the execution. The timestamp records when it happened.
- The input preserves what the model received. The output preserves what it returned.
- The model records which model ran. The tokenCount records its usage.
- The hash fields stay blank until the workflow gains record linking.
Verify the first audit record
A full test proves that the writer sits on the workflow's main path. Before you run it, do you expect the table to contain zero rows or one row?
- Run the workflow from the editor.
You will see every main workflow node finish successfully. Write Audit Record returns the inserted row.
- Return to your n8n project overview.
- Select the Data tables tab.
- Open AI Audit Trail.
Read the first row
- The runId cell contains the test execution's identifier.
- The timestamp cell contains the time of the audit write.
- The nodeName cell reads Answer Question.
- The input cell reads What is a hash chain?.
- The output cell contains the model-generated answer.
- The model cell reads gpt-4o-mini.
- The tokenCount cell contains the recorded usage count.
- The previousHash plus rowHash cells are blank.
That is your first durable audit record. You can now answer what the workflow saw during this run.
Don't see a complete audit row?
Confirm that Write Audit Record is connected after Answer Question. Check that its operation targets AI Audit Trail.
Reopen the mapping if any populated field is blank. Use the expression data picker to select values from the latest execution.
Inspect the latest model action if tokenCount is empty. Remap the displayed total token count before testing again. Help me diagnose this incomplete audit row.
One row proves that the audit writer works. Next, you will run new questions to turn this checkpoint into a readable trail.
Build a Multi-Run Audit Trail
Your first stored row proves that n8n can preserve the model input. It also preserves the model output.
One row is a snapshot. A Data Table becomes an audit trail when several executions can be read as one history.
In this step, get ready to:
- Run the workflow with three new questions.
- Confirm each execution creates a separate audit row.
- Read four rows as a connected run history.
Run the second question
Your existing row already counts as the first run. Each new manual execution receives its own runId.
- Switch back to the Replayable AI Workflow editor from earlier.
- Select the Set Question node on the canvas.
- Replace the value beside question with Why do audit logs need timestamps?.
- Select Execute Workflow at the bottom of the editor.
You'll see all four nodes complete successfully. The second execution has reached the audit writer.
- Return to your n8n project Overview.
- Select the Data tables tab.
- Select AI Audit Trail.
You'll see two rows in the table. Their input values show the two different questions.
Second row missing?
- Confirm that Write Audit Record completed during the second execution.
- Check that the value in Set Question matches the second question exactly.
- Rerun the second question only if the table still contains one row.
Need help tracing the missing record? Help me diagnose why my n8n execution did not add a second row to AI Audit Trail.
Add two more runs
Variation makes a run history useful. Each question creates a recognisable input that you can trace to its stored answer.
- Return to the Replayable AI Workflow editor from earlier.
- Select the Set Question node.
- Replace the value beside question with What information should an AI audit record contain?.
- Select Execute Workflow to create the third execution.
You'll see the workflow complete successfully. The audit writer has recorded the third question.
- Select the Set Question node again.
- Replace the value beside question with How can I replay an AI workflow run?.
- Select Execute Workflow to create the fourth execution.
You'll see every node complete successfully again. The workflow has now processed all four questions.
Workflow stopped before the audit node?
- Inspect the first node that did not complete successfully.
- Confirm that the OpenAI credential from earlier remains selected in Answer Question.
- Run the affected question again after the node completes successfully.
Need help finding the failed node? Help me trace this n8n execution failure.
Read the four-row trail
Four rows are enough to see the workflow as a sequence. The shared columns make each execution comparable.
Before you open the table, how many distinct execution IDs do you expect to find?
- Return to your n8n project Overview.
- Select the Data tables tab.
- Select AI Audit Trail.
- Count the visible audit rows.
- Compare the runId values.
- Scan every row across the remaining columns.
What should I see?
- The table contains four audit rows.
- One input cell contains What is a hash chain?.
- One input cell contains Why do audit logs need timestamps?.
- One input cell contains What information should an AI audit record contain?.
- One input cell contains How can I replay an AI workflow run?.
- Each runId differs from the other three.
- Every timestamp cell contains its execution time.
- Every nodeName cell reads Answer Question.
- Every output cell contains the recorded model answer.
- Every model cell reads gpt-4o-mini.
- Every tokenCount cell contains the recorded usage count.
- Every previousHash cell is blank. Every rowHash cell is blank.
That is the trail working. Four executions now read like a compact history of what the model received.
Seeing fewer than four rows?
- Return to the workflow editor if fewer than four rows appear.
- Run each missing question once with Execute Workflow.
- Confirm that Write Audit Record completes before checking the table again.
Need help matching executions to rows? Help me find the missing audit record.
Your audit trail now tells the story of four separate runs. Next, you'll link its rows so a hidden edit breaks the chain visibly.
Chain Audit Records with Hashes
Your four audit rows now show what each model call saw. However, each row still stands alone.
A hash chain links every new record to the record before it. This gives your n8n workflow evidence when stored history changes.
In this step, get ready to:
- Retrieve the most recent audit record before writing a new one.
- Calculate a fixed-order SHA-256 fingerprint for each new record.
- Prove that two consecutive audit records form a visible link.
Retrieve the previous audit record
Every new record needs the fingerprint stored by its predecessor. The workflow must retrieve the latest row before it calculates the next fingerprint.
- Switch back to the workflow canvas for Replayable AI Workflow.
- Locate the connection from Answer Question to Write Audit Record.
- Insert a Data Table node into that connection.
- Set the node name to Get Previous Audit Record.
- Set Resource to Row.
- Set Operation to Get.
- Select AI Audit Trail as the data table.
Why retrieve only one row?
The newest stored row is the predecessor for the next action. Retrieving one ordered result keeps the workflow focused on that single link.
- Click Add Condition under Conditions.
- Choose timestamp as the condition column.
- Choose Is Not Empty as the comparison.
- Turn off Return All.
- Set Limit to 1.
- Turn on Order By.
- Choose timestamp as the ordering column.
- Choose Descending as the ordering direction.
Before you test this lookup, which of the four stored questions do you expect the node to return?
- Test only Get Previous Audit Record from its node panel.
You should see one row for How can I replay an AI workflow run?. Its rowHash is still blank.
Retrieved the wrong row?
Confirm that Order By uses timestamp. Confirm that the direction is Descending.
Check that Limit is set to 1. Help me troubleshoot my latest-row lookup.
Create the audit hash
A SHA-256 hash turns the current audit values into a fingerprint. The same values in the same order always produce the same fingerprint.
The current row also includes the previous fingerprint. Changing an older row breaks the values that later rows expect to find.
- Insert an Edit Fields (Set) node between Get Previous Audit Record and Write Audit Record.
- Set the node name to Create Audit Hash.
- Select Manual Mapping for Mode.
- Add a string field named previousHash.
- Set previousHash to {{ $json.rowHash || '' }} in expression mode.
- Add a string field named rowHash.
Use one fixed field order
Build the hash source from the existing value expressions in Write Audit Record. Keep the order exactly as shown below.
- Use runId first.
- Use timestamp second.
- Use nodeName third.
- Use input fourth.
- Use output fifth.
- Use model sixth.
- Use tokenCount seventh.
- Use previousHash last.
A different field order produces a different fingerprint. The fixed order makes later verification repeatable.
- Open the existing Write Audit Record node.
- Copy its current source expression for each audit field.
- Return to Create Audit Hash.
- Build the rowHash source from those expressions in the fixed order above.
- Place one | character between each value.
- Apply hash("sha256") to the completed source string.
- Configure the node to keep its input fields in the output.
What does this mapping produce?
- The retrieved rowHash becomes the new record's previousHash.
- The current audit values produce a new rowHash.
- The | separators keep adjacent values from blending together.
- Test only Create Audit Hash from its node panel.
You should see a blank previousHash because the latest original row has no fingerprint. You should also see a populated rowHash for the new record.
- Return to Write Audit Record.
- Map its previousHash column from the matching Create Audit Hash output field.
- Map its rowHash column from the matching Create Audit Hash output field.
- Confirm that the other seven audit columns still use their existing mappings.
Hash field still blank?
Confirm that the source contains all eight values in the listed order. Check that every value is separated by one | character.
Make sure the completed string uses hash("sha256"). Help me debug my audit hash expression.
Prove that two records are linked
The first hashed row starts the new chain because the older rows have blank fingerprints. The next run creates the first visible link between two consecutive hashed rows.
- Open Set Question from the workflow canvas.
- Replace its question with What makes an audit record tamper-evident?.
- Run the complete workflow from Manual Trigger.
The execution completes through Write Audit Record. Your first hashed audit row is now stored.
- Return to Set Question.
- Replace its question with How does a previous hash link audit records?.
Before you run the workflow again, which stored fingerprint do you expect the next record to carry as its previousHash?
- Run the complete workflow from Manual Trigger.
- Switch back to the open AI Audit Trail table.
- Locate the two newest rows by their timestamp values.
- Compare the preceding row's rowHash with the newest row's previousHash.
The two values match exactly. That link proves the newest record points back to the fingerprint of the record before it.
You now have four original rows plus two hashed rows. The audit trail has become a chain that can expose a later edit.
Hashes do not match?
Confirm that the second run retrieved the first hashed row using descending timestamp order. Check that previousHash in Write Audit Record maps from Create Audit Hash.
Verify that both runs used the same field order and separators. Help me find why my consecutive audit hashes do not link.
Your workflow now leaves a linked trail behind every new model action. Next, you will change one stored record and pinpoint where that chain breaks.
Verify a Tampered Audit Trail
The two newest rows in your n8n audit table now form a visible hash chain. This step turns that link into a tamper test.
A manual edit leaves the stored rowHash looking convincing. Your verifier must rebuild each hash from the stored fields before it can expose the changed row.
In this step, get ready to:
- Alter one stored output without changing its saved hash.
- Add a path that verifies the hashed audit rows.
- Prove the report identifies both broken checks.
Tamper with a hashed audit row
A tamper test needs one controlled change. This deliberate edit changes only one stored answer.
- Return to the open AI Audit Trail Data Table from earlier.
- Select the older of the two newest hashed rows.
- Confirm its rowHash is the value referenced by the newest row's previousHash.
- Use the row's edit control to make its fields editable.
The editable row shows output beside rowHash. The test changes only the stored answer.
- Change one word in the output field.
- Save the row using the table's row control.
The edited output now appears in the table. Its saved rowHash remains unchanged.
You now have controlled evidence for the verifier to catch. The table still looks plausible until its hashes are recalculated.
Build the verification path
A verifier needs a stable row order because every link points to an earlier record. The Data Table node supplies the hashed rows from oldest to newest.
- Switch back to the Replayable AI Workflow canvas from earlier.
- Add a Manual Trigger node on an empty area of the canvas.
You will see a separate starting point beside the model path. This keeps verification from making another model call.
- Rename the new trigger to Verify Audit Chain.
- Extend the new trigger with a Data Table node.
The new reader appears after the verification trigger. It can now retrieve the records without changing them.
- Select Row for the Resource.
- Select Get for the Operation.
The node now shows the settings for retrieving rows from one table.
- Select AI Audit Trail as the data table.
- Execute the Data Table node.
You will see all six stored audit rows in the node output. Four rows predate the hash chain.
- Enable Return All.
- Add a condition that keeps rows where rowHash is Is Not Empty.
- Execute the Data Table node again.
You will see the two hashed rows. The four earlier rows stay outside this verification pass.
- Enable Order By.
- Select timestamp as the ordering column.
The ordering controls now show a direction setting for the selected column.
- Select Ascending as the direction.
- Execute the Data Table node again.
The older hashed row now appears first. The newer hashed row follows it.
A Code node can verify the complete sequence in one pass. It recalculates each SHA-256 hash before checking the link to the next row.
- Add a Code node after the Data Table node.
The verification path now contains a trigger, a sorted row reader, and a place for the integrity checks.
What Does the Verifier Check?
- The verifier receives every hashed row in timestamp order.
- It rebuilds each hash from runId, timestamp, nodeName, input, output, model, tokenCount, and previousHash in the same fixed order used by Create Audit Hash.
- It compares the recalculated value with the stored rowHash.
- It compares each previousHash with the preceding row's recalculated hash.
- It returns one report item per hashed row with both comparison results.
- Set the Mode to Run Once for All Items.
- Implement the JavaScript verifier using the fixed field order and comparison rules above.
Run the chain check
The verification path is ready to test against the row you changed.
Before you run it, which row do you think the verifier will flag first?
- Run the Verify Audit Chain path from its trigger.
- Select the Code node after the execution finishes.
The report identifies the edited row as having a rowHash mismatch. It identifies the following row as having a broken previousHash link.
That is the proof your audit trail needed. The verifier points to the changed record before showing how the damage continues through the chain.
No Broken Link in the Report?
Confirm the edited output contains your change. Confirm the same row still holds its original rowHash.
Check that the reader sorts by timestamp in ascending order. Check that the verifier uses the same fixed field order as Create Audit Hash.
If the report still misses the tampered row, help me debug my audit-chain verification path.
Your audit trail can now show exactly where stored history changed. Next, you will replay an old run and compare its new answer with the recorded output.
Replay and Compare an Old Run
The chain check in your n8n workflow has already exposed the edited row. Now you will use the stored history to rerun one earlier question.
A replay feeds stored input back to the same model. The comparison answers whether the new response matches what the trail recorded.
In this step, get ready to:
- Select an old audit record by its runId.
- Send the stored input through the same model again.
- View the recorded output beside the replayed output.
Choose the run to replay
A replay starts from a specific runId. That identifier lets the Data Table retrieve one old record without changing the stored trail.
- Return to the Data tables tab from earlier.
- Select AI Audit Trail.
- Choose an unedited row whose nodeName is Answer Question.
- Record its runId here: run ID to replay.
- Switch back to the Replayable AI Workflow canvas from earlier.
You now have the address of one historical model action. The next nodes turn that address into a reusable replay path.
- Add a Manual Trigger node to an empty area of the canvas.
- Rename the new trigger Replay Stored Run.
- Connect an Edit Fields (Set) node after Replay Stored Run.
- Rename the new node Select Replay Run.
- Add a String field named runId.
- Set its fixed value to run ID to replay.
- Run Select Replay Run.
The output shows the selected runId. Your new trigger can now carry that identifier into the lookup.
- Select Get Previous Audit Record on the existing audit path.
- Use its node menu to create a duplicate.
- Rename the duplicate Get Stored Run.
- Connect Select Replay Run to Get Stored Run.
- Replace the duplicate's existing lookup condition with a condition on the runId column.
- Select Equals as the condition.
- Drag the incoming runId value into the condition's Value field.
- Run Get Stored Run.
The output shows the selected row's runId. It also shows the stored input beside the recorded output.
Why Select by Run ID?
The runId ties the replay to a specific historical action. This keeps the test anchored to what the workflow saw at that time.
The lookup only reads the row. Your manually altered record remains available as evidence for the broken hash chain.
Stored Row Not Appearing?
Confirm that Get Stored Run still targets AI Audit Trail. Check that its condition compares the runId column with the incoming value.
Make sure the selected identifier has no missing characters. Help me troubleshoot this audit row lookup.
Replay the stored input
The replay needs the same OpenAI configuration as the original action. Duplicating the existing model node preserves its credential setup plus its gpt-4o-mini selection.
- Select the existing Answer Question node.
- Use its node menu to create a duplicate.
- Rename the duplicate Replay Answer Question.
- Connect Get Stored Run to Replay Answer Question.
- Remove any outgoing connection from Replay Answer Question to Get Previous Audit Record.
- Open the Messages section in Replay Answer Question.
- Select the User message.
- Drag the stored input from Get Stored Run into the prompt field.
This test sends one model request through your configured credential. The credential stays masked inside n8n.
Before you run the replay, do you expect the new response to match the recorded answer exactly?
- Run Replay Answer Question.
You will see fresh response text in the node output. The replay has now processed the same stored input with gpt-4o-mini.
What Does the Replay Prove?
The replay proves that the audit row contains enough context to repeat the model action. It also gives you a fresh result to compare with the historical answer.
The isolated model copy does not connect to the audit writer. The replay therefore leaves the six stored rows unchanged.
Replay Request Not Completing?
Confirm that the replay copy still uses your configured OpenAI credential. Check that its Model field shows gpt-4o-mini.
Verify that the prompt preview contains the stored question from Get Stored Run. Help me troubleshoot this replay request.
Build the comparison
A useful replay result keeps the historical context beside the new answer. Four fields capture that evidence before the workflow calculates an exact match.
- Add an Edit Fields (Set) node after Replay Answer Question.
- Rename the new node Build Replay Comparison.
- Add a String field named originalRunId.
- Drag runId from Get Stored Run into originalRunId.
- Add a String field named storedInput.
- Drag input from Get Stored Run into storedInput.
- Add a String field named recordedOutput.
- Drag output from Get Stored Run into recordedOutput.
Why Keep Both Answers Together?
The stored fields preserve the original run as evidence. The replayed field captures what the model returns today.
Keeping them in one output makes the comparison readable without switching between nodes.
- Add a String field named replayedOutput.
- Drag the response text from Replay Answer Question into replayedOutput.
- Run Build Replay Comparison.
The output now places originalRunId plus storedInput beside recordedOutput plus replayedOutput.
- Add an If node after Build Replay Comparison.
- Drag recordedOutput into the left comparison value.
- Select String as the data type.
- Select is equal to as the comparison.
- Drag replayedOutput into the right comparison value.
- Run the If node.
One output branch receives the comparison item. The true branch means the text matches exactly.
- Add an Edit Fields (Set) node to the true output.
- Rename the true-path node Mark Replay Match.
- Add a String field named matchResult with the fixed value MATCH.
- Add an Edit Fields (Set) node to the false output.
- Rename the false-path node Mark Replay Difference.
- Add a String field named matchResult with the fixed value DIFFERENT.
- Keep all incoming comparison fields in both marker nodes.
- Save the Replayable AI Workflow.
Before the final run, which marker node do you think will receive the comparison?
- Run the Replay Stored Run trigger.
- Select the completed marker node.
You will see originalRunId plus storedInput plus both outputs. The matchResult field shows MATCH or DIFFERENT.
How Should You Read the Result?
A model can produce different wording from the same input. A DIFFERENT replay result therefore shows output drift.
The hash verification remains your evidence of a stored edit. Replay comparison answers a separate question about reproducibility.
Comparison Missing a Field?
Confirm that both marker nodes keep their incoming fields. Check each mapping in Build Replay Comparison against the output of its source node.
Make sure the If node compares recordedOutput with replayedOutput. Help me troubleshoot this replay comparison.
That completes the audit loop. You can now retrieve an old input plus rerun it plus inspect the result beside the recorded answer.
Secret mission
Investigate a Tampered Audit Record
Use the existing hash failures to locate the manually altered audit row. Then use its replay comparison to separate changed history from current model behavior.
Clean Up Your Resources
Clean Up Your Resources
Choose whether to keep the project active, pause it for later, or remove it. Local n8n has no ongoing hosting cost.
Resources you used:
- A running local n8n instance serving the editor in your browser.
- The Replayable AI Workflow containing every path you built.
- The AI Audit Trail data table containing your stored audit history.
- An OpenAI credential connected to the workflow.
Keep everything running
Keeping the project active lets you continue testing replays. Each new model call may add API usage charges.
- Leave the local n8n process running while you continue testing.
- Keep Replayable AI Workflow available for future replays.
- Keep AI Audit Trail available as evidence of the recorded runs.
- Keep the OpenAI credential connected while the workflow remains in use.
Pause - I'll come back to this later
Pausing preserves the workflow inside local n8n. The stopped process cannot start another model call.
Preserve the trail before stopping:
- Return to the AI Audit Trail table from earlier.
- Use the table's export control to save a local copy.
- Confirm the exported file appears in your browser's download list.
- Return to the terminal panel running n8n.
- Use your terminal's interrupt shortcut to stop the local n8n process.
- Refresh the n8n browser tab to confirm the local editor no longer loads.
You have safely parked the project. Your exported audit trail remains available outside the stopped instance.
Delete - I don't want to use this again
Removing the workflow plus its audit table is permanent. Your exported copy preserves the evidence you created.
Export the audit trail:
- Return to the AI Audit Trail table from earlier.
- Use the table's export control to save a local copy.
- Confirm the exported file appears in your browser's download list.
Remove the local project data:
- Return to Replayable AI Workflow from earlier.
- Open the workflow's options menu.
- Choose the action that permanently removes the workflow.
- Complete the confirmation prompt.
- Return to the AI Audit Trail table.
- Open the table's options menu.
- Choose the action that permanently removes the table.
- Complete the confirmation prompt.
Remove the credential if it only serves this project:
- Return to the OpenAI credential from earlier in n8n's credential manager.
- Open the credential's options menu.
- Choose the action that permanently removes the credential.
- Complete the confirmation prompt.
Stop local n8n:
- Return to the terminal panel running n8n.
- Use your terminal's interrupt shortcut to stop the local n8n process.
- Refresh the n8n browser tab to confirm the local editor no longer loads.
You have closed the loop. The removed workflow can no longer make model calls.
Nice Work!
Nice Work!
You pulled it off: your local n8n workflow now preserves every model action in a tamper-evident audit trail. It can replay a stored run beside its original output.
You've learned how to:
- Capture a complete audit record for each model action with its timestamp, node, input, output, model name, and token count.
- Verify a linked hash chain that pinpoints a manually edited row plus the broken link in the following record.
- Replay an old run from its stored input. Compare the replayed output with the recorded answer.
- Secret Mission: Extend the replayable audit workflow through an optional professional challenge.
Ready to quiz yourself?