Telecommunications

Churn Prevention Outreach

Identify at-risk customers and proactively reach out with retention offers before they cancel, reducing churn without inflating discount costs.

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 churn prevention outreach 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 ChurnPreventionBot(guava.CallController):
    def __init__(self, customer_name: str, account_number: str, churn_risk_score: float,
                 current_plan: str, retention_offer: str):
        super().__init__()
        self.set_persona(
            organization_name="Nexus Mobile Customer Loyalty",
            agent_name="Logan",
        )
        self.set_task(
            objective=f"Retain {customer_name} (churn risk: {churn_risk_score:.0%}) currently on {current_plan}",
            checklist=[
                f"Warmly greet {customer_name} — this is a loyalty appreciation call, not a sales call.",
                guava.Field(
                    key="satisfaction_score",
                    field_type="rating",
                    description="Overall satisfaction with Nexus Mobile (1-10)",
                ),
                guava.Field(
                    key="primary_concern",
                    field_type="choice",
                    description="If there's any dissatisfaction, what's the main issue?",
                    choices=["bill too high", "coverage issues", "data speeds", "customer service",
                             "better offer elsewhere", "no issues"],
                ),
                guava.Say(f"Present the retention offer: {retention_offer}."),
                guava.Field(
                    key="accepts_offer",
                    field_type="bool",
                    description="Does the customer want to accept the loyalty offer?",
                ),
                guava.Field(
                    key="considering_switching",
                    field_type="bool",
                    description="Are they actively considering switching carriers?",
                ),
                "Apply offer if accepted and flag for human follow-up if switching is confirmed.",
            ],
            on_complete=self.handle_churn_result,
        )

    def handle_churn_result(self, fields):
        if fields.get("accepts_offer"):
            print(f"Retention success: {fields}")
        elif fields.get("considering_switching"):
            print(f"ESCALATE to senior retention specialist: high churn intent")

guava.dial(
    controller=ChurnPreventionBot,
    controller_args={"customer_name": "Brandon Walsh", "account_number": "NXM-447821",
                     "churn_risk_score": 0.82, "current_plan": "$85/mo Unlimited Plus",
                     "retention_offer": "$20/month discount for 12 months + free device protection"},
    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 ChurnPreventionBot(guava.CallController):
    def __init__(self, customer_name: str, account_number: str, churn_risk_score: float,
                 current_plan: str, retention_offer: str):
        super().__init__()
        self.set_persona(
            organization_name="Nexus Mobile Customer Loyalty",
            agent_name="Logan",
        )
        self.set_task(
            objective=f"Retain {customer_name} (churn risk: {churn_risk_score:.0%}) currently on {current_plan}",
            checklist=[
                f"Warmly greet {customer_name} — this is a loyalty appreciation call, not a sales call.",
                guava.Field(
                    key="satisfaction_score",
                    field_type="rating",
                    description="Overall satisfaction with Nexus Mobile (1-10)",
                ),
                guava.Field(
                    key="primary_concern",
                    field_type="choice",
                    description="If there's any dissatisfaction, what's the main issue?",
                    choices=["bill too high", "coverage issues", "data speeds", "customer service",
                             "better offer elsewhere", "no issues"],
                ),
                guava.Say(f"Present the retention offer: {retention_offer}."),
                guava.Field(
                    key="accepts_offer",
                    field_type="bool",
                    description="Does the customer want to accept the loyalty offer?",
                ),
                guava.Field(
                    key="considering_switching",
                    field_type="bool",
                    description="Are they actively considering switching carriers?",
                ),
                "Apply offer if accepted and flag for human follow-up if switching is confirmed.",
            ],
            on_complete=self.handle_churn_result,
        )

    def handle_churn_result(self, fields):
        if fields.get("accepts_offer"):
            print(f"Retention success: {fields}")
        elif fields.get("considering_switching"):
            print(f"ESCALATE to senior retention specialist: high churn intent")

guava.dial(
    controller=ChurnPreventionBot,
    controller_args={"customer_name": "Brandon Walsh", "account_number": "NXM-447821",
                     "churn_risk_score": 0.82, "current_plan": "$85/mo Unlimited Plus",
                     "retention_offer": "$20/month discount for 12 months + free device protection"},
    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