Government & Public Sector

Public Health Surveys

Conduct large-scale public health surveys to track disease prevalence, vaccination rates, and health behaviors across the population.

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 public health surveys calls end-to-end with Guava's SDK — no telephony plumbing, no prompt engineering, just Python.

How to set persona & task
Working with Fields and Say items
Handling callbacks
Running the agent
Step 01

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="..."
Step 02

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.

01

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
02

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 PublicHealthSurveyBot(guava.CallController):
    def __init__(self, survey_name: str, agency: str, survey_year: int):
        super().__init__()
        self.set_persona(
            organization_name=agency,
            agent_name="Morgan",
        )
        self.set_task(
            objective=f"Conduct {survey_year} {survey_name} — voluntary, anonymous health survey",
            checklist=[
                f"Introduce yourself from {agency} conducting the voluntary, anonymous {survey_name}.",
                guava.Say("Participation is voluntary and all responses are anonymous."),
                guava.Field(
                    key="agrees_to_participate",
                    field_type="bool",
                    description="Does the resident agree to participate?",
                ),
                guava.Field(
                    key="age_range",
                    field_type="choice",
                    description="Age range",
                    choices=["18-24", "25-34", "35-44", "45-54", "55-64", "65+"],
                ),
                guava.Field(
                    key="vaccinated_flu_this_year",
                    field_type="bool",
                    description="Have they received a flu vaccine this season?",
                ),
                guava.Field(
                    key="has_primary_care_physician",
                    field_type="bool",
                    description="Do they have a primary care physician they see regularly?",
                ),
                guava.Field(
                    key="health_insurance",
                    field_type="bool",
                    description="Do they currently have health insurance coverage?",
                ),
                guava.Field(
                    key="mental_health_access",
                    field_type="bool",
                    description="In the past year, have they had access to mental health services if needed?",
                ),
                "Thank the participant and provide health resources hotline number.",
            ],
            on_complete=lambda fields: print(f"Survey response recorded (anonymous): {fields}"),
        )

guava.dial(
    controller=PublicHealthSurveyBot,
    controller_args={"survey_name": "Behavioral Risk Factor Survey",
                     "agency": "County Department of Public Health",
                     "survey_year": 2024},
    to=os.environ["RESIDENT_PHONE"],
    agent_number=os.environ["GUAVA_AGENT_NUMBER"],
    api_key=os.environ["GUAVA_API_KEY"],
)

Platform performance

<1s

Response time

99.99%

Uptime SLA

13+

Industries served

Step 03

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 PublicHealthSurveyBot(guava.CallController):
    def __init__(self, survey_name: str, agency: str, survey_year: int):
        super().__init__()
        self.set_persona(
            organization_name=agency,
            agent_name="Morgan",
        )
        self.set_task(
            objective=f"Conduct {survey_year} {survey_name} — voluntary, anonymous health survey",
            checklist=[
                f"Introduce yourself from {agency} conducting the voluntary, anonymous {survey_name}.",
                guava.Say("Participation is voluntary and all responses are anonymous."),
                guava.Field(
                    key="agrees_to_participate",
                    field_type="bool",
                    description="Does the resident agree to participate?",
                ),
                guava.Field(
                    key="age_range",
                    field_type="choice",
                    description="Age range",
                    choices=["18-24", "25-34", "35-44", "45-54", "55-64", "65+"],
                ),
                guava.Field(
                    key="vaccinated_flu_this_year",
                    field_type="bool",
                    description="Have they received a flu vaccine this season?",
                ),
                guava.Field(
                    key="has_primary_care_physician",
                    field_type="bool",
                    description="Do they have a primary care physician they see regularly?",
                ),
                guava.Field(
                    key="health_insurance",
                    field_type="bool",
                    description="Do they currently have health insurance coverage?",
                ),
                guava.Field(
                    key="mental_health_access",
                    field_type="bool",
                    description="In the past year, have they had access to mental health services if needed?",
                ),
                "Thank the participant and provide health resources hotline number.",
            ],
            on_complete=lambda fields: print(f"Survey response recorded (anonymous): {fields}"),
        )

guava.dial(
    controller=PublicHealthSurveyBot,
    controller_args={"survey_name": "Behavioral Risk Factor Survey",
                     "agency": "County Department of Public Health",
                     "survey_year": 2024},
    to=os.environ["RESIDENT_PHONE"],
    agent_number=os.environ["GUAVA_AGENT_NUMBER"],
    api_key=os.environ["GUAVA_API_KEY"],
)
Step 04

Run it

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

terminal
python example.py
Get Started