Skip to content

Work with files ​

Flows can read files, such as a price list someone uploads every month, and create them, such as a CSV report or a PDF quote. This guide walks through three common jobs: importing a CSV, emailing a generated report, and making a PDF from a template.

Where files live ​

A run handles files in two places. Knowing which is which explains most of the settings:

PlaceKeeps a fileSteps refer to a file by
Storage (the Files tab in the sidebar)Until someone deletes itIts File ID
The run's working areaOnly until the run endsIts file name

File Storage › Download File copies a file from Storage into the working area, and Upload File copies one the other way. Steps that read or write file contents, such as Extract from File and Convert to File, work in the working area. See Storage for the full picture.

Some fields take a file directly, such as Attachments in Mail › Send Mail. They offer two choices:

  • Reference: a file from an earlier step in this run. Type $, choose the step, then the field that holds the file.
  • Attach new: a file you upload now, which every run then uses.

Import a CSV into Tables ​

Someone uploads a CSV to Storage, and the flow adds each row to a table.

  1. Upload the CSV in Storage › Files, and copy its File ID.

  2. In the flow, click Add Step, open Built-in, choose File Storage, then Download File. Paste the ID into File Storage ID.

  3. Add Built-in › Extract from File › Parse CSV to JSON. Set File Name to the Download step's fileName. Leave Has Header on if the first row holds column names.

  4. The rows are in the step's data, one object per row, keyed by column name:

    json
    [
      { "sku": "P-100", "name": "Green tea", "price": "1200" },
      { "sku": "P-101", "name": "Hojicha", "price": "980" }
    ]
  5. Add a Loop with Value set to that data reference, and inside it a Tables › Create Record step that maps Loop.currentItem.sku and the other columns to fields.

All CSV values arrive as text. For a number field, convert it with an expression such as $number($.<Loop step>.output.currentItem.price).

Importing a new file each time

To pick up whichever file was uploaded most recently, use File Storage › List Files before Download File and take the newest file's ID, instead of pasting a fixed one.

Email a CSV report ​

A scheduled flow lists records, writes them to a CSV and emails it.

  1. Get the data, for example with Tables › List Records.

  2. Save as CSV needs the CSV as text, one line per row. Build it in a Code step with the records as an input parameter called rows:

    js
    const header = "Name,Email,Plan";
    const lines = rows.map((r) => [r.name, r.email, r.plan].map((v) => `"${String(v ?? "").replace(/"/g, '""')}"`).join(","));
    return [header, ...lines].join("\n");
  3. Add Built-in › Convert to File › Save as CSV. Set Content to the Code step's results, and File Name to something like customers.csv.

  4. Add Built-in › Mail › Send Mail. Under Attachments, add an item, choose Reference, and pick the Save as CSV step's file.

To keep a copy as well, add File Storage › Upload File with EFS File Name set to the same file name. Its output has the new file's fileId.

Attachments can be at most 3 MB each, with up to 10 per email. For bigger reports, upload the file to Storage and send a link or a File ID instead.

Make a PDF from a template ​

PDF › Generate PDF turns HTML into a PDF and saves it to Storage.

  1. Add Built-in › PDF › Generate PDF.

  2. Template Source: Inline HTML to write the HTML in the step, or a file to use an HTML template uploaded to Storage.

  3. Write the template. Put placeholders like {{ .customer }} where values go:

    html
    <h1>Quote for {{ .customer }}</h1>
    <p>Total: {{ .total }} yen</p>
    <p>Valid until {{ .validUntil }}</p>
  4. Context: an object whose keys match the placeholders, with values from earlier steps, such as customer set to Current Trigger.company.

  5. Output File Name: the name of the PDF, such as quote.pdf.

The step's output has the PDF's fileId in Storage, so you can find it later or send it on. To email it, pick the PDF step's file in the Mail step's Attachments with Reference.

Placeholders use Go template syntax, so {{ range .items }}…{{ end }} repeats a block for each item in a list.

Generate PDF settings: Template Source Inline HTML, a Template HTML with placeholders customer, total and validUntil, Context rows mapping each placeholder to a Current Trigger value, and Output File Name quote.pdf

Other things you can do with files ​

JobSteps
Read the text of a document so an LLM can summarise itExtract from File › Extract File to Text, then an LLM step
Save an API response that is a file, such as an imageHTTP with Response Format set to File, then File Storage › Upload File
Save JSON for another flow to read laterFile Storage › Upload File with Binary File Mode off and the JSON in File Content
Clean up old generated filesFile Storage › List Files, a Loop, and Delete File