Skip to main content
This example demonstrates how to build a lightweight Upsonic LLM agent that classifies incoming fintech operation emails into specific categories — helping operations teams automatically sort and respond to critical messages.

Overview

In this example, the agent classifies emails into one of two categories:
  1. Information Requests — messages requesting data such as account statements, balance history, or audit documents.
  2. Lien on Bank Account — notifications indicating a lien, freeze, or court order on a customer account.
The agent uses a single LLM Task to perform the classification.
There are no external integrations — just intelligent reasoning based on email content.

Key Features

  • Autonomous Classification: The LLM performs all reasoning — no manual logic or regex
  • Minimal Architecture: One Task, one prompt, one result
  • Structured Output: Uses Pydantic models for type-safe responses
  • Extendable: Easily add new categories or integrate with real email systems

Code Structure

Response Model

Agent Setup

Task Definition

Example Emails

The script includes two sample emails: Email 1 - Information Request:
Email 2 - Lien on Bank Account:

Complete Implementation

How It Works

  1. Input: The LLM receives the text of the email.
  2. Reasoning: The agent analyzes the content and context — e.g., requests vs. legal notifications.
  3. Output: Returns a structured JSON object with a single field:
    • category: "information_request" or "lien_on_bank_account"

Usage

Setup

Run the classifier

Example Output

Email 1:
Email 2:

Use Cases

  • Fintech Operations: Automatically sort incoming regulatory and legal emails
  • Compliance Departments: Handle high email volume with intelligent routing
  • Customer Support: Categorize support tickets and requests
  • Legal Teams: Identify urgent legal notifications requiring immediate attention

File Structure

Repository

View the complete example: Classify Emails Example