Quick overview
This workflow monitors a Google Sheets jobs tracker and, based on each row’s stage, generates quote, invoice, or receipt PDFs via Koutei and emails them with Gmail, while also sending overdue invoice reminders and writing any validation or delivery issues back to the sheet.
How it works
- Runs on a manual trigger, every 30 minutes, and every morning at 9:00 to handle reminders.
- Reads all rows from a specified Google Sheets tab and evaluates each row’s stage and required fields to decide what action is needed.
- For rows requesting a document, marks the row as “Sending…” to prevent duplicate sends, then prepares the appropriate payload for Koutei (quote, deposit invoice, balance invoice, or receipt).
- Validates the document data with Koutei and, if valid, requests the final PDF from Koutei using an idempotency key to avoid duplicate document creation on retries.
- Emails the generated PDF via Gmail (to the owner in preview mode, or the client in final mode) and updates the Google Sheets row with the new stage, totals, due date, email ID, and other tracking fields.
- On the daily reminder run, finds overdue deposit or balance invoices, re-downloads the original sent invoice email attachment from Gmail, and emails a reminder with the same PDF while updating the row’s reminder tracking fields.
- When validation, PDF generation, emailing, or sheet updates fail, writes an actionable status note back to the relevant sheet row and emails the owner with any new non-waiting issues.
Setup
- Create or copy a Google Sheets job sheet with the required columns (including job_id, stage, status, due_date, email_id, reminded_on, made_in, and doc_date) and set the sheet URL and tab name in the workflow settings.
- Add Google Sheets OAuth2 credentials and Gmail OAuth2 credentials for the account that reads/updates the sheet and sends emails.
- Create a Koutei account and API key, then configure an HTTP Header Auth credential with
Authorization: Bearer <your_key> and confirm the Koutei base URL in settings.
- Fill in workflow settings such as owner email, seller/business details, currency, deposit percent, payment terms, and reminder controls (on/off and interval).
- Start in
mode = preview to send watermarked PDFs to the owner, then switch to mode = final before activating the workflow schedules for live client delivery.