Quick overview
This workflow ingests freelance order terms from Gmail or an n8n form, uses Google Gemini to extract required contract items, checks them against Japan’s Freelance Act rules, logs results to Google Sheets, and alerts issues via Slack while creating a corrected notice draft in Gmail.
How it works
- Triggers when an email with the Gmail label
freelance-orders arrives or when someone submits order terms through an n8n form.
- Normalizes the input into a common structure, cleans the order text, skips short/empty items, and deduplicates orders so each orderId is processed once.
- Sends the order text to Google Gemini (Gemini 2.5 Flash) and parses the response into structured JSON fields (client, freelancer, scope, fees, delivery, inspection, payment, and issue dates).
- If Gemini extraction fails, logs the error to a Google Sheets “Errors” tab and posts a Slack alert for manual review.
- Validates the extracted terms against Article 3 required written items and the Article 4 payment deadline rule (default 60 days from delivery), and classifies the result as compliant, needs fixes, or not an order.
- Appends the audit record to Google Sheets and, for orders that need fixes, posts the violations and suggested changes to Slack and creates a Gmail draft of a corrected order notice for review.
Setup
- Add credentials for Gmail, Google Sheets, Slack, and Google Gemini (Google AI) used by the workflow.
- Update the values in “Set configuration” (Google Sheet ID, Slack channel, reviewer email, sender signature, and any rule parameters like
maxPaymentDays and minOrderTextLength).
- Create a Gmail label named
freelance-orders and apply it to the order emails you want audited (or change the trigger query to match your process).
- Create a Google Sheets file with tabs named “Audit log” and “Errors” and ensure the column headers match the fields the workflow appends.
- If you use the form trigger, share the n8n form URL internally so staff can paste order terms for checking.