Quick overview
This workflow monitors a Google Drive folder for new loan application PDFs, extracts text, and uses OpenAI (GPT-4o-mini) to structure applicant data, score risk, generate a lending summary, and produce an underwriting recommendation, then emails the final report via Gmail and posts Slack alerts on failures.
How it works
- Triggers when a new PDF is created in a specified Google Drive folder.
- Downloads the PDF from Google Drive and extracts its text content.
- Uses OpenAI (GPT-4o-mini) to extract key applicant and loan fields into a validated JSON structure.
- Uses OpenAI (GPT-4o-mini) to calculate a risk score, risk level, approval confidence, and key findings in JSON.
- Uses OpenAI (GPT-4o-mini) to write a plain-text lending summary and then generate a final underwriting decision (approve/conditional approval/further review/decline) with reasoning and conditions.
- Assembles a single report from the extracted data, risk analysis, summary, and decision, and sends it to the loan officer via Gmail.
- If extraction or risk scoring fails, sends a Slack alert and retries by re-downloading the application PDF.
Setup
- Connect Google Drive OAuth2 credentials and replace YOUR_GOOGLE_DRIVE_FOLDER_ID with the folder that receives loan application PDFs.
- Add an OpenAI API credential and ensure the GPT-4o-mini model is available in your OpenAI account.
- Connect Gmail OAuth2 credentials and set the recipient email address in the email step (replace [email protected]).
- Connect Slack OAuth2 credentials and set YOUR_SLACK_CHANNEL_ID (and the ops channel used by the global error handler) to the channel(s) where alerts should post.
- Test with a sample PDF to confirm text extraction works and the AI responses match the expected JSON schemas.