Scheduling infrastructure for absolutely everyone.
feat: voice and language support in cal.ai (#23865)
Udit Takkar5c700609924a
diff --git a/apps/web/public/icons/sprite.svg b/apps/web/public/icons/sprite.svgindex 805a734f809..182b16ee59d 100644--- a/apps/web/public/icons/sprite.svg+++ b/apps/web/public/icons/sprite.svg@@ -512,6 +512,10 @@<symbol class="lucide lucide-paperclip" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="paperclip"><path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" ></path></symbol>+<symbol class="lucide lucide-pause" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="pause">+ <rect x="14" y="4" width="4" height="16" rx="1" ></rect>+ <rect x="6" y="4" width="4" height="16" rx="1" ></rect>+</symbol><symbol class="lucide lucide-pencil" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="pencil"><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" ></path><path d="m15 5 4 4" ></path>@@ -533,6 +537,9 @@<symbol class="lucide lucide-phone" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="phone"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z" ></path></symbol>+<symbol class="lucide lucide-play" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="play">+ <polygon points="6 3 20 12 6 21 6 3" ></polygon>+</symbol><symbol class="lucide lucide-plus" viewBox="0 0 24 24" fill="inherit" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" id="plus"><path d="M5 12h14" ></path><path d="M12 5v14" ></path>diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.jsonindex 6ab68e9423f..1225495428b 100644--- a/apps/web/public/static/locales/en/common.json+++ b/apps/web/public/static/locales/en/common.json@@ -3704,5 +3704,13 @@"start_from_scratch_description": "Create your own workflow from scratch.","cal_ai_template_title": "Cal.ai template","cal_ai_template_description": "AI agents that book meetings, send reminders, and follow up!",+ "voice": "Voice",+ "select_voice": "Select Voice",+ "select_voice_for_agent": "Select a voice for your agent",+ "choose_a_voice_for_your_agent": "Choose a voice for your agent",+ "trait": "Trait",+ "voice_id": "Voice ID",+ "use_voice": "Use Voice",+ "current_voice": "Current Voice","ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"}diff --git a/packages/features/calAIPhone/interfaces/AIPhoneService.interface.ts b/packages/features/calAIPhone/interfaces/AIPhoneService.interface.tsindex 6a703503ade..8371517361b 100644--- a/packages/features/calAIPhone/interfaces/AIPhoneService.interface.ts+++ b/packages/features/calAIPhone/interfaces/AIPhoneService.interface.ts@@ -96,6 +96,9 @@ export type AIPhoneServiceListCallsResponse<T extends AIPhoneServiceProviderType = AIPhoneServiceProviderType> = AIPhoneServiceProviderTypeMap[T]["ListCallsResponse"];+export type AIPhoneServiceVoice<T extends AIPhoneServiceProviderType = AIPhoneServiceProviderType> =+ AIPhoneServiceProviderTypeMap[T]["Voice"];+export interface AIPhoneServiceDeletion {modelId?: string;agentId?: string;@@ -311,6 +314,7 @@ export interface AIPhoneServiceProvider<T extends AIPhoneServiceProviderType = AbeginMessage?: string | null;generalTools?: AIPhoneServiceTools<T>;voiceId?: string;+ language?: string;}): Promise<{ message: string }>;/**@@ -374,6 +378,11 @@ export interface AIPhoneServiceProvider<T extends AIPhoneServiceProviderType = AstartTimestamp?: { lower_threshold?: number; upper_threshold?: number };};}): Promise<AIPhoneServiceListCallsResponse<T>>;++ /**+ * List available voices+ */+ listVoices(): Promise<AIPhoneServiceVoice<T>[]>;}/**diff --git a/packages/features/calAIPhone/providers/retellAI/RetellAIPhoneServiceProvider.ts b/packages/features/calAIPhone/providers/retellAI/RetellAIPhoneServiceProvider.tsindex 5e280cff82c..a4d513cae5a 100644--- a/packages/features/calAIPhone/providers/retellAI/RetellAIPhoneServiceProvider.ts+++ b/packages/features/calAIPhone/providers/retellAI/RetellAIPhoneServiceProvider.ts@@ -22,7 +22,7 @@ import type { AgentRepositoryInterface } from "../interfaces/AgentRepositoryInteimport type { PhoneNumberRepositoryInterface } from "../interfaces/PhoneNumberRepositoryInterface";import type { TransactionInterface } from "../interfaces/TransactionInterface";import { RetellAIService } from "./RetellAIService";-import type { RetellAIRepository } from "./types";+import type { RetellAIRepository, Language } from "./types";export class RetellAIPhoneServiceProviderimplements AIPhoneServiceProvider<AIPhoneServiceProviderType.RETELL_AI>@@ -243,6 +243,7 @@ export class RetellAIPhoneServiceProviderbeginMessage?: string | null;generalTools?: AIPhoneServiceTools<AIPhoneServiceProviderType.RETELL_AI>;voiceId?: string;+ language?: Language;}): Promise<{ message: string }> {return await this.service.updateAgentConfiguration(params);}@@ -302,4 +303,8 @@ export class RetellAIPhoneServiceProvider}) {return await this.service.listCalls(params);}++ async listVoices() {+ return await this.service.listVoices();+ }}diff --git a/packages/features/calAIPhone/providers/retellAI/RetellAIService.ts b/packages/features/calAIPhone/providers/retellAI/RetellAIService.tsindex 850e59c8f6e..c0e1952775d 100644--- a/packages/features/calAIPhone/providers/retellAI/RetellAIService.ts+++ b/packages/features/calAIPhone/providers/retellAI/RetellAIService.ts@@ -12,6 +12,7 @@ import { AgentService } from "./services/AgentService";import { BillingService } from "./services/BillingService";import { CallService } from "./services/CallService";import { PhoneNumberService } from "./services/PhoneNumberService";+import { VoiceService } from "./services/VoiceService";import type {RetellLLM,RetellCall,@@ -32,6 +33,7 @@ export class RetellAIService {private billingService: BillingService;private callService: CallService;private phoneNumberService: PhoneNumberService;+ private voiceService: VoiceService;constructor(private repository: RetellAIRepository,@@ -49,6 +51,7 @@ export class RetellAIService {phoneNumberRepository,transactionManager);+ this.voiceService = new VoiceService(repository);// Inject RetellAIService reference into CallServicethis.callService.setRetellAIService(this);@@ -171,6 +174,7 @@ export class RetellAIService {beginMessage?: string | null;generalTools?: RetellLLMGeneralTools;voiceId?: string;+ language?: Language;}) {return this.agentService.updateAgentConfiguration({...params,@@ -254,4 +258,8 @@ export class RetellAIService {}) {return this.callService.listCalls(params);}++ async listVoices() {+ return this.voiceService.listVoices();+ }}diff --git a/packages/features/calAIPhone/providers/retellAI/RetellSDKClient.ts b/packages/features/calAIPhone/providers/retellAI/RetellSDKClient.tsindex 89b3234e98b..3bc5eb7282e 100644--- a/packages/features/calAIPhone/providers/retellAI/RetellSDKClient.ts+++ b/packages/features/calAIPhone/providers/retellAI/RetellSDKClient.ts@@ -16,6 +16,7 @@ import type {ImportPhoneNumberParams,RetellCallListParams,RetellCallListResponse,+ RetellVoice,} from "./types";const RETELL_API_KEY = process.env.RETELL_AI_KEY;@@ -270,4 +271,16 @@ export class RetellSDKClient implements RetellAIRepository {throw error;}}++ async listVoices(): Promise<RetellVoice[]> {++ try {+ const response = await this.client.voice.list();++ return response;+ } catch (error) {+ this.logger.error("Failed to list voices", { error });+ throw error;+ }+ }}diff --git a/packages/features/calAIPhone/providers/retellAI/index.ts b/packages/features/calAIPhone/providers/retellAI/index.tsindex 139280b91ce..c08deecd183 100644--- a/packages/features/calAIPhone/providers/retellAI/index.ts+++ b/packages/features/calAIPhone/providers/retellAI/index.ts@@ -21,6 +21,7 @@ import type {RetellDynamicVariables,RetellCallListParams,RetellCallListResponse,+ RetellVoice,} from "./types";export { RetellAIService } from "./RetellAIService";@@ -30,6 +31,7 @@ export { AgentService } from "./services/AgentService";export { BillingService } from "./services/BillingService";export { CallService } from "./services/CallService";export { PhoneNumberService } from "./services/PhoneNumberService";+export { VoiceService } from "./services/VoiceService";export { RetellAIPhoneServiceProvider } from "./RetellAIPhoneServiceProvider";export { RetellAIPhoneServiceProviderFactory } from "./RetellAIPhoneServiceProviderFactory";@@ -65,6 +67,7 @@ export type {RetellDynamicVariables,RetellCallListParams,RetellCallListResponse,+ RetellVoice,};export interface RetellAIPhoneServiceProviderTypeMap {@@ -83,6 +86,7 @@ export interface RetellAIPhoneServiceProviderTypeMap {AgentWithDetails: RetellAgentWithDetails;ListCallsParams: RetellCallListParams;ListCallsResponse: RetellCallListResponse;+ Voice: RetellVoice;}// ===== USAGE EXAMPLES =====diff --git a/packages/features/calAIPhone/providers/retellAI/services/AgentService.ts b/packages/features/calAIPhone/providers/retellAI/services/AgentService.tsindex 666c326f64d..6c867c9c56a 100644--- a/packages/features/calAIPhone/providers/retellAI/services/AgentService.ts+++ b/packages/features/calAIPhone/providers/retellAI/services/AgentService.ts@@ -507,6 +507,7 @@ export class AgentService {beginMessage,generalTools,voiceId,+ language,updateLLMConfiguration,}: {id: string;@@ -517,6 +518,7 @@ export class AgentService {beginMessage?: string | null;generalTools?: AIPhoneServiceTools<AIPhoneServiceProviderType.RETELL_AI>;voiceId?: string;+ language?: Language;updateLLMConfiguration: (llmId: string,data: AIPhoneServiceUpdateModelParams<AIPhoneServiceProviderType.RETELL_AI>@@ -539,7 +541,8 @@ export class AgentService {generalPrompt !== undefined ||beginMessage !== undefined ||generalTools !== undefined ||- voiceId !== undefined;+ voiceId !== undefined ||+ language !== undefined;if (hasRetellUpdates) {try {@@ -558,10 +561,11 @@ export class AgentService {await updateLLMConfiguration(llmId, llmUpdateData);}- if (voiceId) {- await this.updateAgent(agent.providerAgentId, {- voice_id: voiceId,- });+ if (voiceId || language) {+ const agentUpdateData: Parameters<typeof this.updateAgent>[1] = {};+ if (voiceId) agentUpdateData.voice_id = voiceId;+ if (language) agentUpdateData.language = language;+ await this.updateAgent(agent.providerAgentId, agentUpdateData);}} catch (error) {this.logger.error("Failed to update agent configuration in external AI service", {diff --git a/packages/features/calAIPhone/providers/retellAI/services/VoiceService.ts b/packages/features/calAIPhone/providers/retellAI/services/VoiceService.tsnew file mode 100644index 00000000000..d96aa71e15a--- /dev/null+++ b/packages/features/calAIPhone/providers/retellAI/services/VoiceService.ts@@ -0,0 +1,30 @@+import { HttpError } from "@calcom/lib/http-error";+import logger from "@calcom/lib/logger";++import type { RetellAIRepository, RetellVoice } from "../types";++export class VoiceService {+ private logger = logger.getSubLogger({ prefix: ["VoiceService"] });++ constructor(private retellRepository: RetellAIRepository) {}++ async listVoices(): Promise<RetellVoice[]> {+ try {+ const voices = await this.retellRepository.listVoices();++ this.logger.info("Retrieved voices successfully", {+ count: voices.length,+ });++ return voices;+ } catch (error) {+ this.logger.error("Failed to list voices from external AI service", {+ error,+ });+ throw new HttpError({+ statusCode: 500,+ message: "Failed to retrieve available voices. Please try again.",+ });+ }+ }+}\ No newline at end of filediff --git a/packages/features/calAIPhone/providers/retellAI/types.ts b/packages/features/calAIPhone/providers/retellAI/types.tsindex 4ff785c4b9f..67ee01fac5d 100644--- a/packages/features/calAIPhone/providers/retellAI/types.ts+++ b/packages/features/calAIPhone/providers/retellAI/types.ts@@ -6,6 +6,7 @@ export type RetellLLM = Retell.LlmResponse;export type RetellPhoneNumber = Retell.PhoneNumberResponse;export type RetellCall = Retell.PhoneCallResponse;export type RetellDynamicVariables = { [key: string]: unknown };+export type RetellVoice = Retell.VoiceResponse;export type RetellAgent = Retell.AgentResponse;@@ -186,4 +187,7 @@ export interface RetellAIRepository {createWebCall(data: CreateWebCallParams): Promise<{ call_id: string; access_token: string; agent_id: string }>;++ // Voice operations+ listVoices(): Promise<RetellVoice[]>;}diff --git a/packages/features/ee/workflows/components/AgentConfigurationSheet.tsx b/packages/features/ee/workflows/components/AgentConfigurationSheet.tsxindex 5d1101bbb1c..41b35a4a4f7 100644--- a/packages/features/ee/workflows/components/AgentConfigurationSheet.tsx+++ b/packages/features/ee/workflows/components/AgentConfigurationSheet.tsx@@ -6,6 +6,7 @@ import type { UseFormReturn } from "react-hook-form";import { z } from "zod";import { Dialog } from "@calcom/features/components/controlled-dialog";+import type { Language } from "@calcom/features/calAIPhone/providers/retellAI/types";import { CAL_AI_PHONE_NUMBER_MONTHLY_PRICE } from "@calcom/lib/constants";import { formatPhoneNumber } from "@calcom/lib/formatPhoneNumber";import { useLocale } from "@calcom/lib/hooks/useLocale";@@ -27,7 +28,7 @@ import {} from "@calcom/ui/components/dropdown";import { AddVariablesDropdown } from "@calcom/ui/components/editor";import { ToggleGroup, Switch } from "@calcom/ui/components/form";-import { Label, TextArea, Input, TextField, Form } from "@calcom/ui/components/form";+import { Label, TextArea, Input, TextField, Form, Select } from "@calcom/ui/components/form";import { Icon } from "@calcom/ui/components/icon";import {Sheet,@@ -43,6 +44,7 @@ import { Tooltip } from "@calcom/ui/components/tooltip";import { DYNAMIC_TEXT_VARIABLES } from "../lib/constants";import type { FormValues } from "../pages/workflow";import { TestPhoneCallDialog } from "./TestPhoneCallDialog";+import { VoiceSelectionDialog } from "./VoiceSelectionDialog";import { WebCallDialog } from "./WebCallDialog";// Utility functions for prompt display@@ -68,10 +70,52 @@ const restorePromptComplexity = (prompt: string): string => {return restoredPrompt;};+// Language options for the dropdown+const LANGUAGE_OPTIONS = [+ { value: "en-US", label: "English (US)" },+ { value: "en-IN", label: "English (India)" },+ { value: "en-GB", label: "English (UK)" },+ { value: "en-AU", label: "English (Australia)" },+ { value: "en-NZ", label: "English (New Zealand)" },+ { value: "de-DE", label: "German" },+ { value: "es-ES", label: "Spanish (Spain)" },+ { value: "es-419", label: "Spanish (Latin America)" },+ { value: "hi-IN", label: "Hindi" },+ { value: "fr-FR", label: "French (France)" },+ { value: "fr-CA", label: "French (Canada)" },+ { value: "ja-JP", label: "Japanese" },+ { value: "pt-PT", label: "Portuguese (Portugal)" },+ { value: "pt-BR", label: "Portuguese (Brazil)" },+ { value: "zh-CN", label: "Chinese (Simplified)" },+ { value: "ru-RU", label: "Russian" },+ { value: "it-IT", label: "Italian" },+ { value: "ko-KR", label: "Korean" },+ { value: "nl-NL", label: "Dutch (Netherlands)" },+ { value: "nl-BE", label: "Dutch (Belgium)" },+ { value: "pl-PL", label: "Polish" },+ { value: "tr-TR", label: "Turkish" },+ { value: "th-TH", label: "Thai" },+ { value: "vi-VN", label: "Vietnamese" },+ { value: "ro-RO", label: "Romanian" },+ { value: "bg-BG", label: "Bulgarian" },+ { value: "ca-ES", label: "Catalan" },+ { value: "da-DK", label: "Danish" },+ { value: "fi-FI", label: "Finnish" },+ { value: "el-GR", label: "Greek" },+ { value: "hu-HU", label: "Hungarian" },+ { value: "id-ID", label: "Indonesian" },+ { value: "no-NO", label: "Norwegian" },+ { value: "sk-SK", label: "Slovak" },+ { value: "sv-SE", label: "Swedish" },+ { value: "multi", label: "Multilingual" },+];+const agentSchema = z.object({generalPrompt: z.string().min(1, "General prompt is required"),beginMessage: z.string().min(1, "Begin message is required"),numberToCall: z.string().optional(),+ language: z.string().optional(),+ voiceId: z.string().optional(),generalTools: z.array(z.object({@@ -145,6 +189,7 @@ export function AgentConfigurationSheet({const [showAdvancedFields, setShowAdvancedFields] = useState(false);const [isTestAgentDialogOpen, setIsTestAgentDialogOpen] = useState(false);const [isWebCallDialogOpen, setIsWebCallDialogOpen] = useState(false);+ const [isVoiceDialogOpen, setIsVoiceDialogOpen] = useState(false);const [cancellingNumberId, setCancellingNumberId] = useState<number | null>(null);const [numberToDelete, setNumberToDelete] = useState<string | null>(null);// const [toolDialogOpen, setToolDialogOpen] = useState(false);@@ -159,6 +204,8 @@ export function AgentConfigurationSheet({generalPrompt: "",beginMessage: "",numberToCall: "",+ language: "en-US",+ voiceId: "",generalTools: [],},});@@ -170,6 +217,8 @@ export function AgentConfigurationSheet({generalPrompt: cleanPromptForDisplay(retellData.generalPrompt || ""),beginMessage: retellData.beginMessage || "",numberToCall: "",+ language: retellData.language || "en-US",+ voiceId: retellData.voiceId || "",generalTools: retellData.generalTools || [],});}@@ -289,6 +338,8 @@ export function AgentConfigurationSheet({const updatePayload = {generalPrompt: restorePromptComplexity(data.generalPrompt),beginMessage: data.beginMessage,+ language: data.language as Language,+ voiceId: data.voiceId,// Don't include generalTools - they are managed by the backend};@@ -434,6 +485,43 @@ export function AgentConfigurationSheet({<SheetBody className="px-0">{activeTab === "prompt" && (<div className="space-y-4">+ <div>+ <Label className="text-emphasis mb-1 block text-sm font-medium">+ {t("language")}+ </Label>+ <Controller+ name="language"+ control={agentForm.control}+ render={({ field }) => (+ <Select+ value={LANGUAGE_OPTIONS.find((option) => option.value === field.value)}+ onChange={(option) => field.onChange(option?.value)}+ options={LANGUAGE_OPTIONS}+ isDisabled={readOnly}+ className="mb-4"+ />+ )}+ />+ </div>+ <div>+ <Label className="text-emphasis mb-1 block text-sm font-medium">+ {t("voice")}+ </Label>+ <p className="text-subtle mb-1.5 text-xs">{t("select_voice_for_agent")}</p>+ <Button+ type="button"+ color="secondary"+ onClick={() => setIsVoiceDialogOpen(true)}+ disabled={readOnly}+ className="w-full justify-start">+ <Icon name="user" className="mr-2 h-4 w-4" />+ {agentForm.watch("voiceId") ? (+ <span className="font-mono text-sm">{agentForm.watch("voiceId")}</span>+ ) : (+ t("select_voice")+ )}+ </Button>+ </div><div><Label className="text-emphasis mb-1 block text-sm font-medium">{t("initial_message")} *@@ -1044,6 +1132,15 @@ export function AgentConfigurationSheet({/>)}+ <VoiceSelectionDialog+ open={isVoiceDialogOpen}+ onOpenChange={setIsVoiceDialogOpen}+ selectedVoiceId={agentForm.watch("voiceId")}+ onVoiceSelect={(voiceId) => {+ agentForm.setValue("voiceId", voiceId, { shouldDirty: true });+ }}+ />+<UIDialog open={cancellingNumberId !== null} onOpenChange={() => setCancellingNumberId(null)}><ConfirmationDialogContentisPending={cancelSubscriptionMutation.isPending}diff --git a/packages/features/ee/workflows/components/VoiceSelectionDialog.tsx b/packages/features/ee/workflows/components/VoiceSelectionDialog.tsxnew file mode 100644index 00000000000..687781541a8--- /dev/null+++ b/packages/features/ee/workflows/components/VoiceSelectionDialog.tsx@@ -0,0 +1,217 @@+import { getCoreRowModel, getSortedRowModel, useReactTable, type ColumnDef } from "@tanstack/react-table";+import { useMemo, useState } from "react";++import {+ DataTableProvider,+ DataTableWrapper,+ DataTableToolbar,+ DataTableFilters,+ useDataTable,+} from "@calcom/features/data-table";+import { useSegments } from "@calcom/features/data-table/hooks/useSegments";+import { useLocale } from "@calcom/lib/hooks/useLocale";+import { trpc } from "@calcom/trpc/react";+import { Button } from "@calcom/ui/components/button";+import { Dialog, DialogContent, DialogHeader } from "@calcom/ui/components/dialog";+import { Icon } from "@calcom/ui/components/icon";+import { showToast } from "@calcom/ui/components/toast";++import { useVoicePreview } from "../hooks/useVoicePreview";++type Voice = {+ voice_id: string;+ voice_name: string;+ provider: 'elevenlabs' | 'openai' | 'deepgram';+ gender: 'male' | 'female';+ accent?: string;+ age?: string;+ preview_audio_url?: string;+};++type VoiceSelectionDialogProps = {+ open: boolean;+ onOpenChange: (open: boolean) => void;+ selectedVoiceId?: string;+ onVoiceSelect: (voiceId: string) => void;+};++function VoiceSelectionTable({ selectedVoiceId, onVoiceSelect }: { selectedVoiceId?: string; onVoiceSelect: (voiceId: string) => void }) {+ return (+ <DataTableProvider useSegments={useSegments} defaultPageSize={1000}>+ <VoiceSelectionContent selectedVoiceId={selectedVoiceId} onVoiceSelect={onVoiceSelect} />+ </DataTableProvider>+ );+}++function VoiceSelectionContent({ selectedVoiceId, onVoiceSelect }: { selectedVoiceId?: string; onVoiceSelect: (voiceId: string) => void }) {+ const { t } = useLocale();+ const { playingVoiceId, handlePlayVoice } = useVoicePreview();+ const [rowSelection, setRowSelection] = useState({});++ const { data: voices, isLoading } = trpc.viewer.aiVoiceAgent.listVoices.useQuery();+++ const handleUseVoice = (voiceId: string) => {+ onVoiceSelect(voiceId);+ showToast("Voice selected successfully", "success");+ };++ const voiceData: Voice[] = useMemo(() => {+ if (!voices) return [];+ return voices;+ }, [voices]);++ const columns = useMemo<ColumnDef<Voice>[]>(+ () => [+ {+ id: "voice",+ accessorKey: "voice_name",+ header: t("voice"),+ size: 200,+ cell: ({ row }) => (+ <div className="flex items-center gap-3">+ <Button+ type="button"+ variant="icon"+ color="secondary"+ size="sm"+ onClick={() => handlePlayVoice(row.original.preview_audio_url, row.original.voice_id)}+ className="rounded-full">+ {playingVoiceId === row.original.voice_id ? (+ <Icon name="pause" className="h-3 w-3 text-default" />+ ) : (+ <Icon name="play" className="h-3 w-3 text-default" />+ )}+ </Button>+ <div className="flex items-center gap-2">+ <div className="w-10 h-10 bg-subtle rounded-full flex items-center justify-center">+ <Icon name="user" className="h-5 w-5 text-default" />+ </div>+ <span className="font-medium text-emphasis">{row.original.voice_name}</span>+ </div>+ </div>+ ),+ },+ {+ id: "trait",+ accessorKey: "accent",+ header: t("trait"),+ size: 200,+ cell: ({ row }) => (+ <div className="flex gap-2 text-sm">+ {row.original.accent && (+ <span className="px-2 py-1 bg-subtle text-default rounded-md text-xs">+ {row.original.accent}+ </span>+ )}+ {row.original.gender && (+ <span className="px-2 py-1 bg-subtle text-default rounded-md text-xs">+ {row.original.gender}+ </span>+ )}+ {row.original.provider && (+ <span className="px-2 py-1 bg-subtle text-default rounded-md text-xs">+ {row.original.provider}+ </span>+ )}+ {row.original.age && (+ <span className="px-2 py-1 bg-subtle text-default rounded-md text-xs">+ {row.original.age}+ </span>+ )}+ </div>+ ),+ },+ {+ id: "voice_id",+ accessorKey: "voice_id",+ header: t("voice_id"),+ size: 200,+ cell: ({ row }) => (+ <span className="text-sm text-muted font-mono">{row.original.voice_id}</span>+ ),+ },+ {+ id: "actions",+ header: "",+ size: 120,+ cell: ({ row }) => (+ <Button+ type="button"+ size="sm"+ color={selectedVoiceId === row.original.voice_id ? "primary" : "secondary"}+ onClick={() => handleUseVoice(row.original.voice_id)}+ className="whitespace-nowrap">+ {selectedVoiceId === row.original.voice_id ? (+ <>+ {t("current_voice")}+ </>+ ) : (+ t("use_voice")+ )}+ </Button>+ ),+ },+ ],+ [t, playingVoiceId, selectedVoiceId]+ );++ const table = useReactTable({+ data: voiceData,+ columns,+ enableRowSelection: false,+ manualPagination: false,+ state: {+ rowSelection,+ },+ getCoreRowModel: getCoreRowModel(),+ getSortedRowModel: getSortedRowModel(),+ onRowSelectionChange: setRowSelection,+ getRowId: (row) => row.voice_id,+ });++ return (+ <div className="max-h-[500px] overflow-auto border border-subtle rounded-lg">+ <DataTableWrapper<Voice>+ testId="voice-selection-data-table"+ table={table}+ isPending={isLoading}+ totalRowCount={voiceData?.length || 0}+ paginationMode="standard"+ className="h-auto"+ />+ </div>+ );+}++export function VoiceSelectionDialog({+ open,+ onOpenChange,+ selectedVoiceId,+ onVoiceSelect,+}: VoiceSelectionDialogProps) {+ const { t } = useLocale();++ const handleVoiceSelect = (voiceId: string) => {+ onVoiceSelect(voiceId);+ onOpenChange(false);+ };++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent enableOverflow className="sm:max-w-7xl h-[80vh] flex flex-col p-6">+ <DialogHeader+ title={t("select_voice")}+ subtitle={t("choose_a_voice_for_your_agent")}+ />++ <div className="flex-1 overflow-hidden min-h-0 mt-4">+ <VoiceSelectionTable+ selectedVoiceId={selectedVoiceId}+ onVoiceSelect={handleVoiceSelect}+ />+ </div>+ </DialogContent>+ </Dialog>+ );+}diff --git a/packages/features/ee/workflows/components/WebCallDialog.tsx b/packages/features/ee/workflows/components/WebCallDialog.tsxindex 00614fe2f49..cffb1a51c31 100644--- a/packages/features/ee/workflows/components/WebCallDialog.tsx+++ b/packages/features/ee/workflows/components/WebCallDialog.tsx@@ -454,7 +454,8 @@ export function WebCallDialog({type="button"onClick={handleStartCall}loading={createWebCallMutation.isPending || callStatus === "connecting"}- disabled={!hasCredits || createWebCallMutation.isPending || callStatus === "connecting"}>+ disabled={!hasCredits || createWebCallMutation.isPending || callStatus === "connecting"}+ ><Icon name="phone" className="mr-2 h-4 w-4" />{callStatus === "connecting" ? t("connecting") : t("start_web_call")}</Button>diff --git a/packages/features/ee/workflows/hooks/useVoicePreview.ts b/packages/features/ee/workflows/hooks/useVoicePreview.tsnew file mode 100644index 00000000000..6cf66ddc612--- /dev/null+++ b/packages/features/ee/workflows/hooks/useVoicePreview.ts@@ -0,0 +1,78 @@+import { useState, useEffect, useRef } from "react";++import { showToast } from "@calcom/ui/components/toast";++export function useVoicePreview() {+ const [playingVoiceId, setPlayingVoiceId] = useState<string | null>(null);+ const [currentAudio, setCurrentAudio] = useState<HTMLAudioElement | null>(null);+ const audioRef = useRef<HTMLAudioElement | null>(null);++ const stopCurrentAudio = () => {+ if (currentAudio) {+ currentAudio.pause();+ currentAudio.currentTime = 0;+ setCurrentAudio(null);+ audioRef.current = null;+ }+ setPlayingVoiceId(null);+ };++ const handlePlayVoice = (previewUrl?: string, voiceId?: string) => {+ if (!previewUrl) {+ showToast("Preview not available for this voice", "error");+ return;+ }++ if (playingVoiceId === voiceId) {+ stopCurrentAudio();+ return;+ }++ stopCurrentAudio();++ const audio = new Audio(previewUrl);++ audio.onended = () => {+ setPlayingVoiceId(null);+ setCurrentAudio(null);+ audioRef.current = null;+ };++ audio.onerror = () => {+ setPlayingVoiceId(null);+ setCurrentAudio(null);+ audioRef.current = null;+ showToast("Failed to play voice preview", "error");+ };++ setCurrentAudio(audio);+ audioRef.current = audio;++ audio.play()+ .then(() => {+ setPlayingVoiceId(voiceId || null);+ })+ .catch(() => {+ setPlayingVoiceId(null);+ setCurrentAudio(null);+ audioRef.current = null;+ showToast("Failed to play voice preview", "error");+ });+ };++ useEffect(() => {+ return () => {+ if (audioRef.current) {+ audioRef.current.pause();+ audioRef.current.currentTime = 0;+ audioRef.current = null;+ }+ };+ }, []);++ return {+ playingVoiceId,+ handlePlayVoice,+ stopCurrentAudio,+ };+}diff --git a/packages/trpc/server/routers/viewer/aiVoiceAgent/_router.ts b/packages/trpc/server/routers/viewer/aiVoiceAgent/_router.tsindex f5fb8732762..de4536f1c21 100644--- a/packages/trpc/server/routers/viewer/aiVoiceAgent/_router.ts+++ b/packages/trpc/server/routers/viewer/aiVoiceAgent/_router.ts@@ -82,4 +82,12 @@ export const aiVoiceAgentRouter = router({input,});}),++ listVoices: authedProcedure.query(async ({ ctx }) => {+ const { listVoicesHandler } = await import("./listVoices.handler");++ return listVoicesHandler({+ ctx,+ });+ }),});diff --git a/packages/trpc/server/routers/viewer/aiVoiceAgent/listVoices.handler.ts b/packages/trpc/server/routers/viewer/aiVoiceAgent/listVoices.handler.tsnew file mode 100644index 00000000000..bf457d89e6d--- /dev/null+++ b/packages/trpc/server/routers/viewer/aiVoiceAgent/listVoices.handler.ts@@ -0,0 +1,15 @@+import { createDefaultAIPhoneServiceProvider } from "@calcom/features/calAIPhone";++import type { TrpcSessionUser } from "../../../types";++type ListVoicesHandlerOptions = {+ ctx: {+ user: NonNullable<TrpcSessionUser>;+ };+};++export const listVoicesHandler = async ({ ctx }: ListVoicesHandlerOptions) => {+ const aiService = createDefaultAIPhoneServiceProvider();++ return await aiService.listVoices();+};\ No newline at end of filediff --git a/packages/trpc/server/routers/viewer/aiVoiceAgent/update.handler.ts b/packages/trpc/server/routers/viewer/aiVoiceAgent/update.handler.tsindex 5da6dc701d1..79e51ceb1da 100644--- a/packages/trpc/server/routers/viewer/aiVoiceAgent/update.handler.ts+++ b/packages/trpc/server/routers/viewer/aiVoiceAgent/update.handler.ts@@ -25,5 +25,6 @@ export const updateHandler = async ({ ctx, input }: UpdateHandlerOptions) => {beginMessage: retellUpdates.beginMessage ?? undefined,generalTools: retellUpdates.generalTools as RetellLLMGeneralTools,voiceId: retellUpdates.voiceId,+ language: retellUpdates.language,});};diff --git a/packages/trpc/server/routers/viewer/aiVoiceAgent/update.schema.ts b/packages/trpc/server/routers/viewer/aiVoiceAgent/update.schema.tsindex c61b1dac52e..b458bd099c7 100644--- a/packages/trpc/server/routers/viewer/aiVoiceAgent/update.schema.ts+++ b/packages/trpc/server/routers/viewer/aiVoiceAgent/update.schema.ts@@ -1,5 +1,46 @@import { z } from "zod";+import type { Language } from "@calcom/features/calAIPhone/providers/retellAI/types";++const languageSchema = z.enum([+ "en-US",+ "en-IN",+ "en-GB",+ "en-AU",+ "en-NZ",+ "de-DE",+ "es-ES",+ "es-419",+ "hi-IN",+ "fr-FR",+ "fr-CA",+ "ja-JP",+ "pt-PT",+ "pt-BR",+ "zh-CN",+ "ru-RU",+ "it-IT",+ "ko-KR",+ "nl-NL",+ "nl-BE",+ "pl-PL",+ "tr-TR",+ "th-TH",+ "vi-VN",+ "ro-RO",+ "bg-BG",+ "ca-ES",+ "da-DK",+ "fi-FI",+ "el-GR",+ "hu-HU",+ "id-ID",+ "no-NO",+ "sk-SK",+ "sv-SE",+ "multi",+]) satisfies z.ZodType<Language>;+export const ZUpdateInputSchema = z.object({id: z.string(),teamId: z.number().optional(),@@ -20,6 +61,7 @@ export const ZUpdateInputSchema = z.object({).optional(),voiceId: z.string().optional(),+ language: languageSchema.optional(),});export type TUpdateInputSchema = z.infer<typeof ZUpdateInputSchema>;diff --git a/packages/ui/components/icon/icon-list.mjs b/packages/ui/components/icon/icon-list.mjsindex dc62ed30fb9..3b277ceeefe 100644--- a/packages/ui/components/icon/icon-list.mjs+++ b/packages/ui/components/icon/icon-list.mjs@@ -98,10 +98,12 @@ export const lucideIconList = new Set(["moon","paintbrush","paperclip",+ "pause","pencil","phone-call","phone-outgoing","phone",+ "play","plus","refresh-ccw","refresh-cw",diff --git a/packages/ui/components/icon/icon-names.ts b/packages/ui/components/icon/icon-names.tsindex d079436a493..82e916fc4e5 100644--- a/packages/ui/components/icon/icon-names.ts+++ b/packages/ui/components/icon/icon-names.ts@@ -105,11 +105,13 @@ export type IconName =| "moon"| "paintbrush"| "paperclip"+ | "pause"| "pencil"| "phone-call"| "phone-off"| "phone-outgoing"| "phone"+ | "play"| "plus"| "refresh-ccw"| "refresh-cw"