DEV Community

Cover image for The Zombie Ticket: Deleting a Chatbot Conversation Doesn't Delete It
Harsheen
Harsheen

Posted on AI-assisted

The Zombie Ticket: Deleting a Chatbot Conversation Doesn't Delete It

Deleting a conversation in a chatbot dashboard removes one record. A single support enquiry usually leaves several more: the helpdesk ticket created at handoff, a transcript emailed to the visitor, an export someone downloaded, a job waiting to retry, and whatever the model provider and backups keep. GDPR erasure applies to the person's data, not to one table, so a request is only finished when every copy is accounted for.

The remedy has three parts: a ledger of every place a conversation can land, a deletion path that fans out to each one while blocking queued work from recreating data, and a test that proves both. A short simulation below shows the resurrection happening and the guard stopping it. The trade-off is real: every store needs an owner, and some copies, such as provider logs and backups, can only be handled through contracts and retention terms, not code.

Follow One Enquiry Through the Stack

Start by tracing where a single message actually travels, because the list of copies is longer than the chat inbox suggests.

Diagram of one chatbot enquiry fanning out into a chat session, contact record, helpdesk ticket, emailed transcript, export file, knowledge base entry, retry queue and provider or backup copies, with only the chat session deleted

Each row below is a separate place personal data can sit, with the check that shows whether it is really gone.

Copy Created when Check after deletion
Chat session The visitor sends a message Open the session by ID and expect not found
Contact or lead record The widget captures a name or email Query by the identifier, separately from the session
Helpdesk ticket A conversation is handed to a human Open the old ticket URL and check notification messages
Emailed transcript A session closes and a summary is sent Check the sent copy and the mail service logs
Export file Someone downloads a conversation Find the file, including copies on laptops
Knowledge base entry A past answer is reused as source material Search the index for the person's identifiers and remove the source document
Retry queue A handoff fails and waits to run again List pending jobs for the person, cancel them, replay one
Provider copy and backups The model request runs and snapshots rotate Read the retention terms and record an expiry date and owner

The list grows with every tool the bot can call, so treat this table as a starting point for your own stack.

Erasure Starts With a Subject Key

Before any row can be erased, the system has to know which records belong to the same person.

The reliable approach is to mint an internal subject key at first contact and carry it into every downstream record: a custom field on the ticket, metadata on each knowledge base chunk, a mapping row for each export. Erasure then becomes a lookup by key instead of a search by name.

Two cases break that neat picture. When a request arrives with only an email address, resolve it through an identity map that stores a keyed hash of the email next to the subject key, so the lookup works without a plaintext table. And when a visitor pasted a phone number or order reference into free text, no key will find it, so search the stores for those identifiers directly and have a person review matches before deleting. Fuzzy matches deserve a human check, because deleting the wrong person's record is its own failure.

Why Deleting the Chat Is Not Erasure

The legal side explains why the ledger needs more than a "deleted" flag.

A conversation can relate to a person even when the visitor never types a name, because session identifiers, IP addresses and the message itself can all point back to them. When Article 17 applies, it reaches that personal data wherever it sits, though it applies only where a ground exists and carries exceptions. Article 19 adds a second duty: the controller must pass an erasure on to each recipient the data was disclosed to, unless that proves impossible or involves disproportionate effort, and must name those recipients if the person asks.

Some copies may legitimately stay. An invoice required by law is the usual example. The record is then kept under restricted access, its use is limited, and the reply to the person explains why.

Each row in the ledger therefore needs one of three statuses.

  • Erased: The copy was removed and a read-back confirmed it.
  • Pending: A processor or provider still has to act, with a named owner.
  • Retained: An exception applies, with the reason written down.

A request is not closed while any row has no status.

The Retry Job Problem

The ticket is the copy most likely to come back, because the system that created it once can create it again.

Consider a handoff that fails when the helpdesk API times out. The job is saved with the conversation payload and retried later. An erasure request arrives in between, the ticket that already exists is deleted, and the retry then succeeds and creates a fresh ticket from the saved payload. Nothing errors, and the data is back.

To check that this is more than a story, here is a local simulation: an in-memory helpdesk, a queue, a worker and an erase function, with no real services involved. It shows the mechanism, not production behavior. These are the two functions that matter, copied from the script.

async function runJob(job, midFlight) {
  const key = opaqueKey(job.subjectId);
  if (guarded && tombstones.has(key)) return "dropped (tombstone)";
  if (midFlight) await midFlight();
  const id = createTicket(job.payload);
  if (guarded && tombstones.has(key)) { helpdesk.delete(id); return "created then removed"; }
  return "created " + id;
}

async function erase(subjectId) {
  const key = opaqueKey(subjectId);
  if (guarded) {
    tombstones.add(key);
    for (let i = queue.length - 1; i >= 0; i--) if (opaqueKey(queue[i].subjectId) === key) queue.splice(i, 1);
  }
  for (const [id, p] of helpdesk) if (p.subjectId === subjectId) helpdesk.delete(id);
}
Enter fullscreen mode Exit fullscreen mode

Running the full script prints this.

A. No tombstone, no queue cancel
  first handoff:         created T-1
  tickets after erase:   0
  retry worker result:   created T-2
  tickets after retry:   1

B. Tombstone and queue cancel (job still queued)
  first handoff:         created T-1
  tickets after erase:   0
  retry worker result:   queue empty
  tickets after retry:   0

C. Tombstone guard when the job is already in flight
  job already dequeued, erase first:   dropped (tombstone) | tickets: 0
  erase lands mid-flight:              created then removed | tickets: 0
Enter fullscreen mode Exit fullscreen mode

Scenario A is the zombie. The erase removes the first ticket, the retry worker drains the queue, and one ticket exists again. Scenario B shows the first two fixes working together: the tombstone is written, the queued job is cancelled, and nothing is recreated. Scenario C covers the jobs cancellation cannot reach. A worker that already took the job off the queue drops it at the tombstone check, and an erasure that lands between the check and the ticket write is caught by the second check, which deletes the ticket it just created.

The tombstone stores only an opaque key derived with a server secret, never the personal data it protects, and it needs its own retention rule. In production, replace the in-memory pieces with your queue's cancel call and a transactional store, and keep the replay test: take a failed handoff, erase the person, run the stale job, and confirm no ticket appears.

Full simulation script
import { createHmac } from "node:crypto";

const SECRET = "demo-secret";
const opaqueKey = (id) => createHmac("sha256", SECRET).update(id).digest("hex").slice(0, 12);

function makeWorld({ guarded }) {
  const helpdesk = new Map();          // ticketId -> payload
  const tombstones = new Set();        // opaque subject keys
  const queue = [];                    // pending handoff jobs
  let nextId = 1;

  const createTicket = (payload) => { const id = "T-" + nextId++; helpdesk.set(id, payload); return id; };

  async function runJob(job, midFlight) {
    const key = opaqueKey(job.subjectId);
    if (guarded && tombstones.has(key)) return "dropped (tombstone)";
    if (midFlight) await midFlight();
    const id = createTicket(job.payload);
    if (guarded && tombstones.has(key)) { helpdesk.delete(id); return "created then removed"; }
    return "created " + id;
  }

  async function erase(subjectId) {
    const key = opaqueKey(subjectId);
    if (guarded) {
      tombstones.add(key);
      for (let i = queue.length - 1; i >= 0; i--) if (opaqueKey(queue[i].subjectId) === key) queue.splice(i, 1);
    }
    for (const [id, p] of helpdesk) if (p.subjectId === subjectId) helpdesk.delete(id);
  }

  return { helpdesk, queue, runJob, erase, createTicket };
}

async function scenario(label, guarded) {
  const w = makeWorld({ guarded });
  const subject = "visitor-4821";
  const payload = { subjectId: subject, text: "Where is my order? token=ZX-" + subject };

  // 1. Handoff succeeds once, ticket exists.
  const first = await w.runJob({ subjectId: subject, payload });
  // 2. A second handoff for the same chat fails upstream and is queued for retry.
  w.queue.push({ subjectId: subject, payload });
  // 3. Erasure request arrives.
  await w.erase(subject);
  const afterErase = [...w.helpdesk.values()].filter(p => p.subjectId === subject).length;
  // 4. The retry worker drains whatever is left in the queue.
  const retryResults = [];
  while (w.queue.length) retryResults.push(await w.runJob(w.queue.shift()));
  const afterRetry = [...w.helpdesk.values()].filter(p => p.subjectId === subject).length;

  console.log(`\n${label}`);
  console.log("  first handoff:        ", first);
  console.log("  tickets after erase:  ", afterErase);
  console.log("  retry worker result:  ", retryResults.length ? retryResults.join(", ") : "queue empty");
  console.log("  tickets after retry:  ", afterRetry);
}


async function inFlight(label) {
  const w = makeWorld({ guarded: true });
  const subject = "visitor-4821";
  const payload = { subjectId: subject, text: "token=ZX-" + subject };
  const job = { subjectId: subject, payload };
  // Worker already took the job off the queue, so queue cancel cannot reach it.
  await w.erase(subject);
  const r1 = await w.runJob(job);
  const n1 = [...w.helpdesk.values()].length;
  // Erasure lands between the tombstone check and the ticket write.
  const w2 = makeWorld({ guarded: true });
  const r2 = await w2.runJob(job, () => w2.erase(subject));
  const n2 = [...w2.helpdesk.values()].length;
  console.log(`\n${label}`);
  console.log("  job already dequeued, erase first:  ", r1, "| tickets:", n1);
  console.log("  erase lands mid-flight:             ", r2, "| tickets:", n2);
}

await scenario("A. No tombstone, no queue cancel", false);
await scenario("B. Tombstone and queue cancel (job still queued)", true);
await inFlight("C. Tombstone guard when the job is already in flight");
Enter fullscreen mode Exit fullscreen mode

Verification and Backups

A passing check only counts if the read behind it can be trusted.

Replicas, caches and search indexes can lag behind a delete, so a read issued immediately afterwards may still return the record. Give the verification step the same settle-and-retry treatment as the delete itself, and mark a row as pending, not failed, until the window closes.

Backups need a plan rather than a check. For systems you operate, an isolated restore should reapply eligible deletions before data returns to normal use. For provider-held copies, ask how backups expire and what happens on restoration, then record the answer and the date in the ledger. Either way, the ledger shows what was checked and when.

Copy Less in the First Place

Every copy that never gets made is a row that never needs verifying.

Take a refund question. The refund record may hold the card's last digits, the billing address, an internal reviewer note and the agent's free-text comments, while the answer needs only a status and an expected timeframe. The backend can return exactly that.

{
  "refund_status": "approved",
  "expected_in_days": 5
}
Enter fullscreen mode Exit fullscreen mode

Filtering has to happen in the backend, before the agent platform receives the response. Selecting one value in a workflow step does not remove the original response from the integration. Those two fields can still be personal data once linked to a customer, so if the application can render them in a fixed reply, they never need to pass through the model at all.

Handoffs follow the same rule. A ticket summary such as "Refund disputed, customer asks for a person" with a link to a restricted conversation is a smaller copy than a full transcript pasted into every notification. Smaller copies are also easier to verify.

Test the Boundary Before Launch

Deletion is one boundary, and access to private records is the other.

For any action that reads a private record, run at least these three cases through the real signed-in page with synthetic accounts.

Request Expected behavior
A customer asks about their own refund Only the approved fields come back
A customer asks about someone else's refund Access is denied and nothing about the record leaks
The sign-in has expired or is missing The backend rejects the lookup even when the API key is valid

For erasure, create a synthetic person with a unique token in every message, push it through the normal path, file the request, and search every store for the token a day later. Anything that turns up is a store missing from the ledger, and it is the most useful result the test can give.

A route that fails its checks stays disabled while the rest of the service ships.

When a Lighter Version Is Enough

Not every bot needs the full machinery, and pretending otherwise wastes a small team's time.

A bot that answers from public pages, creates no tickets, runs no background jobs and reads no private records has a short ledger: the chat session, the provider's retention terms and any export. A written checklist and a quarterly review can cover that. The tombstone, queue cancellation and subject key start to pay for themselves once the bot hands conversations to a helpdesk, retries failed work, or touches account data.

Answering the Request on Time

The technical work still has to fit inside the legal clock.

Article 12 asks for a response without undue delay and normally within one month of receipt. Complexity or volume can justify up to two further months, but the extension has to be explained within the first month. Confirm identity in proportion to the doubt instead of collecting ID documents by default.

The reply should state what was erased, what is still pending with which processor, and what was kept under an exception and why. That written account is also the ledger from the first section, which is why it pays to keep it current.

Make the Ledger Run in CI

Chat is only the first of the stores a support bot will touch. Each new tool, whether a calendar, a CRM or a payment lookup, adds another place where a conversation can land and another job that can bring it back.

A workable habit is to make the ledger a release gate. A pull request that adds an integration also adds a row, an eraser and a verification, or it does not merge. The synthetic-person test runs on a schedule and fails loudly when a store appears that nobody listed.

What is the oddest place a support conversation has turned up in your stack? Share it in the comments.

For the notice, retention and handoff settings that sit around this ledger, the YourGPT guide to building a GDPR-compliant chatbot walks through the full setup.

Top comments (0)