Telecommunications

Device Trade-In & Upgrade Campaigns

Reach customers who are eligible for device upgrades, present trade-in values, and capture upgrade commitments to drive device revenue.

Why this matters

Reduce churn, drive upgrades, and streamline support with voice automation tailored for wireless and broadband providers. This example shows you how to automate device trade-in & upgrade campaigns 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 DeviceUpgradeBot(guava.CallController):
    def __init__(self, customer_name: str, current_device: str, device_age_months: int,
                 trade_in_value: float, new_device: str, monthly_cost: float):
        super().__init__()
        self.set_persona(
            organization_name="Nexus Mobile Device Team",
            agent_name="Cameron",
        )
        self.set_task(
            objective=f"Offer device upgrade to {customer_name} — {current_device} ({device_age_months} months old)",
            checklist=[
                f"Greet {customer_name} and mention their {current_device} is eligible for a trade-in upgrade.",
                guava.Say(f"Trade-in value for their device: ${trade_in_value:.0f}."),
                guava.Say(f"Recommended upgrade: {new_device} — as low as ${monthly_cost:.2f}/mo after trade-in credit."),
                guava.Field(
                    key="interested_in_upgrade",
                    field_type="bool",
                    description="Is the customer interested in the upgrade?",
                ),
                guava.Field(
                    key="device_condition",
                    field_type="choice",
                    description="Condition of their current device (affects trade-in value)",
                    choices=["excellent", "good", "fair", "poor / cracked screen"],
                    required=False,
                ),
                guava.Field(
                    key="preferred_channel",
                    field_type="choice",
                    description="Preferred way to complete the upgrade",
                    choices=["ship new device and prepaid return box", "nearest store visit",
                             "have rep call me back with details"],
                    required=False,
                ),
                guava.Field(
                    key="wants_device_protection",
                    field_type="bool",
                    description="Interested in adding device protection ($12/mo)?",
                    required=False,
                ),
                "Confirm trade-in details and initiate upgrade order or store appointment.",
            ],
            on_complete=lambda fields: print(f"Device upgrade: {customer_name} — {fields.get('preferred_channel')}"),
        )

guava.dial(
    controller=DeviceUpgradeBot,
    controller_args={"customer_name": "Marcus Howard", "current_device": "iPhone 13",
                     "device_age_months": 28, "trade_in_value": 380,
                     "new_device": "iPhone 16 Pro", "monthly_cost": 12.50},
    to=os.environ["CUSTOMER_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 DeviceUpgradeBot(guava.CallController):
    def __init__(self, customer_name: str, current_device: str, device_age_months: int,
                 trade_in_value: float, new_device: str, monthly_cost: float):
        super().__init__()
        self.set_persona(
            organization_name="Nexus Mobile Device Team",
            agent_name="Cameron",
        )
        self.set_task(
            objective=f"Offer device upgrade to {customer_name} — {current_device} ({device_age_months} months old)",
            checklist=[
                f"Greet {customer_name} and mention their {current_device} is eligible for a trade-in upgrade.",
                guava.Say(f"Trade-in value for their device: ${trade_in_value:.0f}."),
                guava.Say(f"Recommended upgrade: {new_device} — as low as ${monthly_cost:.2f}/mo after trade-in credit."),
                guava.Field(
                    key="interested_in_upgrade",
                    field_type="bool",
                    description="Is the customer interested in the upgrade?",
                ),
                guava.Field(
                    key="device_condition",
                    field_type="choice",
                    description="Condition of their current device (affects trade-in value)",
                    choices=["excellent", "good", "fair", "poor / cracked screen"],
                    required=False,
                ),
                guava.Field(
                    key="preferred_channel",
                    field_type="choice",
                    description="Preferred way to complete the upgrade",
                    choices=["ship new device and prepaid return box", "nearest store visit",
                             "have rep call me back with details"],
                    required=False,
                ),
                guava.Field(
                    key="wants_device_protection",
                    field_type="bool",
                    description="Interested in adding device protection ($12/mo)?",
                    required=False,
                ),
                "Confirm trade-in details and initiate upgrade order or store appointment.",
            ],
            on_complete=lambda fields: print(f"Device upgrade: {customer_name} — {fields.get('preferred_channel')}"),
        )

guava.dial(
    controller=DeviceUpgradeBot,
    controller_args={"customer_name": "Marcus Howard", "current_device": "iPhone 13",
                     "device_age_months": 28, "trade_in_value": 380,
                     "new_device": "iPhone 16 Pro", "monthly_cost": 12.50},
    to=os.environ["CUSTOMER_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