* 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 <30310907+CarinaWolli@users.noreply.github.com>
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
// Utility functions for prompt display and restoration
|
|
import { RETELL_AI_TEST_MODE, RETELL_AI_TEST_EVENT_TYPE_MAP } from "@calcom/lib/constants";
|
|
|
|
export const cleanPromptForDisplay = (prompt: string): string => {
|
|
if (!prompt) return prompt;
|
|
|
|
const cleanedPrompt = prompt
|
|
.replace(/check_availability_\{\{eventTypeId\}\}/g, "check_availability")
|
|
.replace(/book_appointment_\{\{eventTypeId\}\}/g, "book_appointment")
|
|
.replace(/check_availability_\d+/g, "check_availability")
|
|
.replace(/book_appointment_\d+/g, "book_appointment");
|
|
|
|
return cleanedPrompt;
|
|
};
|
|
|
|
export const restorePromptComplexity = (prompt: string): string => {
|
|
if (!prompt) return prompt;
|
|
|
|
return prompt
|
|
.replace(/\bcheck_availability\b/g, "check_availability_{{eventTypeId}}")
|
|
.replace(/\bbook_appointment\b/g, "book_appointment_{{eventTypeId}}");
|
|
};
|
|
|
|
/**
|
|
* Replaces event type placeholders in a prompt with the actual event type ID
|
|
* Handles both numeric placeholders (check_availability_123) and template placeholders (check_availability_{{eventTypeId}})
|
|
*/
|
|
export const replaceEventTypePlaceholders = (prompt: string, eventTypeId: number): string => {
|
|
let eventTypeIdToUse = eventTypeId;
|
|
if (RETELL_AI_TEST_MODE && RETELL_AI_TEST_EVENT_TYPE_MAP) {
|
|
const mappedId = RETELL_AI_TEST_EVENT_TYPE_MAP[String(eventTypeId)];
|
|
eventTypeIdToUse = mappedId ? Number(mappedId) : eventTypeId;
|
|
}
|
|
|
|
return prompt
|
|
.replace(/check_availability_\d+/g, `check_availability_${eventTypeIdToUse}`)
|
|
.replace(/book_appointment_\d+/g, `book_appointment_${eventTypeIdToUse}`)
|
|
.replace(/check_availability_\{\{eventTypeId\}\}/g, `check_availability_${eventTypeIdToUse}`)
|
|
.replace(/book_appointment_\{\{eventTypeId\}\}/g, `book_appointment_${eventTypeIdToUse}`);
|
|
};
|