refactor: small improvements for cal ai (#23444)

* refactor: small improvements follow up

* fix: add docs
This commit is contained in:
Udit Takkar authored and GitHub committed 2025-08-29 17:42:15 +05:30
1 parent e7779bba0a
commit dd16c2b99d
6 files changed
+47 -23

No files matched your search

@@ -1,10 +1,9 @@
import { v4 as uuidv4 } from "uuid";
import { generateUniqueAPIKey as generateHashedApiKey } from "@calcom/ee/api-keys/lib/apiKeys";
import { timeZoneSchema } from "@calcom/lib/dayjs/timeZone.schema";
import { HttpError } from "@calcom/lib/http-error";
import logger from "@calcom/lib/logger";
import prisma from "@calcom/prisma";
import { PrismaApiKeyRepository } from "@calcom/lib/server/repository/PrismaApiKeyRepository";
import type {
AIPhoneServiceUpdateModelParams,
@@ -27,24 +26,12 @@ export class AgentService {
) {}
private async createApiKey({ userId, teamId }: { userId: number; teamId?: number }) {
const [hashedApiKey, apiKey] = generateHashedApiKey();
await prisma.apiKey.create({
data: {
id: uuidv4(),
userId,
teamId,
// And here we pass a null to expiresAt if never expires is true
expiresAt: null,
hashedKey: hashedApiKey,
note: `Cal AI Phone API Key for agent ${userId} ${teamId ? `for team ${teamId}` : ""}`,
},
return await PrismaApiKeyRepository.createApiKey({
userId,
teamId,
expiresAt: null,
note: `Cal AI Phone API Key for agent ${userId} ${teamId ? `for team ${teamId}` : ""}`,
});
const apiKeyPrefix = process.env.API_KEY_PREFIX ?? "cal_";
const prefixedApiKey = `${apiKeyPrefix}${apiKey}`;
return prefixedApiKey;
}
async getAgent(agentId: string): Promise<AIPhoneServiceAgent<AIPhoneServiceProviderType.RETELL_AI>> {
@@ -934,12 +934,13 @@ export function AgentConfigurationSheet({
{t("learn_how_to_get_your_terminator")}
</p>
</div>
{/*TODO: Create a doc and link to it */}
<Button
type="button"
color="secondary"
size="base"
EndIcon="external-link"
href="https://cal.com/help/importing/import-numbers"
target="_blank"
className="text-emphasis my-auto">
{t("learn")}
</Button>