{"slug": "i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you", "title": "I Built an AI Subscription Cancel-Save Agent That Does Not Manipulate You", "summary": "Telnyx released an open-source AI subscription cancel-save agent built with Python Flask that combines voice, AI inference, and messaging. The agent classifies cancellation reasons, offers one relevant save option, and respects direct cancellation requests without manipulative dark patterns. The demo covers three flows—saved, cancelled, and transferred—and is designed to mirror ethical customer-success team practices.", "body_md": "Cancel-save flows are easy to over-engineer into manipulative dark patterns, and easy to under-engineer into \"your subscription has been cancelled, goodbye\" experiences that lose revenue. A good cancel-save agent does three things: classifies the reason, offers one relevant save option, and respects a direct cancellation request.\n\nThe Telnyx code example is:\n\nIt is a Python Flask app that combines Telnyx Voice, AI Inference, and Messaging into a small demo you can clone and run in a few minutes.\n\nA customer calls in saying they want to cancel. The Flask app receives the webhook, verifies the customer by caller ID, and asks why they want to cancel. AI Inference returns the reason (`too_expensive`\n\n, `not_using`\n\n, `missing_feature`\n\n, `support_issue`\n\n, `competitor_switch`\n\n, `temporary_pause`\n\n, `other`\n\n) and the sentiment. Hardcoded urgent phrases (`lawyer`\n\n, `sue`\n\n, `fraud`\n\n, `chargeback`\n\n) and direct cancel phrases (`cancel now`\n\n, `please cancel my subscription`\n\n) short-circuit before any offer.\n\nOtherwise, the agent offers one save option from the OFFER_POLICY mapping. A \"yes\" applies the save or pauses the subscription. A \"no\" or \"cancel\" ends the call with a graceful cancellation. An ambiguous yes/no gets exactly one clarifying prompt — the agent never loops.\n\nThe case is recorded with the outcome (`saved`\n\n, `cancelled`\n\n, `paused`\n\n, `transferred`\n\n, `needs_followup`\n\n), and the customer record is updated. Hangups before resolution are recorded as `needs_followup`\n\nso reps can call back.\n\nIt is small enough to demo live, but it covers the parts that often get cut from a \"Hello World\" voice AI demo:\n\nThe design choice I care most about is non-manipulation. The agent does not push back on a direct cancellation, and it offers one save option — not five — when the customer is open to one. That maps to how good customer-success teams actually operate.\n\n```\ngit clone https://github.com/team-telnyx/telnyx-code-examples.git\ncd telnyx-code-examples/ai-subscription-cancel-save-retention-agent-python\ncp .env.example .env\npip install -r requirements.txt\npython app.py\n```\n\nExpose the webhook:\n\n```\nngrok http 5000\n```\n\nIn the Telnyx Portal, set the Voice API app webhook URL to `https://<ngrok-id>.ngrok-free.app/webhooks/voice`\n\n. Seed a customer with `POST /customers`\n\n, then call the Telnyx number from the customer's phone.\n\nI would keep the demo short and show three flows back-to-back:\n\n`saved`\n\n, customer status `active`\n\n.`cancelled`\n\n, customer status `cancelled`\n\n.`transferred`\n\n, call moves to the human escalation number.That gives viewers the full loop without getting lost in implementation details.\n\nThe demo uses in-memory state, which is fine for learning. Production would wire the customer and case stores into your billing system (Stripe, Recurly, Chargebee) so a `saved`\n\noutcome actually applies the discount and a `paused`\n\noutcome defers the next invoice. Add consent recording (`record_channels: \"dual\"`\n\n) for compliance audits, and replace the caller-ID match with a one-time code flow for real verification.", "url": "https://wpnews.pro/news/i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you", "canonical_source": "https://dev.to/botoclock/i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you-3gbd", "published_at": "2026-07-14 22:03:54+00:00", "updated_at": "2026-07-14 22:57:37.072225+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-ethics", "ai-agents", "developer-tools"], "entities": ["Telnyx", "Python Flask", "Stripe", "Recurly", "Chargebee"], "alternates": {"html": "https://wpnews.pro/news/i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you", "markdown": "https://wpnews.pro/news/i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you.md", "text": "https://wpnews.pro/news/i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you.txt", "jsonld": "https://wpnews.pro/news/i-built-an-ai-subscription-cancel-save-agent-that-does-not-manipulate-you.jsonld"}}