-
Notifications
You must be signed in to change notification settings - Fork 49
Add web-hook call when phone is not picked #453
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add web-hook call when phone is not picked #453
Conversation
WalkthroughThe changes introduce webhook notifications for no-answer call scenarios during retries, update the retry dispatcher to accept outcome parameters for external reporting, adjust webhook behavior for different call outcomes in the websocket bot, and remove unused type imports from the TTS module. Changes
Sequence DiagramsequenceDiagram
participant Call as Call Handler
participant Retry as Retry Dispatcher
participant Lead as Lead Tracker
participant Webhook as Webhook Service
participant Log as Logger
Call->>Retry: _retry_call(lead, config, "NO_ANSWER")
Note over Retry: outcome = "NO_ANSWER"
Retry->>Lead: Check reporting_webhook_url
alt webhook_url present
Retry->>Retry: Compute call duration
Retry->>Retry: Assemble summary_data<br/>(callSid, outcome, attemptCount, etc.)
Retry->>Webhook: Send webhook (max_retries=3)
alt success
Webhook-->>Retry: 2xx response
Retry->>Log: Log webhook success
else failure
Webhook-->>Retry: error
Retry->>Log: Log webhook failure
end
else no webhook_url
Note over Retry: Skip webhook notification
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/ai/voice/agents/breeze_buddy/managers/calls.py (1)
213-248: Consider narrowing the exception handler and evaluating session reuse.The webhook logic for NO_ANSWER on the last retry is well-implemented and aligns with the PR objective. However, there are two areas to consider:
Catching blind exception: Line 247 catches
Exceptionwithout specifying the exception type, which is flagged by static analysis. While this ensures the retry logic doesn't break, consider catching more specific exceptions (e.g.,aiohttp.ClientError,asyncio.TimeoutError) or at minimum logging the exception type.Session reuse opportunity: This function creates a new aiohttp session at line 235. When called from
process_backlog_leads, an aiohttp session already exists (line 315). Consider whether the session could be passed as a parameter to avoid creating multiple sessions, though this would require refactoring other call sites as well.🔎 Proposed fix for the exception handler
except Exception as e: - logger.error(f"Error sending webhook on no_answer: {e}") + logger.error(f"Error sending webhook on no_answer: {e}", exc_info=True)This at least adds the stack trace to help debug issues while maintaining the same error-handling behavior.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
app/ai/voice/agents/breeze_buddy/managers/calls.pyapp/ai/voice/agents/breeze_buddy/websocket_bot.pyapp/ai/voice/tts/sarvam.py
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-10T11:55:16.753Z
Learnt from: narsimhaReddyJuspay
Repo: juspay/clairvoyance PR: 414
File: app/services/langfuse/tasks/score_monitor/score.py:469-489
Timestamp: 2025-12-10T11:55:16.753Z
Learning: In the Breeze Buddy call tracking system, a lead can only have one outcome type among CONFIRM, CANCEL, or ADDRESS_UPDATED—these outcomes are mutually exclusive per lead.
Applied to files:
app/ai/voice/agents/breeze_buddy/managers/calls.py
🧬 Code graph analysis (1)
app/ai/voice/agents/breeze_buddy/managers/calls.py (3)
app/schemas/breeze_buddy/core.py (2)
LeadCallTracker(34-57)CallExecutionConfig(118-134)app/core/transport/http_client.py (1)
create_aiohttp_session(58-77)app/ai/voice/agents/breeze_buddy/utils/common.py (1)
send_webhook_with_retry(57-99)
🪛 Ruff (0.14.10)
app/ai/voice/agents/breeze_buddy/managers/calls.py
247-247: Do not catch blind exception: Exception
(BLE001)
🔇 Additional comments (2)
app/ai/voice/tts/sarvam.py (1)
7-7: LGTM!Good cleanup removing unused imports while retaining the necessary
Optionaltype.app/ai/voice/agents/breeze_buddy/managers/calls.py (1)
186-188: LGTM!The optional
outcomeparameter is a clean addition that maintains backward compatibility with existing call sites at lines 293, 629 while enabling the new NO_ANSWER webhook behavior at line 664.
| # Send webhook - skip BUSY/NO_ANSWER unless it's the last attempt | ||
| should_send_webhook = self.reporting_webhook_url and ( | ||
| self.outcome not in ["BUSY", "NO_ANSWER"] or is_last_attempt | ||
| self.outcome != "BUSY" or is_last_attempt | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the outdated comment.
The comment states "skip BUSY/NO_ANSWER" but the code only skips BUSY. NO_ANSWER now triggers webhook sending.
🔎 Proposed fix
- # Send webhook - skip BUSY/NO_ANSWER unless it's the last attempt
+ # Send webhook - skip BUSY unless it's the last attempt
should_send_webhook = self.reporting_webhook_url and (
self.outcome != "BUSY" or is_last_attempt
)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # Send webhook - skip BUSY/NO_ANSWER unless it's the last attempt | |
| should_send_webhook = self.reporting_webhook_url and ( | |
| self.outcome not in ["BUSY", "NO_ANSWER"] or is_last_attempt | |
| self.outcome != "BUSY" or is_last_attempt | |
| ) | |
| # Send webhook - skip BUSY unless it's the last attempt | |
| should_send_webhook = self.reporting_webhook_url and ( | |
| self.outcome != "BUSY" or is_last_attempt | |
| ) |
🤖 Prompt for AI Agents
In app/ai/voice/agents/breeze_buddy/websocket_bot.py around lines 628 to 631,
the inline comment is inaccurate ("skip BUSY/NO_ANSWER") while the code only
skips BUSY; update the comment to reflect the actual behavior (e.g., "skip BUSY
unless it's the last attempt") so it no longer mentions NO_ANSWER, keeping the
logic unchanged.
Summary by CodeRabbit
New Features
Improvements
Chores
✏️ Tip: You can customize this high-level summary in your review settings.