Quick overview
This sub-workflow accepts plain-text invoice details, uses OpenAI to extract and normalize invoice fields, renders a styled HTML invoice to PDF via PDFCrowd, uploads the PDF to Google Drive, and returns a shareable Drive link while clearing working tabs in Google Sheets.
How it works
- Receives invoice details as input from a parent workflow.
- Uses OpenAI to parse the free text into a fixed set of invoice fields and calculations, with a structured output parser that retries and auto-fixes malformed JSON.
- Adds company metadata and today’s invoice date, and maps the extracted values into the fields used for the invoice.
- Builds a styled HTML invoice document from the structured fields.
- Sends the HTML to the PDFCrowd API to generate an A4 PDF.
- Uploads the generated PDF to a specified Google Drive folder and returns a view URL.
- Clears rows in the “Invoice Input” and “Invoice Output” tabs in Google Sheets to prepare for the next run.
Setup
- Add an OpenAI API credential for the chat model used to extract and structure invoice data.
- Add Google Drive and Google Sheets credentials, then set YOUR_DRIVE_FOLDER_ID and YOUR_GOOGLE_SHEET_ID to your target folder and spreadsheet.
- Create a PDFCrowd account and replace the Authorization header with your base64-encoded username:apiKey value.
- Update the invoice template placeholders in the HTML (company name, address, email, TRN, and payment details) and set YOUR_COMPANY_TAX_NUMBER in the invoice fields mapping.