Graphay, is an AI-powered financial process automation system designed to streamline and manage the entire lifecycle of an invoice, from initial receipt to final payment confirmation. Leveraging the LangGraph library, this system orchestrates a multi-step workflow, integrating various services and including human-in-the-loop checkpoints to ensure accuracy and compliance.
Graphay automates a complex accounts payable workflow by creating a stateful agent that intelligently manages the process for each invoice. The core of the system is a Python-based application using LangGraph to define and execute the workflow as a stateful graph. This approach allows for robust, concurrent processing of multiple invoices while handling asynchronous human-in-the-loop tasks efficiently.
- Automated Invoice Ingestion: Polling a dedicated email inbox for new invoices.
- AI-Powered Data Extraction: Using a Document Intelligence Service to parse and extract key data from invoices.
- Automated Validation & Follow-Up: Validating extracted data and automatically sending follow-up emails for missing information.
- Human-in-the-Loop Approvals: Staging invoices for approval and monitoring a Discord server for an approval decision from a designated team.
- Payment Verification: Monitoring for payment confirmation and verifying transactions via a public API (e.g., Etherscan).
- Centralized Tracking: Recording all invoice data, status, and decisions in a Google Sheets tracking system.
- Invoice Ingestion → Detects new invoice emails & downloads files.
- AI-Powered Extraction → Extracts vendor, date, amounts, line items, payment details.
- Validation → Checks for missing data, requests additional info if needed.
- Approval Staging → Logs invoice to Google Sheets & posts request in Discord.
- Human Approval → Approvers approve/reject & provide cost center.
- Decision Recording → Updates Google Sheets with decision.
- Payment Confirmation → Waits for transaction ID, verifies via Etherscan.
- Finalization → Records payment confirmation & marks invoice complete.
- Python
- Google Cloud project with:
- Discord bot with channel & thread access
- Etherscan API key
| Variable | How to Get |
|---|---|
| DISCORD_TOKEN | Discord Developer Portal → Applications → Select your bot → Bot → Reset Token → Copy |
| DISCORD_CHANNEL_ID | In Discord server, right-click on the channel → Copy Channel ID |
| APPROVING_TEAM_ROLE_ID | Discord server → Server Settings → Roles → Create Role → Set Permissions: View Channel, Manage Channel, Manage Role, Create Expressions, Create Invite, Manage Messages, Manage Threads & Posts, Read Message History |
| SPREADSHEET_ID | In Google Sheets URL, copy the value between d/ and /edit |
| GDRIVE_FOLDER_ID | In Google Drive folder URL, copy the value between /folder/ and the next slash |
# Clone the repository
git clone https://github.com/Sidharth1743/Graphay.git
cd graphay
# Install dependencies
pip install -r req.txt
# Copy environment variables
cp .env.example .envThe heart of this system is a stateful graph built with LangGraph. The graph's state is a dictionary that holds all relevant invoice data at each step (e.g., vendor name, status, approval decision, transaction ID). Each step in the workflow is a node in the graph, with edges defining the flow based on the current state.
This design enables:
- Asynchronous Checkpoints: Nodes like
await_approvalare designed to pause the graph's execution for a specific invoice until a condition is met (e.g., a Discord message is received). This non-blocking approach ensures the system can continue processing other invoices concurrently. - Error Handling & Retries: The graph can be configured with error-handling logic to manage failed tool calls or invalid data, routing the process to a specific node for resolution.
- Fork the repository
- Create a feature branch
- Commit changes
- Push to branch
- Open a Pull Request