One-Off Document Extraction with Transient Collections
Use a Transient collection to embed a single document, query it, and discard everything automatically within one workflow run, with no persistent collection and no file name to manage.
Overview
A Transient collection is a throwaway knowledge store that Spojit creates for the duration of one run and cleans up the moment the run finishes. It exists so you can run the classic retrieval pattern - embed a document, ask questions against it, then throw it away - without polluting your workspace with one-off collections you never look at again. The most common use is pulling a handful of fields out of a single inbound document, for example reading the supplier, totals, and line items from one invoice that just arrived by email.
Mentally, think of a Transient collection as a scratchpad shared by every Knowledge node in the same run. You set one Knowledge node to Embed mode and point its Collection at Transient, then a later Knowledge node in Query mode also points at Transient and reads back what the first node embedded. Because the collection never persists, there is no file name to set, no embedding model to pick, and nothing to delete afterwards. When you want a long-lived, multi-workflow archive instead, you use a persistent collection; Transient is purely for single-run extraction.
Before You Start
- A workflow with a trigger that delivers the document you want to read. A Mailhook or Email trigger works well when the document arrives by email, but any trigger that produces the document bytes is fine.
- The document content available as a base64 reference in a variable. From a Mailhook workflow this comes from an Attachment node as
{{ attachment.content }}; from an FTP download it is something like{{ sftp_result.data.content }}. - You do not need to create a collection in the Knowledge sidebar section first. Transient collections are created automatically per run.
Steps
Step 1: Get the document into a variable
Make sure the document bytes are reachable as a base64 reference earlier in the run. In a Mailhook workflow, add an Attachment node in Single mode with a Filename pattern such as *.pdf so the first matching file is returned as {{ attachment.content }}. If the document comes from a file transfer, the download tool on your FTP connector exposes the bytes in its output variable instead. Whatever the source, note the exact variable path - you will paste it into the embed node next.
Step 2: Add a Knowledge node in Embed mode
Drop a Knowledge node onto the canvas and set its mode to Embed. Configure it as follows:
- Collection: open the dropdown and choose
Transient. Selecting Transient hides the File Name and Embedding Model fields, because a per-run collection does not need them. - Document Type: pick the format that matches your file, for example
PDFfor an invoice PDF, orImages via OCRfor a scanned image. - Document Input: paste the base64 reference from Step 1, for example
{{ attachment.content }}. - Output Variable: name it something like
embedResult. It reports the chunk count and metadata so you can confirm the document was processed.
When this node runs, Spojit splits the document into chunks and embeds them into the run's Transient collection.
Step 3: Add a Knowledge node in Query mode
Connect a second Knowledge node after the embed node and set its mode to Query. Point its Collection at Transient as well - this is what links it to the document the previous node just embedded in the same run. Then configure:
- Prompt: write a natural-language request describing exactly the fields you want, for example
Extract the supplier name, invoice number, invoice date, currency, subtotal, tax, and grand total from this invoice. - Model: choose the AI model that synthesizes the answer.
- Result Count: leave the default of
5for a single small document; raise it only if the document is long and your fields are spread across many chunks. - Output Variable: name it
extractedso later steps can read{{ extracted }}.
Step 4: Force structured output with a Response Schema
For extraction you almost always want predictable JSON rather than prose. In the Query node, fill in the Response Schema field with a JSON schema that names each field you expect. For example, define properties for supplier, invoiceNumber, invoiceDate, currency, subtotal, tax, and total. The query then returns an object that matches your schema, so downstream nodes can reference fields directly, such as {{ extracted.total }}, instead of parsing free text. This is the difference between a one-off lookup and a reliable extraction you can act on.
Step 5: Use the extracted data, then let it discard
Add whatever node comes next to act on the result. You might add a Condition node that checks {{ extracted.total }} against a threshold, a Send Email node that emails the summary back to {{ input.replyTo }} on a Mailhook run, or a Connector node in Direct mode that writes the values into your accounting or ERP system. You do not add any cleanup step. When the run completes, Spojit automatically deletes the Transient collection and its embedded chunks, so nothing is left behind for the next run.
Tips
- Any number of Knowledge nodes in the same run can read and write the one Transient collection, so you can embed several documents and ask several questions before the run ends. They all share the same scratchpad.
- Be specific in the Prompt: name each field you want by the words that appear on the document. Vague prompts return vague answers, even with a Response Schema attached.
- If the document is a scanned image rather than a digital PDF, set Document Type to
Images via OCRso the text is read before embedding. - Ask Miraxa, the intelligent layer across your automation, to scaffold the pattern for you with a prompt like "Add a Knowledge node in Embed mode using a Transient collection that embeds
{{ attachment.content }}, then a Knowledge node in Query mode that extracts the invoice total." Then fine-tune the fields in the properties panel.
Common Pitfalls
- Forgetting to set the Query node's Collection to
Transientas well. If the embed node writes to Transient but the query node points at a persistent collection (or the reverse), the query finds nothing from this run. - Expecting the data to survive after the run. A Transient collection is wiped on completion by design, so you cannot query it from a later run or a different workflow. If you need a lasting, multi-workflow archive, embed into a persistent collection instead.
- Leaving Response Schema empty and then trying to reference exact fields downstream. Without a schema the query returns prose, and
{{ extracted.total }}will not resolve. Define the schema when you need structured fields. - Pointing Document Input at an attachment reference instead of its content. On a Mailhook run, an attachment reference is only an id, filename, and content type; you must fetch the bytes with an Attachment node first and feed
{{ attachment.content }}.
Related Articles
- Using Knowledge Nodes
- Querying Your Knowledge Base
- Introduction to the Knowledge Base
- Managing Collections and Storage
- How to Extract and Store Invoice Data in a Knowledge Collection