Quick overview
This workflow monitors a Google Forms response sheet to validate and look up Brazilian supplier CNPJs via BrasilAPI, assigns a risk score, and then approves, rejects, or requests buyer approval by Gmail while maintaining approved and rejected supplier logs in Google Sheets.
How it works
- Triggers when a new row is added to the Google Sheets spreadsheet linked to your Google Form.
- Normalizes the CNPJ from the form and validates its check digits, routing invalid entries to rejection logging.
- Loads the existing Suppliers list from Google Sheets and stops duplicates from being processed again.
- Looks up the CNPJ on BrasilAPI to fetch the Receita CNPJ record, and routes 404/not-found or API failures to a manual buyer review email.
- Scores supplier risk from the Receita data and form inputs (for example status, company age, CNAE, MEI/Simples flags, share capital, and mismatches in name/UF/email) and categorizes the request as approved, review, or rejected.
- For review cases, sends a Gmail approval email to the buyer and treats no response within 3 days as a decline.
- Writes approved suppliers to the Suppliers sheet (append or update) and emails the requester the outcome, while rejected/duplicate/invalid cases are appended to the Rejected sheet and the requester is notified when a final decision exists.
- Every Monday at 07:00, rechecks active suppliers against BrasilAPI, updates their status in Google Sheets (including blocking those no longer ATIVA), and emails the buyer a summary of status changes or check failures.
Setup
- Connect Google Sheets Trigger and Google Sheets with access to the Google Form response spreadsheet and the supplier tracking spreadsheet.
- Connect a Gmail account that can send approval emails to the buyer and notifications to the requester.
- Replace YOUR_FORM_RESPONSES_SHEET_ID in the trigger and YOUR_SHEET_ID in all Google Sheets nodes, and ensure the target tabs are named Suppliers and Rejected with the expected header columns.
- Update the field mappings in the form-to-data step to match your Google Form response column names (including Timestamp and the collected requester email column).
- Set buyerEmail and the scoring thresholds (accepted CNAE prefixes, minimum age and capital, review and reject scores) in the Config node, replace [email protected] in the "Alert: workflow failed" and "Weekly alert: status changed" Gmail nodes, and set the workflow timezone so the Monday recheck runs at the intended local time.