feat: add Revenue Leak Detector agent with HubSpot CRM + Telegram + Gmail integration#5166
feat: add Revenue Leak Detector agent with HubSpot CRM + Telegram + Gmail integration#5166Siddharth2624 wants to merge 5 commits intoaden-hive:mainfrom
Conversation
… Gmail integration - 4-node event_loop graph: monitor → analyze → notify → followup - Detects GHOSTED (21+ days), STALLED (10-20 days), OVERDUE_PAYMENT, CHURN_RISK - HubSpot CRM v3 API integration with contact email batch-fetch - Telegram HTML-formatted alerts via Bot API - Gmail SMTP follow-up emails to ghosted contacts - Graceful offline fallback when credentials not set - Halt loop fix: str(halt).lower() != 'true' to handle any LLM casing
bryanadenhq
left a comment
There was a problem hiding this comment.
Hi @Siddharth2624, I just left some comments for you to review. Thanks for your contribution!
| @@ -0,0 +1,7 @@ | |||
| from .agent import goal, nodes, edges | |||
There was a problem hiding this comment.
Missing agent class, default_agnet instance, and config exports. All other template export these. WIthout an agent calss, this template can't be loaded or run the same way as others.
| print(" 💰 REVENUE LEAK DETECTOR — Starting Agent") | ||
| print("=" * 64) | ||
|
|
||
| runner = AgentRunner.load("examples/templates/revenue_leak_detector") |
There was a problem hiding this comment.
Other templates don't use AgentRunner.load() in main.py, they all import and instantiate their own agent class in init.py per my previous comment.
| print("=" * 64) | ||
|
|
||
| runner = AgentRunner.load("examples/templates/revenue_leak_detector") | ||
| runner._setup() |
There was a problem hiding this comment.
Private class, shouldn't be called directly
| # Minimal @tool decorator (framework convention) | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
| def tool(func): |
There was a problem hiding this comment.
We should be registering tools using the TOOLS dict + tool_executor() pattern.
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Shared in-process state — survives across node calls within the same run | ||
| _CURRENT_CYCLE_DATA: dict = {} |
There was a problem hiding this comment.
Globals are not thread-sage and not session-isolated.
| ## Agent Graph | ||
|
|
||
| ``` | ||
| monitor ──► analyze ──► notify |
There was a problem hiding this comment.
readme no longer up to date
There was a problem hiding this comment.
Fixed all. Please check if anything left.
Fixes #5153
Overview
Adds a new
revenue_leak_detectoragent template — an autonomous business health monitor that continuously scans a CRM pipeline, detects revenue leak patterns, sends Telegram alerts, dispatches Gmail follow-up emails to ghosted contacts, and halts automatically when severity reaches critical.Agent Architecture
monitor ──► analyze ──► notify ──► followup
│
◄───────────────────────────┘
(loops while halt != true)
monitorevent_loopscan_pipeline()— fetches open deals from HubSpot CRManalyzeevent_loopdetect_revenue_leaks()— classifies leaks, calculates severitynotifyevent_loopsend_revenue_alert()— prints structured report + sends Telegram alertfollowupevent_loopsend_followup_emails()— sends Gmail re-engagement emails to GHOSTED contactsLoop exits automatically when
severity = critical(halt = True).What It Detects
Integrations
HubSpot CRM (real data tested ✅)
hs_lastmodifieddateto calculatedays_inactiveclosedwon/closedlostdeals automaticallyHUBSPOT_API_KEYis not setTelegram (real delivery tested ✅)
Gmail SMTP (configured ✅)
Environment Variables Required
HUBSPOT_API_KEYcrm.objects.deals.read,crm.objects.contacts.read)TELEGRAM_BOT_TOKENTELEGRAM_CHAT_IDGMAIL_USERGMAIL_APP_PASSWORDAll integrations are optional — the agent runs fully offline without any credentials (console output only).
Running