feat: inbound calls in cal ai (#23890)
* feat: lang support * fix: type errors * feat: select voice agent * refactor: address feedback * refactor: address feedback * refactor: missing import * fix: types * feat: add inbound calls * chore: formatting * chore * feat: finish inbound call * chore: formatting * fix: update bug * fix: types * refactor: Agent Configuration Sheet (#23930) * refactor: agent configuration sheet * chore: use default phone numbre * refactor: improvements * refactor: improvements * fix: types * fix: feedback * chore: * fix: feedback * fix: prompt * fix: review * fix: review * refactor: class * refactor: class * refactor: rename * Update apps/web/public/static/locales/en/common.json * Update apps/web/public/static/locales/en/common.json * chore: update set value * fix: remove index * fix: type error * fix: update tetss * fix: use logger * refactor: don't use static * fix: type * fix: schema * refactor: --------- Co-authored-by: Carina Wollendorfer <[email protected]>
This commit is contained in:
1 parent
bec49ef417
commit
aa48e72c12
74 files changed
+2980
-1680
No files matched your search
@@ -3,7 +3,7 @@ import stripe from "@calcom/features/ee/payments/server/stripe";
|
||||
import { PrismaAgentRepository } from "@calcom/lib/server/repository/PrismaAgentRepository";
|
||||
import { PrismaPhoneNumberRepository } from "@calcom/lib/server/repository/PrismaPhoneNumberRepository";
|
||||
import { CreditsRepository } from "@calcom/lib/server/repository/credits";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { PhoneNumberSubscriptionStatus } from "@calcom/prisma/enums";
|
||||
|
||||
import { CHECKOUT_SESSION_TYPES } from "../../constants";
|
||||
@@ -100,7 +100,8 @@ async function handleCalAIPhoneNumberSubscription(
|
||||
throw new HttpCode(400, "Missing agentId for phone number subscription");
|
||||
}
|
||||
|
||||
const agent = await PrismaAgentRepository.findByIdWithUserAccess({
|
||||
const agentRepo = new PrismaAgentRepository(prisma);
|
||||
const agent = await agentRepo.findByIdWithUserAccess({
|
||||
agentId,
|
||||
userId,
|
||||
teamId: teamId ?? undefined,
|
||||
@@ -130,7 +131,8 @@ async function handleCalAIPhoneNumberSubscription(
|
||||
throw new HttpCode(400, "Invalid subscription data");
|
||||
}
|
||||
|
||||
const newNumber = await PrismaPhoneNumberRepository.createPhoneNumber({
|
||||
const phoneNumberRepo = new PrismaPhoneNumberRepository(prisma);
|
||||
const newNumber = await phoneNumberRepo.createPhoneNumber({
|
||||
userId,
|
||||
teamId: teamId ?? undefined,
|
||||
phoneNumber: calAIPhoneNumber.phone_number,
|
||||
@@ -144,7 +146,7 @@ async function handleCalAIPhoneNumberSubscription(
|
||||
try {
|
||||
console.log("Attempting to link agent to phone number:", { agentId, phoneNumberId: newNumber.id });
|
||||
|
||||
const agent = await PrismaAgentRepository.findByIdWithUserAccess({
|
||||
const agent = await agentRepo.findByIdWithUserAccess({
|
||||
agentId,
|
||||
userId,
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { createDefaultAIPhoneServiceProvider } from "@calcom/features/calAIPhone";
|
||||
import { PrismaPhoneNumberRepository } from "@calcom/lib/server/repository/PrismaPhoneNumberRepository";
|
||||
import prisma from "@calcom/prisma";
|
||||
|
||||
import type { LazyModule, SWHMap } from "./__handler";
|
||||
import { HttpCode } from "./__handler";
|
||||
@@ -12,8 +13,9 @@ const STRIPE_TEAM_PRODUCT_ID = process.env.STRIPE_TEAM_PRODUCT_ID || "";
|
||||
|
||||
const stripeWebhookProductHandler = (handlers: Handlers) => async (data: Data) => {
|
||||
const subscription = data.object;
|
||||
const phoneNumberRepo = new PrismaPhoneNumberRepository(prisma);
|
||||
|
||||
const phoneNumber = await PrismaPhoneNumberRepository.findByStripeSubscriptionId({
|
||||
const phoneNumber = await phoneNumberRepo.findByStripeSubscriptionId({
|
||||
stripeSubscriptionId: subscription.id,
|
||||
});
|
||||
|
||||
@@ -62,7 +64,7 @@ const stripeWebhookProductHandler = (handlers: Handlers) => async (data: Data) =
|
||||
|
||||
async function handleCalAIPhoneNumberSubscriptionDeleted(
|
||||
subscription: Data["object"],
|
||||
phoneNumber: NonNullable<Awaited<ReturnType<typeof PrismaPhoneNumberRepository.findByStripeSubscriptionId>>>
|
||||
phoneNumber: NonNullable<Awaited<ReturnType<PrismaPhoneNumberRepository["findByStripeSubscriptionId"]>>>
|
||||
) {
|
||||
if (!subscription.id) {
|
||||
throw new HttpCode(400, "Subscription ID not found");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { PrismaPhoneNumberRepository } from "@calcom/lib/server/repository/PrismaPhoneNumberRepository";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import prisma from "@calcom/prisma";
|
||||
import { PhoneNumberSubscriptionStatus } from "@calcom/prisma/enums";
|
||||
|
||||
import type { SWHMap } from "./__handler";
|
||||
@@ -14,7 +14,8 @@ const handler = async (data: Data) => {
|
||||
throw new HttpCode(400, "Subscription ID not found");
|
||||
}
|
||||
|
||||
const phoneNumber = await PrismaPhoneNumberRepository.findByStripeSubscriptionId({
|
||||
const phoneNumberRepo = new PrismaPhoneNumberRepository(prisma);
|
||||
const phoneNumber = await phoneNumberRepo.findByStripeSubscriptionId({
|
||||
stripeSubscriptionId: subscription.id,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user