-
Couldn't load subscription status.
- Fork 0
feat: support web calls in webhook #4
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-1757676529905
Are you sure you want to change the base?
feat: support web calls in webhook #4
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.
2 issues found across 2 files
Prompt for AI agents (all 2 issues)
Understand the root cause of the following 2 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:65">
The `callCost` parameter, derived from Retell AI's `combined_cost`, is passed to the `chargeCreditsForCall` function but is never used. The function instead recalculates the cost based on call duration and a local rate, which can lead to billing discrepancies and makes the code's intent unclear.</violation>
<violation number="2" location="apps/web/app/api/webhooks/retell-ai/route.ts:147">
The handler for web calls correctly finds the agent associated with a call via `agent_id`, but it fails to check if the agent is enabled before charging credits. This creates a risk of billing for calls made through agents that have been disabled in the system.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
| return; | ||
| } | ||
|
|
||
| const agent = await PrismaAgentRepository.findByProviderAgentId({ |
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.
The handler for web calls correctly finds the agent associated with a call via agent_id, but it fails to check if the agent is enabled before charging credits. This creates a risk of billing for calls made through agents that have been disabled in the system.
Prompt for AI agents
Address the following comment on apps/web/app/api/webhooks/retell-ai/route.ts at line 147:
<comment>The handler for web calls correctly finds the agent associated with a call via `agent_id`, but it fails to check if the agent is enabled before charging credits. This creates a risk of billing for calls made through agents that have been disabled in the system.</comment>
<file context>
@@ -124,15 +117,74 @@ async function handleCallAnalyzed(callData: any) {
+ return;
+ }
+
+ const agent = await PrismaAgentRepository.findByProviderAgentId({
+ providerAgentId: agent_id,
+ });
</file context>
[internal] Confidence score: 10/10
[internal] Posted by: System Design Agent
| return; | ||
| } | ||
|
|
||
| async function chargeCreditsForCall({ |
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.
The callCost parameter, derived from Retell AI's combined_cost, is passed to the chargeCreditsForCall function but is never used. The function instead recalculates the cost based on call duration and a local rate, which can lead to billing discrepancies and makes the code's intent unclear.
Prompt for AI agents
Address the following comment on apps/web/app/api/webhooks/retell-ai/route.ts at line 65:
<comment>The `callCost` parameter, derived from Retell AI's `combined_cost`, is passed to the `chargeCreditsForCall` function but is never used. The function instead recalculates the cost based on call duration and a local rate, which can lead to billing discrepancies and makes the code's intent unclear.</comment>
<file context>
@@ -59,44 +62,27 @@ const RetellWebhookSchema = z.object({
- return;
- }
-
+async function chargeCreditsForCall({
+ userId,
+ teamId,
</file context>
[internal] Confidence score: 9/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 support for Retell web calls in the webhook. Web calls are now billed by resolving the agent to a user/team instead of relying on phone numbers.
New Features
Refactors