camwest
04/06/2024, 4:04 PMexport async function registerCall(
organizationId: number,
interviewGuideId: number,
) {
if (!process.env.RETELL_API_KEY) {
throw new Error("RETELL_API_KEY is not set");
}
const retell = new Retell({
apiKey: process.env.RETELL_API_KEY,
});
const USER_RESEARCHER_AGENT_ID = "5f2353a28871ef689f72ba147b95b56c";
const res = await retell.call.register({
agent_id: USER_RESEARCHER_AGENT_ID,
audio_encoding: "s16le",
sample_rate: 44100,
audio_websocket_protocol: "web",
});
// insert a record into our db using god client
// so we can fetch the call details later
const supabase = getGodClient();
await supabase
.from("interview_calls")
.insert([
{
organization_id: organizationId,
interview_guide_id: interviewGuideId,
retell_call_id: res.call_id,
retell_sample_rate: res.sample_rate,
metadata: {},
},
])
.throwOnError();
return {
data: {
callId: res.call_id,
sampleRate: res.sample_rate,
},
};
}camwest
04/06/2024, 4:06 PM