# Account Delinquency Outreach

Contact past-due customers with empathy, offer payment arrangements, and capture commitments to pay — all while maintaining FDCPA compliance.

### Why this matters

PCI-compliant, fully auditable voice automation for loans, collections, onboarding, and fraud prevention. This example shows you how to automate account delinquency outreach calls end-to-end with Guava's SDK — no telephony plumbing, no prompt engineering, just Python.

## Installation

Install from Guava's private PyPI index. A public package is coming soon — the install command will simplify to `pip install guava`.

```terminal
# Step 1: Install Guava
pip install gridspace-guava --extra-index-url https://guava-pypi.gridspace.com

# Public PyPI package coming soon — the install command will simplify to:
# pip install guava

# Step 2: Set your credentials
export GUAVA_API_KEY="..."
export GUAVA_AGENT_NUMBER="..."
```

## How it's built

Every Guava agent is a Python class. Walk through the key sections below, then grab the complete file at the end.

### Imports

Import the Guava SDK and any helpers you need. `guava.CallController` is the base class for every voice agent.

```example.py
# Install: pip install gridspace-guava --extra-index-url https://guava-pypi.gridspace.com
import guava
import os
```

### Agent setup

`set_persona()` defines how the agent presents itself. `set_task()` gives it its mission in plain English. The checklist drives the conversation — Guava works through it top-to-bottom, collecting `Field` values and speaking `Say` items as it goes.

```example.py
class DelinquencyBot(guava.CallController):
    def __init__(self, customer_name: str, account_last4: str, balance: float, days_past_due: int):
        super().__init__()
        self.set_persona(
            organization_name="Meridian Bank Collections",
            agent_name="Taylor",
        )
        self.set_task(
            objective=f"Reach {customer_name} about their past-due account balance of ${balance:.2f} ({days_past_due} days past due)",
            checklist=[
                f"Identify yourself and state this is an attempt to collect a debt from Meridian Bank.",
                guava.Field(
                    key="speaking_with_customer",
                    field_type="bool",
                    description=f"Confirm you are speaking with {customer_name}",
                ),
                guava.Say(f"Advise the balance of ${balance:.2f} is {days_past_due} days past due."),
                guava.Field(
                    key="payment_intent",
                    field_type="choice",
                    description="How does the customer want to resolve the balance?",
                    choices=["pay in full today", "set up payment plan", "dispute the balance", "call back later"],
                ),
                guava.Field(
                    key="payment_date",
                    field_type="date",
                    description="When can the customer make a payment?",
                    required=False,
                ),
                guava.Field(
                    key="payment_amount",
                    field_type="currency",
                    description="How much can the customer pay?",
                    required=False,
                ),
                "Confirm any arrangement, provide confirmation number, and advise of consumer rights.",
            ],
            on_complete=lambda fields: print(f"Delinquency call complete for {customer_name}: {fields}"),
        )

guava.dial(
    controller=DelinquencyBot,
    controller_args={"customer_name": "Derek Mason", "account_last4": "3391",
                     "balance": 1247.50, "days_past_due": 45},
    to=os.environ["CUSTOMER_PHONE"],
    agent_number=os.environ["GUAVA_AGENT_NUMBER"],
    api_key=os.environ["GUAVA_API_KEY"],
)
```

## Full example

The complete file — copy it, save it as `example.py`, and run it.

```example.py
# Install: pip install gridspace-guava --extra-index-url https://guava-pypi.gridspace.com
import guava
import os

class DelinquencyBot(guava.CallController):
    def __init__(self, customer_name: str, account_last4: str, balance: float, days_past_due: int):
        super().__init__()
        self.set_persona(
            organization_name="Meridian Bank Collections",
            agent_name="Taylor",
        )
        self.set_task(
            objective=f"Reach {customer_name} about their past-due account balance of ${balance:.2f} ({days_past_due} days past due)",
            checklist=[
                f"Identify yourself and state this is an attempt to collect a debt from Meridian Bank.",
                guava.Field(
                    key="speaking_with_customer",
                    field_type="bool",
                    description=f"Confirm you are speaking with {customer_name}",
                ),
                guava.Say(f"Advise the balance of ${balance:.2f} is {days_past_due} days past due."),
                guava.Field(
                    key="payment_intent",
                    field_type="choice",
                    description="How does the customer want to resolve the balance?",
                    choices=["pay in full today", "set up payment plan", "dispute the balance", "call back later"],
                ),
                guava.Field(
                    key="payment_date",
                    field_type="date",
                    description="When can the customer make a payment?",
                    required=False,
                ),
                guava.Field(
                    key="payment_amount",
                    field_type="currency",
                    description="How much can the customer pay?",
                    required=False,
                ),
                "Confirm any arrangement, provide confirmation number, and advise of consumer rights.",
            ],
            on_complete=lambda fields: print(f"Delinquency call complete for {customer_name}: {fields}"),
        )

## Run it

Start the agent. It will connect to Guava's infrastructure and begin accepting calls on your assigned number.

```terminal
python example.py
```
