docs/docs/en/ai-employees/workflow/nodes/knowledge/delete-document.md
<PluginInfo name="ai-knowledge-base"></PluginInfo>
In NocoBase, the Delete document node deletes a specified document from an AI knowledge base. In this example, it listens for deletion events in Answers and deletes the corresponding document from the target knowledge base by the same Key used by Create document, so removed data is no longer retrieved.
The Delete document node is asynchronous. It depends on the Key written when the document was created, so it must use the same target knowledge base and the same Key rule as the Create and Update document nodes.
The example workflow listens for deletion events in Answers and deletes the document with the same Key from the target knowledge base.
Where:
Collection event listens for collection deletionDelete document deletes the document from the target knowledge baseThe example uses the target knowledge base and Key rule from Create document. Before configuring the workflow, confirm that:
KeyKey from trigger data. The example uses the Answers record IDSelect Collection event as the trigger. In the trigger configuration:
Collection to the collection to listen to, such as Main / AnswersTrigger on to After record deletedDeleting a document only needs the document Key, so relation fields usually do not need to be preloaded.
Add a Delete document node after the trigger.
Key settings:
The Delete document node only needs to locate the document to delete. It does not need body content, title, or related questions.
| Setting | Example value | Description |
|---|---|---|
Knowledge base | Target knowledge base | Select the same knowledge base used by the Create and Update document nodes. |
Key | Answers.ID | Select the exact same field used by the Create document node. The example continues to use the Answers record ID so the node deletes the document that corresponds to this answer. |
:::warning Note
The delete node does not look up documents by title or body content. It only locates documents by Knowledge base and Key. The Create, Update, and Delete workflows must use the same Key.
:::
After configuring the Delete document node, return to the "Verify the synchronization chain" section in Overview to verify add, update, and delete in order.