Passing Attachment Bytes into Send Email and Knowledge Nodes
Learn how to take the base64 content produced by an Attachment node and feed it straight into a Send Email attachment or a Knowledge Embed document, including the per-attachment and per-run size limits to plan around.
Overview
In a Mailhook workflow, the Attachment node fetches the real bytes of a file that arrived on an inbound email. When it runs in Single mode it produces an object shaped like { filename, contentType, size, content }, where content is the file encoded as base64. That base64 string is the piece you wire downstream: it is exactly the format that both the Send Email node and the Knowledge node in Embed mode expect when you want to move a file from an email into the rest of your automation.
The mental model is simple: the Attachment node turns an attachment reference into usable bytes, and downstream nodes consume those bytes through a variable reference such as {{ attachment.content }}. Because everything flows as variables on the Spojit canvas, you never download or re-upload anything by hand. This guide shows the two most common destinations: forwarding a file by email, and embedding a document into a knowledge collection so Miraxa, the intelligent layer across your automation, can answer questions about it later.
Before You Start
- Your workflow must use a Mailhook trigger. The designer refuses to save an Attachment node unless a Mailhook trigger is present upstream.
- Add an Attachment node and give it an Output Variable (this guide assumes
attachment). Set Mode toSinglefor one file, orMultiplewhen an email can carry several files. - If you plan to embed into a persistent collection, create the collection first under the Knowledge section of the sidebar with New Collection.
Steps: Send the attachment back out by email
Use this when you want to forward, archive, or relay the original file to a person or system.
- On the canvas, add a Send Email node after your Attachment node and connect them so the attachment runs first.
- In the Send Email properties panel, fill in Recipients (comma-separated, templated), Subject, and Body. You can pull values from the inbound mail, for example
{{ input.subject }}and{{ input.from }}. - Add an attachment to the email and map its content to the bytes from the Attachment node. In
Singlemode reference{{ attachment.content }}for the base64 data,{{ attachment.filename }}for the file name, and{{ attachment.contentType }}for the type. - To reply to the original sender, set Recipients to
{{ input.replyTo }}, since Mailhook workflows are always asynchronous and do not respond to the sender automatically. - Decide on the If sending fails behavior (
Fail the workfloworContinue anyway) and save.
Steps: Embed the attachment into a Knowledge collection
Use this when you want the file to become searchable, for example to extract invoice data or answer questions from a document later in the same run.
- Add a Knowledge node after your Attachment node and set it to Embed mode.
- Pick a Collection. Choose a persistent collection to keep the document long-term, or choose Transient for a one-off "embed then query then discard" run where you do not need to keep the file.
- Set File Name (required unless the collection is transient). A handy choice is the original name:
{{ attachment.filename }}. If a document with that name already exists in the collection it is overwritten. - Set Document Type to match the file, for example
PDF,Excel,CSV/TSV, orWord. - In Document Input, point at the base64 bytes with
{{ attachment.content }}. This is the same reference the Send Email node uses, so one Attachment node can feed both destinations. - Optionally set an Output Variable to capture the chunk count and metadata, then save. To search the document right after, add a second Knowledge node in Query mode pointed at the same collection (or Transient if you embedded transiently).
Handling Multiple attachments
When the Attachment node runs in Multiple mode, its output is a list shaped like { attachments: [...], count, totalBytes } rather than a single object. To process each file, add a Loop node in ForEach mode over {{ attachment.attachments }}. Inside the loop body, each item exposes the same fields, so you reference {{ item.content }}, {{ item.filename }}, and {{ item.contentType }} in the downstream Send Email or Knowledge node. Use the Content type filter (for example application/pdf, image/*) or the Filename pattern glob (for example *.pdf or invoice-*.csv) on the Attachment node to keep the list to the files you actually want.
Size Limits to Plan Around
The Attachment node enforces two defaults: a per-attachment cap of 10 MB and a per-run cap of 25 MB across all attachments it fetches. Files larger than the per-attachment limit are not fetched, and a run that exceeds the total cap stops fetching once the budget is spent. You can also narrow what gets pulled with the Min size and Max size options. Inbound emails received by a Mailhook are retained for 30 days, so re-runs that need the bytes must happen within that window.
Tips
- Reuse one Attachment node for several destinations. The same
{{ attachment.content }}reference works in both Send Email and Knowledge, so you do not need to fetch the file twice. - Set the Attachment ID field when you know the exact attachment you want. It overrides the content type and filename filters and pulls that one file directly.
- Turn on Fail if no attachment matches when a file is mandatory, so the run stops loudly instead of passing empty content downstream.
- Ask Miraxa, the intelligent layer across your automation, to scaffold the wiring for you, for example: "Build a workflow that watches a mailhook, extracts the PDF invoice, and embeds it into a Knowledge collection." Then fine-tune the fields in the properties panel.
Common Pitfalls
- Forgetting the Mailhook trigger. The Attachment node only exists for Mailhook workflows and the designer will not save it otherwise.
- Wiring
Multiple-mode output straight into a single destination. InMultiplemode there is no top-levelcontent; you must Loop over{{ attachment.attachments }}and reference{{ item.content }}. - Mismatching the Document Type in a Knowledge Embed node with the actual file, which can produce poor or empty chunks. Match the type to the real file the email carried.
- Assuming a large file came through. If an attachment exceeds
10 MB, or the run passes the25 MBtotal, it is skipped. Check the Attachment node output before relying on it downstream. - Expecting external recipients to receive a Send Email message without allowlisting. External addresses must be on the org allowlist under Settings → General → Email recipients.
Related Articles
- Using Send Email Nodes
- Using Knowledge Nodes
- Using Loop Nodes
- Setting Up a Mailhook Trigger
- Working with Variables and Templates