# Loan Application Follow-Up

Proactively contact loan applicants to collect missing documents, update them on status, and keep them engaged through the underwriting process.

### Why this matters

PCI-compliant, fully auditable voice automation for loans, collections, onboarding, and fraud prevention. This example shows you how to automate loan application follow-up 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 LoanFollowUpBot(guava.CallController):
    def __init__(self, applicant_name: str, loan_type: str, missing_docs: list[str]):
        super().__init__()
        self.missing_docs = missing_docs
        self.set_persona(
            organization_name="Meridian Bank",
            agent_name="Chris",
        )
        self.set_task(
            objective=f"Follow up with {applicant_name} on their {loan_type} application and collect missing documents",
            checklist=[
                f"Greet {applicant_name} and confirm you're speaking with the right person.",
                guava.Say(f"Explain that the application is in review and the following documents are still needed: {', '.join(missing_docs)}."),
                guava.Field(
                    key="document_upload_method",
                    field_type="choice",
                    description="How would the applicant prefer to submit documents?",
                    choices=["email", "secure portal", "branch drop-off", "mail"],
                ),
                guava.Field(
                    key="expected_submission_date",
                    field_type="date",
                    description="When does the applicant expect to have documents ready?",
                ),
                guava.Field(
                    key="has_questions",
                    field_type="bool",
                    description="Does the applicant have any questions about the process?",
                ),
                "Confirm next steps and provide the secure upload link if requested.",
            ],
            on_complete=lambda fields: print(f"Follow-up logged for {applicant_name}: {fields}"),
        )

guava.dial(
        controller=LoanFollowUpBot,
        controller_args={"applicant_name": "James Park", "loan_type": "home mortgage",
                         "missing_docs": ["2023 W-2", "last 2 bank statements", "HOA docs"]},
        to=os.environ["APPLICANT_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 LoanFollowUpBot(guava.CallController):
    def __init__(self, applicant_name: str, loan_type: str, missing_docs: list[str]):
        super().__init__()
        self.missing_docs = missing_docs
        self.set_persona(
            organization_name="Meridian Bank",
            agent_name="Chris",
        )
        self.set_task(
            objective=f"Follow up with {applicant_name} on their {loan_type} application and collect missing documents",
            checklist=[
                f"Greet {applicant_name} and confirm you're speaking with the right person.",
                guava.Say(f"Explain that the application is in review and the following documents are still needed: {', '.join(missing_docs)}."),
                guava.Field(
                    key="document_upload_method",
                    field_type="choice",
                    description="How would the applicant prefer to submit documents?",
                    choices=["email", "secure portal", "branch drop-off", "mail"],
                ),
                guava.Field(
                    key="expected_submission_date",
                    field_type="date",
                    description="When does the applicant expect to have documents ready?",
                ),
                guava.Field(
                    key="has_questions",
                    field_type="bool",
                    description="Does the applicant have any questions about the process?",
                ),
                "Confirm next steps and provide the secure upload link if requested.",
            ],
            on_complete=lambda fields: print(f"Follow-up logged for {applicant_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
```
