8000 https://github.com/FoloUp/FoloUp/issues/3 by aditya-qapitol · Pull Request #5 · FoloUp/FoloUp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

https://github.com/FoloUp/FoloUp/issues/3 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to 10000 file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"react-dom": "^18",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.49.0",
"retell-client-js-sdk": "^1.3.3",
"retell-sdk": "^3.12.0",
"retell-client-js-sdk": "^2.0.0",
"retell-sdk": "^4.19.0",
"shadcn-ui": "^0.4.1",
"sharp": "^0.33.2",
"sonner": "^1.4.41",
Expand Down
57 changes: 31 additions & 26 deletions src/components/call/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type registerCallResponseType = {
data: {
registerCallResponse: {
call_id: string;
sample_rate: number;
access_token: string;
};
};
};
Expand Down Expand Up @@ -121,7 +121,7 @@ function Call({ interview }: InterviewProps) {
}
setCurrentTimeDuration(String(Math.floor(time / 100)));
if (Number(currentTimeDuration) == Number(interviewTimeDuration) * 60) {
webClient.stopConversation();
webClient.stopCall();
setIsEnded(true);
}

Expand All @@ -136,36 +136,37 @@ function Call({ interview }: InterviewProps) {
}, [email]);

useEffect(() => {
webClient.on("conversationStarted", () => {
console.log("conversationStarted");
webClient.on("call_started", () => {
console.log("Call started");
setIsCalling(true);
});

webClient.on("audio", (audio: Uint8Array) => {
console.log("There is audio");
});

webClient.on("conversationEnded", ({ code, reason }) => {
console.log("Closed with code:", code, ", reason:", reason);
webClient.on("call_ended", () => {
console.log("Call ended");
setIsCalling(false);
setIsEnded(true);
});

webClient.on("agent_start_talking", () => {
setActiveTurn("agent");
});

webClient.on("agent_stop_talking", () => {
// Optional: Add any logic when agent stops talking
setActiveTurn("user");
});

webClient.on("error", (error) => {
console.error("An error occurred:", error);
setIsCalling(false);
webClient.stopCall();
setIsEnded(true);
setIsCalling(false);
});

webClient.on("update", (update) => {
const roleContents: { [key: string]: string } = {};
if (update.turntaking === "agent_turn") {
setActiveTurn("agent");
} else if (update.turntaking === "user_turn") {
setActiveTurn("user");
}

if (update.transcript) {
const transcripts: transcriptType[] = update.transcript;
const roleContents: { [key: string]: string } = {};

transcripts.forEach((transcript) => {
roleContents[transcript?.role] = transcript?.content;
Expand All @@ -176,12 +177,16 @@ function Call({ interview }: InterviewProps) {
}
//TODO: highlight the newly uttered word in the UI
});
return () => {
// Clean up event listeners
webClient.removeAllListeners();
};
}, []);

const () => {
if (isStarted) {
setLoading(true);
webClient.stopConversation();
webClient.stopCall();
setIsEnded(true);
setLoading(false);
} else {
Expand Down Expand Up @@ -212,13 +217,11 @@ function Call({ interview }: InterviewProps) {
"/api/register-call",
{ dynamic_data: data, interviewer_id: interview?.interviewer_id },
);
if (registerCallResponse.data.registerCallResponse.call_id) {
webClient
.startConversation({
callId: registerCallResponse.data.registerCallResponse.call_id,
sampleRate:
registerCallResponse.data.registerCallResponse.sample_rate,
enableUpdate: true,
if (registerCallResponse.data.registerCallResponse.access_token) {
await webClient
.startCall({
accessToken:
registerCallResponse.data.registerCallResponse.access_token,
})
.catch(console.error);
setIsCalling(true);
Expand All @@ -232,6 +235,8 @@ function Call({ interview }: InterviewProps) {
email: email,
name: name,
});
} else {
console.log("Failed to register call");
}
}

Expand Down
Loading
0