# Risk Survey & Inspection Scheduling

Conduct structured risk surveys and schedule on-site inspections for commercial or high-value residential policies — all without a field inspector making the first contact.

### Why this matters

Automate claims intake, policy renewals, and customer outreach with voice agents built for regulated insurance workflows. This example shows you how to automate risk survey & inspection scheduling 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 RiskSurveyBot(guava.CallController):
    def __init__(self, contact_name: str, property_address: str, policy_number: str):
        super().__init__()
        self.set_persona(
            organization_name="Atlas Underwriters Risk Services",
            agent_name="Blake",
        )
        self.set_task(
            objective=f"Complete risk survey for {property_address} and schedule inspection if needed",
            checklist=[
                f"Introduce yourself to {contact_name} and explain the annual risk assessment process.",
                guava.Field(
                    key="sprinkler_system",
                    field_type="bool",
                    description="Does the property have a sprinkler system?",
                ),
                guava.Field(
                    key="fire_alarm_monitored",
                    field_type="bool",
                    description="Is the fire alarm system centrally monitored?",
                ),
                guava.Field(
                    key="recent_renovations",
                    field_type="bool",
                    description="Any major renovations in the past 2 years?",
                ),
                guava.Field(
                    key="occupancy_changes",
                    field_type="bool",
                    description="Any changes in occupancy or business operations?",
                ),
                guava.Field(
                    key="inspection_needed",
                    field_type="bool",
                    description="Based on answers, does an on-site inspection need to be scheduled?",
                ),
                guava.Field(
                    key="inspection_availability",
                    field_type="calendar_slot",
                    description="Best time for inspector to visit",
                    required=False,
                    choice_generator=lambda: ["Mon 9-12", "Mon 1-4", "Wed 9-12", "Fri 9-12"],
                ),
                "Confirm survey completion and inspection details if applicable.",
            ],
            on_complete=lambda fields: print(f"Risk survey complete for {property_address}"),
        )

guava.dial(
    controller=RiskSurveyBot,
    controller_args={"contact_name": "Gary Mendez", "property_address": "2210 Commerce Blvd Suite 400",
                     "policy_number": "COM-7742"},
    to=os.environ["CONTACT_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.

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

class RiskSurveyBot(guava.CallController):
    def __init__(self, contact_name: str, property_address: str, policy_number: str):
        super().__init__()
        self.set_persona(
            organization_name="Atlas Underwriters Risk Services",
            agent_name="Blake",
        )
        self.set_task(
            objective=f"Complete risk survey for {property_address} and schedule inspection if needed",
            checklist=[
                f"Introduce yourself to {contact_name} and explain the annual risk assessment process.",
                guava.Field(
                    key="sprinkler_system",
                    field_type="bool",
                    description="Does the property have a sprinkler system?",
                ),
                guava.Field(
                    key="fire_alarm_monitored",
                    field_type="bool",
                    description="Is the fire alarm system centrally monitored?",
                ),
                guava.Field(
                    key="recent_renovations",
                    field_type="bool",
                    description="Any major renovations in the past 2 years?",
                ),
                guava.Field(
                    key="occupancy_changes",
                    field_type="bool",
                    description="Any changes in occupancy or business operations?",
                ),
                guava.Field(
                    key="inspection_needed",
                    field_type="bool",
                    description="Based on answers, does an on-site inspection need to be scheduled?",
                ),
                guava.Field(
                    key="inspection_availability",
                    field_type="calendar_slot",
                    description="Best time for inspector to visit",
                    required=False,
                    choice_generator=lambda: ["Mon 9-12", "Mon 1-4", "Wed 9-12", "Fri 9-12"],
                ),
                "Confirm survey completion and inspection details if applicable.",
            ],
            on_complete=lambda fields: print(f"Risk survey complete for {property_address}"),
        )

## Run it

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

```
python example.py
```
