-
Couldn't load subscription status.
- Fork 0
feat: support web calls in webhook #6
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
base: eval-pr-23788-target-1757676792622
Are you sure you want to change the base?
feat: support web calls in webhook #6
Conversation
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.
1 issue found across 2 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="apps/web/app/api/webhooks/retell-ai/route.ts">
<violation number="1" location="apps/web/app/api/webhooks/retell-ai/route.ts:141">
This change introduces two different sources of truth for determining who to bill for a call: `from_number` for phone calls and `agent_id` for web calls. This fragments the billing logic across two different data models and repositories. A more robust architecture would unify this, for example by assigning a consistent billing entity when a call is initiated, rather than deriving it from different properties after the call has ended.
DEV MODE: This violation would have been filtered out by GPT-5.
Reasoning:
• **GPT-5**: Intentional per-call-type lookup (agent_id for web calls, from_number for phone calls) that both resolve to the same billing owner (userId/teamId) and feed a unified chargeCreditsForCall. No conflicting rules introduced; this is an architectural choice without clear negative impact.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| let teamId: number | undefined; | ||
|
|
||
| // Handle web calls vs phone calls | ||
| if (call_type === "web_call" || !from_number) { |
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.
This change introduces two different sources of truth for determining who to bill for a call: from_number for phone calls and agent_id for web calls. This fragments the billing logic across two different data models and repositories. A more robust architecture would unify this, for example by assigning a consistent billing entity when a call is initiated, rather than deriving it from different properties after the call has ended.
DEV MODE: This violation would have been filtered out by GPT-5.
Reasoning:
• GPT-5: Intentional per-call-type lookup (agent_id for web calls, from_number for phone calls) that both resolve to the same billing owner (userId/teamId) and feed a unified chargeCreditsForCall. No conflicting rules introduced; this is an architectural choice without clear negative impact.
Prompt for AI agents
Address the following comment on apps/web/app/api/webhooks/retell-ai/route.ts at line 141:
<comment>This change introduces two different sources of truth for determining who to bill for a call: `from_number` for phone calls and `agent_id` for web calls. This fragments the billing logic across two different data models and repositories. A more robust architecture would unify this, for example by assigning a consistent billing entity when a call is initiated, rather than deriving it from different properties after the call has ended.
DEV MODE: This violation would have been filtered out by GPT-5.
Reasoning:
• **GPT-5**: Intentional per-call-type lookup (agent_id for web calls, from_number for phone calls) that both resolve to the same billing owner (userId/teamId) and feed a unified chargeCreditsForCall. No conflicting rules introduced; this is an architectural choice without clear negative impact.</comment>
<file context>
@@ -124,15 +117,74 @@ async function handleCallAnalyzed(callData: any) {
+ let teamId: number | undefined;
+
+ // Handle web calls vs phone calls
+ if (call_type === "web_call" || !from_number) {
+ if (!agent_id) {
+ log.error(`Web call ${call_id} missing agent_id, cannot charge credits`);
</file context>
[internal] Confidence score: 8/10
[internal] Posted by: System Design Agent
|
This PR is being marked as stale due to inactivity. |
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Summary by cubic
Adds web call support to the Retell webhook. Credits are now charged for web calls by resolving agent_id to the owning user or team when phone data is missing.