# Permit & License Application Follow-Up

Notify applicants of permit status, outstanding requirements, or inspection scheduling needs — reducing in-person counter visits.

### Why this matters

Reach constituents at scale for benefits enrollment, permit follow-ups, public health outreach, and emergency notifications. This example shows you how to automate permit & license 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`.

```
# 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.

```
# 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.

```python
class PermitFollowUpBot(guava.CallController):
    def __init__(self, applicant_name: str, permit_number: str, permit_type: str,
                 status: str, action_required: str):
        super().__init__()
        self.set_persona(
            organization_name="City Planning & Building Department",
            agent_name="Robin",
        )
        self.set_task(
            objective=f"Update {applicant_name} on permit {permit_number} status",
            checklist=[
                f"Identify yourself to {applicant_name} regarding permit {permit_number} for {permit_type}.",
                guava.Say(f"Current status: {status}. Action required: {action_required}."),
                guava.Field(
                    key="understands_requirement",
                    field_type="bool",
                    description="Does the applicant understand what action is required?",
                ),
                guava.Field(
                    key="needs_clarification",
                    field_type="bool",
                    description="Do they have questions about the requirement?",
                ),
                guava.Field(
                    key="inspection_scheduling",
                    field_type="bool",
                    description="Does this require scheduling a building inspection?",
                ),
                guava.Field(
                    key="inspection_slot",
                    field_type="calendar_slot",
                    description="Preferred inspection date",
                    required=False,
                    choice_generator=lambda: ["Mon AM", "Mon PM", "Wed AM", "Wed PM", "Fri AM"],
                ),
                guava.Field(
                    key="revised_submission_date",
                    field_type="date",
                    description="When does the applicant expect to complete the required action?",
                    required=False,
                ),
                "Provide permit portal URL and direct line for building department questions.",
            ],
            on_complete=lambda fields: print(f"Permit follow-up complete: {permit_number}"),
        )
```

### Full example

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

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

class PermitFollowUpBot(guava.CallController):
    def __init__(self, applicant_name: str, permit_number: str, permit_type: str,
                 status: str, action_required: str):
        super().__init__()
        self.set_persona(
            organization_name="City Planning & Building Department",
            agent_name="Robin",
        )
        self.set_task(
            objective=f"Update {applicant_name} on permit {permit_number} status",
            checklist=[
                f"Identify yourself to {applicant_name} regarding permit {permit_number} for {permit_type}.",
                guava.Say(f"Current status: {status}. Action required: {action_required}."),
                guava.Field(
                    key="understands_requirement",
                    field_type="bool",
                    description="Does the applicant understand what action is required?",
                ),
                guava.Field(
                    key="needs_clarification",
                    field_type="bool",
                    description="Do they have questions about the requirement?",
                ),
                guava.Field(
                    key="inspection_scheduling",
                    field_type="bool",
                    description="Does this require scheduling a building inspection?",
                ),
                guava.Field(
                    key="inspection_slot",
                    field_type="calendar_slot",
                    description="Preferred inspection date",
                    required=False,
                    choice_generator=lambda: ["Mon AM", "Mon PM", "Wed AM", "Wed PM", "Fri AM"],
                ),
                guava.Field(
                    key="revised_submission_date",
                    field_type="date",
                    description="When does the applicant expect to complete the required action?",
                    required=False,
                ),
                "Provide permit portal URL and direct line for building department questions.",
            ],
            on_complete=lambda fields: print(f"Permit follow-up complete: {permit_number}"),
        )

guava.dial(
    controller=PermitFollowUpBot,
    controller_args={"applicant_name": "Oak Street Builders LLC",
                     "permit_number": "BP-2024-08847",
                     "permit_type": "residential addition",
                     "status": "on hold pending fire sprinkler plans",
                     "action_required": "submit revised fire sprinkler layout"},
    to=os.environ["APPLICANT_PHONE"],
    agent_number=os.environ["GUAVA_AGENT_NUMBER"],
    api_key=os.environ["GUAVA_API_KEY"],
)
```

## Run it

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

```
python example.py
```
