Skip to content

Every 15 minutes

Create PDF invoices from Airtable orders into Drive

When an order in Airtable is marked for invoicing, a PDF invoice is created, saved to Drive and linked on the record.

Runs
Every 15 minutes
Apps
Airtable, Google Drive
AI
Not needed
Access
Airtable read+write; Drive write

Send this to your assistant

Create a ClickRuntime automation: when an Airtable order is marked 'Invoice', create a PDF invoice with its line items, save it to my Drive 'Invoices' folder, and put the link on the order.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A small print studio takes orders by phone and email and tracks them in Airtable: customer, items, quantities and prices. When a job ships, someone copies the order into an invoice template, exports a PDF, saves it in the right folder and pastes the link back. It is ten minutes per order and easy to get a figure wrong.

Building the invoice straight from the Airtable record means the numbers on the PDF are exactly the numbers in the order, and the file is filed in Drive with a link the team can send to the customer.

What you get out of it

  • Invoices match the order

    Line items, quantities and totals are taken from the record, so there is no retyping.

  • Filed in one place

    Every invoice PDF is saved in your Invoices folder in Drive with a consistent name.

  • Link on the record

    The order gets the PDF link and moves to Invoiced, so the team can see what has been billed.

  • Each order invoiced once

    Only orders marked Invoice are picked up, and they move on once the PDF exists.

How it works

What happens, step by step

  1. Every 15 minutes, ClickRuntime looks in your Airtable Orders table for orders marked Invoice.

  2. It builds a PDF invoice from the customer details and line items on each order.

  3. The PDF is saved to your Invoices folder in Drive.

  4. The order gets the PDF link and moves to Invoiced, so it is not invoiced again.

Before it runs live

  • Connect Airtable
  • Connect Google Drive

What you get

RunsEvery 15 minutes
Create PDF invoices from Airtable orders into Drivetoday, 9:00Succeeded
Airtable · OrdersOrder 1043 · Acme Bakery · Invoiced · 384.00 Invoice 1043.pdf saved to Drive / Invoices

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Act only on the items that match your own rules, and skip the rest
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Airtable and Google Drive steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
generate_pdf_invoices_from_airtable_into_drive.pyexample
import io
from fpdf import FPDF
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseUpload
from clickruntime import on_trigger, credentials, http, report_fetched
BASE_ID, FOLDER_ID = "appXXXXXXXXXXXXXX", "1FolderIdOfInvoices"
@on_trigger
def run(event):
    api, headers = f"https://api.airtable.com/v0/{BASE_ID}/Orders", {"Authorization": f"Bearer {credentials.connection('airtable', 'work')}"}
    orders = http.get(api, headers=headers, params={"filterByFormula": "{Status}='Invoice'"}).json()["records"]
    report_fetched(len(orders))
    if not orders:
        return {"invoiced": 0}
    drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    for rec in orders:
        f, pdf, total = rec["fields"], FPDF(), 0.0
        pdf.add_page(); pdf.set_font("Helvetica", size=12)
        pdf.cell(0, 10, f"Invoice {f.get('Order number')} - {f.get('Customer')}", new_x="LMARGIN", new_y="NEXT")
        for line in (f.get("Line items") or "").splitlines():
            desc, qty, price = [p.strip() for p in line.split(",")]
            total += float(qty) * float(price)
            pdf.cell(0, 8, f"{desc}  x{qty}  @ {float(price):.2f}", new_x="LMARGIN", new_y="NEXT")
        pdf.cell(0, 10, f"Total: {total:.2f}")
        file = drive.files().create(body={"name": f"Invoice {f.get('Order number')}.pdf", "parents": [FOLDER_ID]},
                                    media_body=MediaIoBaseUpload(io.BytesIO(bytes(pdf.output())), mimetype="application/pdf"),
                                    fields="webViewLink").execute()
        http.patch(api, headers=headers, json={"records": [{"id": rec["id"], "fields": {
            "Status": "Invoiced", "Invoice PDF": file["webViewLink"], "Total": total}}]}).raise_for_status()
    return {"invoiced": len(orders)}

FAQ

Common questions

What do the line items need to look like?
One line per item in a long text field, written as description, quantity and unit price separated by commas. The script adds up the total from those lines.
Can the invoice show my logo and bank details?
Yes. Your business name, address and payment details can be added to the header and footer in the script. A logo can be added as an image file.
Does it email the invoice to the customer?
Not by default. It saves the PDF and puts the link on the order. Sending it can be added as an extra step.
What permissions does it need?
Airtable read+write; Drive write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it checks. Checks that find nothing new and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Create PDF invoices from Airtable orders into Drive” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.