Documentation Index Fetch the complete documentation index at: https://docs.langdock.com/llms.txt
Use this file to discover all available pages before exploring further.
Invoice Processing & Approval
Automatically extract invoice data, verify vendors, and route for approval based on amount thresholds.
How It Works
Trigger : Integration trigger (new email with attachment) or Form submission
Workflow:
Agent : Extract invoice data from attachment
Vendor name and details
Invoice number and date
Line items and amounts
Payment terms
HTTP Request : Verify vendor exists in approved vendor list
Code : Calculate totals and validate
Condition : Check if approval needed based on amount
Under $5,000 → Auto-approve
Over $5,000 → Require approval (Human in the Loop)
Action : Create payment record in accounting system
Action : Update invoice status in finance system
Configuration Example
Agent Node (Extract Invoice Data):
Model: GPT-4
Instructions: Extract all invoice information from this document:
Document: {{trigger.output.attachment}}
Return structured data with:
- Vendor name, address, contact
- Invoice number and date
- Line items (description, quantity, unit price)
- Subtotal, tax, total amount
- Payment terms and due date
Structured Output:
{
"vendor_name": "string",
"invoice_number": "string",
"invoice_date": "string",
"line_items": [{"description": "string", "amount": "number"}],
"subtotal": "number",
"tax": "number",
"total": "number",
"due_date": "string",
"payment_terms": "string"
}
HTTP Request Node (Verify Vendor):
Method: GET
URL: https://api.yourcompany.com/vendors/search
Query Parameters:
- name: {{agent.output.structured.vendor_name}}
Headers:
- Authorization: Bearer YOUR_TOKEN
Code Node (Validate):
// Check if vendor exists
const vendorExists = http_request . output . vendors && http_request . output . vendors . length > 0 ;
if ( ! vendorExists ) {
throw new Error ( `Vendor ${ agent . output . structured . vendor_name } not found in approved list` );
}
// Validate amounts match
const calculatedTotal = agent . output . structured . subtotal + agent . output . structured . tax ;
if ( Math . abs ( calculatedTotal - agent . output . structured . total ) > 0.01 ) {
throw new Error ( "Invoice totals don't match" );
}
return {
vendor_verified: true ,
vendor_id: http_request . output . vendors [ 0 ]. id ,
total_amount: agent . output . structured . total ,
needs_approval: agent . output . structured . total >= 5000
};
Condition Node:
If Needs Approval: {{ code.needs_approval === true }}
Else Auto-Approve: {{ code.needs_approval === false }}
Action Node (Requires Approval if over $5K):
Integration: Your Accounting System
Action: Create Payment
Settings:
✅ Require Approval (enabled for high-value path)
Approvers: Finance Manager
Message: "Approve payment of ${{agent.output.structured.total}} to {{agent.output.structured.vendor_name}}"
Fields:
- Vendor ID: {{code.vendor_id}}
- Amount: {{agent.output.structured.total}}
- Invoice Number: {{agent.output.structured.invoice_number}}
- Due Date: {{agent.output.structured.due_date}}
Benefits
90% reduction in manual data entry
All invoices processed within 24 hours
Automatic vendor verification
Approval workflow for high-value payments
Complete audit trail
Expense Report Validation
Automatically review and validate expense reports against company policies before approval.
How It Works
Trigger : Integration trigger (new expense report submitted)
Workflow:
Loop : For each expense item in report
Agent : Validate receipt and categorize expense
Code : Check against policy limits
Condition : Flag policy violations
Code : Aggregate results and calculate totals
Agent : Review overall report for anomalies
Condition : Auto-approve or send for manual review
No violations + under limit → Auto-approve
Has violations → Require manual review
Action : Update expense system with decision
Send Notification : Notify employee of status
Configuration Example
Loop Node:
Input Array: {{trigger.output.expense_items}}
Loop Variable: expense
Max Iterations: 50
Agent Node (Inside Loop - Validate Each Item):
Model: GPT-3.5 Turbo
Instructions: Validate this expense item:
**Expense:**
- Description: {{expense.description}}
- Amount: ${{expense.amount}}
- Category: {{expense.category}}
- Date: {{expense.date}}
- Receipt: {{expense.receipt_url}}
Check for:
1. Does receipt match the description?
2. Is the amount reasonable for this category?
3. Is there any suspicious activity?
4. What is the appropriate expense category?
Structured Output:
{
"receipt_valid": "boolean",
"amount_reasonable": "boolean",
"suggested_category": "string",
"policy_compliant": "boolean",
"notes": "string"
}
Code Node (Inside Loop - Check Policy Limits):
// Policy limits by category
const policyLimits = {
'meals' : 75 ,
'transportation' : 200 ,
'accommodation' : 300 ,
'office_supplies' : 150 ,
'other' : 100
};
const category = agent . output . structured . suggested_category || expense . category ;
const limit = policyLimits [ category ] || 100 ;
const overLimit = expense . amount > limit ;
return {
category: category ,
limit: limit ,
amount: expense . amount ,
over_limit: overLimit ,
violation: overLimit || ! agent . output . structured . policy_compliant ,
violation_reason: overLimit
? `Amount $ ${ expense . amount } exceeds limit $ ${ limit } `
: agent . output . structured . notes
};
Code Node (After Loop - Aggregate Results):
// Aggregate all expense validations
const expenses = loop . items || [];
const violations = expenses . filter ( e => e . violation );
const totalAmount = expenses . reduce (( sum , e ) => sum + e . amount , 0 );
return {
total_expenses: expenses . length ,
total_amount: totalAmount . toFixed ( 2 ),
violations_count: violations . length ,
has_violations: violations . length > 0 ,
violation_details: violations ,
auto_approvable: violations . length === 0 && totalAmount < 1000
};
Agent Node (Final Review):
Model: GPT-4
Instructions: Review this expense report for any anomalies:
**Report Summary:**
- Total Items: {{code.total_expenses}}
- Total Amount: ${{code.total_amount}}
- Policy Violations: {{code.violations_count}}
**Violation Details:**
{{code.violation_details}}
Look for:
- Unusual patterns (multiple similar expenses)
- Suspicious timing or amounts
- Missing justifications
Structured Output:
{
"anomalies_found": "boolean",
"review_notes": "string",
"recommendation": "approve|review|reject"
}
Condition Node:
If Auto-Approve: {{ code.auto_approvable === true && agent.output.structured.anomalies_found === false }}
Else Needs Review: {{ true }}
Send Notification (Employee):
**Expense Report Status**
Your expense report has been {{ code.has_violations ? 'flagged for review' : 'approved' }} .
**Summary:**
- Total: $ {{ code.total_amount }}
- Items: {{ code.total_expenses }}
- Status: {{ code.has_violations ? 'Under Review' : 'Approved' }}
{{ #if code.has_violations }}
**Issues Found:**
{{ code.violation_details }}
A manager will review your report within 24 hours.
{{ else }}
Your reimbursement will be processed within 3-5 business days.
{{ /if }}
Benefits
80% of expense reports auto-approved
Policy compliance automatically enforced
Faster reimbursements for employees
Reduced finance team workload by 70%
Complete audit trail for all decisions
Next Steps
Marketing Workflows Content and campaign automation
Popular Workflows Most common workflow automations
Human in the Loop Add approval steps for sensitive actions
Loop Node Process multiple items efficiently