The @tixae-labs/web-sdk package enables voice call functionality via WebRTC. It allows you to initialize a voice call session with an agent (identified by agentId and region from your Convocore Dashboard and provides event listeners to track call status.
Below is an example that demonstrates how to initialize the voice call and set up event listeners. (This example is suitable for NextJS 13+ with TypeScript.)
"use client";import React from "react";import { WebCall } from "@tixae-labs/web-sdk";const VoiceCallPage = () => { const [voiceState, setVoiceState] = React.useState<WebCall | null>(null); async function initVoice() { const voice = new WebCall(); console.log("Starting voice call..."); await voice.init({ agentId: "", // Replace with a valid agentId from your Convocore Dashboard URL (e.g., "enit5lczmqbz1s7d") region: "", // Replace with a valid region (e.g., "eu" or "na") }); // Set up event listeners voice.on("call-start", () => { console.log("Call has started..."); }); voice.on("final_transcript", (data) => { console.log("Transcript:", data); }); voice.on("conversation-update", (data) => { console.log("Conversation update:", data); }); voice.on("call-ended", () => { console.log("Call ended"); }); voice.on("error", (data) => { console.error("Call error:", data); }); setVoiceState(voice); } React.useEffect(() => { initVoice(); }, []); return ( <div className="min-h-screen flex justify-center items-center"> <button onClick={() => voiceState?.startCall()}> Start Call </button> <button onClick={() => voiceState?.endCall()}> End Call </button> </div> );};export default VoiceCallPage;
.startCall()You can start a call by invoking the .startCall() function..endCall()You can end a call by invoking the .endCall() function..toggleMute()You can toggle the local microphone on or off during an active call.