LogoLogo
Visit Contextual.ioSign Up
  • Getting Started
    • Welcome
    • Tour: Hello, AI World!
  • TRAINING
    • Basic Developer Training Course
      • Lesson 1: HTTP Agent Introduction
      • Lesson 2: Logging and Error Handling Basics
      • Lesson 3: Event Processing Agent Introduction
  • Services Catalog
    • What's in the Catalog?
      • Intro Patterns
      • Object Type Bundles
    • Browse by Platform
    • All Intro Patterns
      • Anthropic Claude Image Analysis
      • Mistral AI Prompt and Response
      • xAI Grok Prompt and Response
      • DeepSeek Chat Prompt and Response
      • Qwen Chat Prompt and Response
      • Perplexity AI Search and Response
      • Firecrawl Website Scraper
      • Groq Prompt and Response
      • Nyckel Dog Breed Classification
      • RapidAPI ClassifyAI Text Classification
      • RapidAPI YouTube AI Video Summary
      • UnifyAI Model Comparison
      • WebPilot URL Analysis and Summarization
      • OpenAI Assistants Prompt and Response
      • OpenAI Sync
    • All Prebuilt Solutions
      • Invoice AI
      • Lead Generation Form
    • All Object Type Bundles
      • Work Order Management System ITIL Object Type Bundle
        • Work Order
        • User
        • Role
        • Permission
        • Asset
        • Task
        • Action
        • Attachment
        • Comment
        • Notification
        • Audit Log
        • Service Level Agreement
        • Custom Fields
        • Work Order Template
        • Work Order Transition
        • Escalation Policy
        • Tag
  • Components & Data
    • Object Types
      • Data in Contextual
        • Secrets
        • Validation
        • Versioning
      • Examples
      • Creating an Object Type
      • Object Type Details
        • Definition
        • Data Schema
          • Automatic Record Metadata
          • Generated Values
            • Dates and Times
            • UUIDs
          • Frequently Used Validation
          • Disallowing Null Property Values
          • Disallowing Undefined Properties
          • Secrets
          • AI Assistant
          • ID and PrimaryKey Permanence
        • UI Schemas
        • Features
        • Triggers
        • Actions
        • Audit Trail
        • Versions
        • Templates
        • Records
      • Using Object Types in Flows
      • Records
        • Records and Your Tenant API
        • Record Import
    • Flows
      • Nodes
      • Wires
      • Message Object
      • Flow Editor
        • Basics
        • Saving Changes
        • In-Flow Testing with Debugger
        • Restart Agents to Make Changes Active
        • Config
      • Node Reference
        • Common
          • Log Tap
          • Inject
          • Debug
          • Complete
          • Catch
          • Status
          • Link In
          • Link Call
          • Link Out
          • Comment
        • Event
          • Prepare Event
          • Event Start
          • Event End
          • Event Error
        • Object
          • Search Object
          • Get Object
          • Create Object
          • Patch Object
          • Put Object
          • Delete Object
          • Run Action
        • Request
          • Send to Agent
          • HTTP GET
          • HTTP PATCH
          • HTTP PUT
          • HTTP DELETE
          • HTTP POST
          • GQL
          • Produce Message
        • Function
          • Function
          • Switch
          • Change
          • Range
          • Template
          • Delay
          • Trigger
          • Exec
          • Filter
          • Loop
        • Models
          • ML Predict
        • Network
          • MQTT In
          • MQTT Out
          • HTTP In
          • HTTP Response
          • HTTP Request
          • WebSocket In
          • WebSocket Out
          • TCP In
          • TCP Out
          • TCP Request
          • UDP In
          • UDP Out
        • Sequence
          • Split
          • Join
          • Sort
          • Batch
        • Parser
          • csv
          • html
          • json
          • xml
          • yaml
    • Agents
      • Creating an Agent
      • Types of Agents
        • Event to Flow
        • HTTP to Flow
          • Custom Domains
      • How Agents Work
        • Flow Execution
        • HTTP Load Balancing
        • Event Routing
      • Scale and Performance
        • Flow execution
        • Parallel Instances
        • Event Lag Scaling
        • Compute Threshold Scaling
        • Instance Compute Sizing
      • Agent Details
        • Definition
        • Operations
        • Logs
          • Session Log
          • Message Log
        • Audit Trail
        • Versions
      • Using Agents in Flows
    • Connections
      • Creating a Connection
      • Types of Connections
        • Basic
        • Bearer
        • Client Grant
        • Kafka
        • Password Grant
        • Public
        • Pulsar
      • Using Connections in Flows
    • JWKS Profiles
      • Using JWKS Profiles in Your Solution
  • PATTERNS
    • Solution Architecture
      • Events, Messages, Queues
    • Working with Data
      • Search Object Node & Pagination
      • Message Payload Content - Triggers and Actions
    • Industry Cookbooks
      • Field Services
  • Tenants
    • Tenant Workspace
    • Tenant Logs
      • Contextual Log Query Language (CLQL)
        • String Searches
        • Keyword Searches
        • Advanced Operators
    • Tenant API
      • API Keys
        • API Key Settings
        • API Key Permissions
      • Documentation
  • Release Notes
    • 2024
      • 2024.12.09
Powered by GitBook
On this page
  • What's Included
  • What You'll Need
  • Ideas for Using Invoice AI
  • Flow Overview
  • Flow Details
  • Summary of Flow

Was this helpful?

  1. Services Catalog
  2. All Prebuilt Solutions

Invoice AI

The Invoice AI Solution leverages advanced AI capabilities for parsing and analyzing invoice documents. It automates the extraction of key fields from uploaded invoices (images or PDFs) and performs anomaly detection using AI models. This solution streamlines invoice workflows, improves data accuracy, and flags irregularities for review.

This flow is useful for automatically analyzing invoice inputs, storing structured results, and identifying anomalies for further processing.

This template can be found in the Services Catalog under the following categories:

  • AI, Enrichment, Workflow Management


What's Included

  • 2 Flows

    • Invoice AI Web

    • Invoice AI Anomaly Detection

  • 2 Agents

    • HTTP Agent

    • Event Agent

  • 1 Object Type

    • Invoice AI Data

  • 1 Connection

    • Anthropic Claude API


What You'll Need

  • An API key for the Anthropic Claude API


Ideas for Using Invoice AI

Automated Invoice Processing

Use AI to extract structured invoice data (e.g., Vendor Name, Address, Service Date) and eliminate manual data entry tasks.

Financial Anomaly Detection

Leverage historical patterns to identify irregularities in invoice terms, amounts, or services, helping detect fraud or errors.

Vendor Payment Validation

Automatically validate vendor details against historical records to ensure consistency and prevent discrepancies.

Improved Financial Audits

Simplify audits by maintaining structured invoice records with flagged anomalies for rapid review and resolution.


Flow Overview

Invoice AI Web Flow

  • Flow Start: The flow begins when a user uploads an invoice file (image or PDF) through the web interface.

  • Convert File to Base64: Converts the uploaded file into a Base64 format for API compatibility.

  • Send to Claude API: Sends the file data and structured prompt to the Anthropic Claude API for parsing.

  • Extract and Store Data: Processes the API response, extracts key invoice fields, and stores them as structured records in the system.

  • Trigger Anomaly Detection: Sends the invoice record to the Invoice AI Anomaly Detection flow for anomaly analysis.

  • Error Handling: Captures and logs any errors during file upload, API calls, or record creation.

Invoice AI Anomaly Detection Flow

  • Flow Start: Triggered when a new invoice record is created.

  • Retrieve Historical Records: Searches for historical invoices from the same vendor for comparison.

  • Send to Claude API: Prepares the anomaly detection prompt and sends it to the Anthropic Claude API.

  • Parse API Response: Processes the API's anomaly response to identify and summarize anomalies.

  • Update Invoice Record: Patches the original invoice record with anomaly details and status.

  • Error Handling: Logs any errors encountered during anomaly detection or record updates.


Flow Details

Invoice AI Web Flow

  1. HTTP Input Node

    • Node: Web

    • Purpose: Receives uploaded invoice files (image/PDF) from the web interface.

  2. Convert File to Base64

    • Node: Convert to Base64

    • Purpose: Converts the uploaded file buffer to a Base64 string for API submission.

  3. Prepare Claude API Payload

    • Node: Prepare PDF/IMG for Claude

    • Purpose: Formats the data for the Anthropic Claude API. Example Code:

    msg.claudePrompt = {
        model: "claude-3-5-sonnet-20240620",
        messages: [
            {
                role: "user",
                content: [
                    {
                        type: "document",
                        source: { type: "base64", data: msg.payload.toString('base64') }
                    },
                    { type: "text", text: "Extract: Vendor Name, Address, Date, Amount, and Payment Terms." }
                ]
            }
        ]
    };
    return msg;
  4. Send to Claude API

    • Node: Send to Claude

    • Purpose: Submits the formatted payload to the Claude API and receives structured invoice data.

  5. Parse API Response

    • Node: Parse Response

    • Purpose: Extracts invoice fields (e.g., Vendor Name, Amount) from the Claude API response. Example Code:

    msg.payload = {
        vendorName: extractValue(text, 'Vendor Name'),
        invoiceAmount: '$' + extractValue(text, 'Invoice Amount').replace('$', ''),
        paymentTerms: extractValue(text, 'Payment Terms')
    };
    return msg;
  6. Create Invoice AI Record

    • Node: Create Invoice AI Record

    • Purpose: Saves the extracted data to the Invoice AI Data object type.

  7. Trigger Anomaly Detection

    • Node: Send for Anomaly Detection

    • Purpose: Sends the new record to the anomaly detection flow for analysis.

  8. Error Handling

    • Nodes: Catch, Error Log

    • Purpose: Captures and logs any errors during upload, API interaction, or record creation.


Invoice AI Anomaly Detection Flow

  1. Retrieve Historical Records

    • Node: Search Historical Invoices

    • Purpose: Fetches historical records for the vendor to identify patterns.

  2. Prepare Anomaly Detection Request

    • Node: Prepare for Anomaly Detection

    • Purpose: Structures a prompt comparing the current invoice to historical records. Example Code:

    const prompt = `Compare this invoice:\n${JSON.stringify(currentInvoice)}\nTo historical invoices:\n${JSON.stringify(historicalInvoices)}`;
    msg.payload = {
        model: "claude-3-5-sonnet-20240620",
        messages: [{ role: "user", content: prompt }]
    };
    return msg;
  3. Send to Claude API

    • Node: Send to Claude

    • Purpose: Submits the request for anomaly detection.

  4. Parse Anomaly Response

    • Node: Parse Response

    • Purpose: Extracts anomaly, anomalySummary, and anomalyStatus from the API response.

  5. Update Invoice Record

    • Node: Patch Invoice Record

    • Purpose: Updates the invoice record with anomaly details.

  6. Error Handling

    • Nodes: Catch, Error Log

    • Purpose: Logs errors for debugging.


Summary of Flow

  • Flow Start: Invoice files are uploaded through a web interface.

  • Data Preparation: Files are converted to Base64 and sent to the Claude API for parsing.

  • AI Processing: Structured invoice data is extracted and stored.

  • Anomaly Detection: Invoice records are analyzed for anomalies using historical data.

  • Error Handling: Errors are captured and logged for review.

PreviousAll Prebuilt SolutionsNextLead Generation Form

Last updated 4 months ago

Was this helpful?

Page cover image