Abandoned Cart Recovery
Reach customers who abandoned high-value carts, understand why, and offer personalized incentives to complete the purchase.
Why this matters
Drive revenue and retention with voice automation for order updates, cart recovery, loyalty enrollment, and post-purchase engagement. This example shows you how to automate abandoned cart recovery 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 osAgent 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.
class AbandonedCartBot(guava.CallController):
def __init__(self, customer_name: str, cart_items: list[str], cart_value: float):
super().__init__()
self.set_persona(
organization_name="Pinnacle Commerce",
agent_name="Quinn",
)
self.set_task(
objective=f"Recover abandoned cart of ${cart_value:.2f} from {customer_name}",
checklist=[
f"Greet {customer_name} — mention you noticed they left items in their cart.",
guava.Say(f"Items: {', '.join(cart_items)}. Total: ${cart_value:.2f}."),
guava.Field(
key="abandonment_reason",
field_type="choice",
description="Why did they not complete the purchase?",
choices=["shipping cost too high", "just browsing", "found it cheaper elsewhere",
"had a technical issue", "changed my mind", "price too high"],
),
guava.Field(
key="wants_discount",
field_type="bool",
description="Would a 10% discount help them complete the order?",
),
guava.Field(
key="complete_now",
field_type="bool",
description="Would they like a direct link sent to complete the purchase now?",
),
"Send cart recovery link and apply discount code if accepted.",
],
on_complete=self.handle_recovery,
)
def handle_recovery(self, fields):
if fields.get("complete_now"):
print(f"Sending recovery link with 10% discount to {fields}")
else:
print(f"Abandonment reason logged: {fields.get('abandonment_reason')}")
guava.dial(
controller=AbandonedCartBot,
controller_args={"customer_name": "Rachel Green", "cart_value": 342.99,
"cart_items": ["Wireless Headphones", "USB-C Hub", "Laptop Stand"]},
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
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 AbandonedCartBot(guava.CallController):
def __init__(self, customer_name: str, cart_items: list[str], cart_value: float):
super().__init__()
self.set_persona(
organization_name="Pinnacle Commerce",
agent_name="Quinn",
)
self.set_task(
objective=f"Recover abandoned cart of ${cart_value:.2f} from {customer_name}",
checklist=[
f"Greet {customer_name} — mention you noticed they left items in their cart.",
guava.Say(f"Items: {', '.join(cart_items)}. Total: ${cart_value:.2f}."),
guava.Field(
key="abandonment_reason",
field_type="choice",
description="Why did they not complete the purchase?",
choices=["shipping cost too high", "just browsing", "found it cheaper elsewhere",
"had a technical issue", "changed my mind", "price too high"],
),
guava.Field(
key="wants_discount",
field_type="bool",
description="Would a 10% discount help them complete the order?",
),
guava.Field(
key="complete_now",
field_type="bool",
description="Would they like a direct link sent to complete the purchase now?",
),
"Send cart recovery link and apply discount code if accepted.",
],
on_complete=self.handle_recovery,
)
def handle_recovery(self, fields):
if fields.get("complete_now"):
print(f"Sending recovery link with 10% discount to {fields}")
else:
print(f"Abandonment reason logged: {fields.get('abandonment_reason')}")
guava.dial(
controller=AbandonedCartBot,
controller_args={"customer_name": "Rachel Green", "cart_value": 342.99,
"cart_items": ["Wireless Headphones", "USB-C Hub", "Laptop Stand"]},
to=os.environ["CUSTOMER_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