Giter Site home page Giter Site logo

retell-client-js-sdk's Introduction

retell-client-js-sdk's People

Contributors

anne-ribbon avatar austinzzx avatar spikecodes avatar weijia-yu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

retell-client-js-sdk's Issues

Client SDK doesn't work on mobile networks

When using the latest version of the library that uses RTC I'm noticing that phones running on mobile networks (specifically I'm testing with Verizon) are unable to connect but are able to connect when on WiFi. I believe this is likely do to SSL / TURN not being setup correctly with the newer LiveKit dependency...

Check out the documentation: https://docs.livekit.io/home/self-hosting/deployment/

Elsewhere I see documenation states that this can cause issues with mobile networks when not setup correctly.

The socket connection closes after some time

My socket connection closes after some time, for a reason unknown to me. I used your client-js-sdk and the example in the demo repository

const webClient = new RetellWebClient();

export default function Home() {
    const [ callActive, setCallActive ] = useState<boolean>(false);

    useEffect(() => {
        // Setup event listeners
        webClient.on("conversationStarted", () => {
            console.log("conversationStarted");
        });

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

        webClient.on("conversationEnded", ({ code, reason }) => {
            console.log("Closed with code:", code, ", reason:", reason);
            setCallActive(false); // Update button to "Start" when conversation ends
        });

        webClient.on("error", (error) => {
            console.error("An error occurred:", error);
            setCallActive(false); // Update button to "Start" in case of error
        });

        webClient.on("update", (update) => {
            // Print live transcript as needed
            console.log("update", update);
        });
    }, []);

    const toggleConversation = async () => {
        if (callActive) {
            webClient.stopConversation();
        } else {
            const registerCallResponse = await registerCall();
            if (registerCallResponse.call_id) {
                webClient
                    .startConversation({
                        callId: registerCallResponse.call_id,
                        sampleRate: 24000,
                        enableUpdate: true,
                    })
                    .catch(console.error);
                setCallActive(true); // Update button to "Stop" when conversation starts
            }
        }
    };

    const registerCall = async (): Promise<{ call_id: string }> => {

        const res = await axios.post<{ call_id: string }>("http://my-server.com/api/v1/calls/register-call/", {
            audio_encoding: "s16le",
            audio_websocket_protocol: "web",
            sample_rate: 24000
        });

        return res.data;
   }
   ...
}
image image

[Bug] unable to stop conversation using sdk.stopConversation()

Using this code from the sample demo.
const toggleConversation = async () => {
if (isCalling) {
console.log("stopping conversation")
try {
webClient.stopConversation();
} catch (err) {
console.log(err);
// throw new Error(err);
}
} else {
const registerCallResponse = await registerCall(agentId);
console.log(registerCallResponse)
if (registerCallResponse.call_id) {
console.log("starting conversation")
webClient
.startConversation({
callId: registerCallResponse.call_id,
sampleRate: registerCallResponse.sample_rate,
enableUpdate: true,
})
.catch(console.error);
setIsCalling(true); // Update button to "Stop" when conversation starts
}
}
};

Able to successfully start the conversation but the conversation never stops and the event listeners for conversationEnded or error don't get called. So, unable to stop a web conversation. Is there anything I am missing here?

Receive function call results from client js sdk

Is there a way to receive the JSON output on the client from calling a function? Let's say my retell python backend defines a function (which does something other than ending the call) that gets called by the LLM, how can I access the function from this JS SDK on the client?

New version with livekit seems to have performance issues / latency

I was trying out the latest release that uses livekit that was pushed last night and have been noticing intermittent performance issues that don't exist with the previous version.

Specifically the voices seem to sometimes drop out and slowed down, like it's struggling with bad latency that we didn't see with the previous version of the api. Recordings of the call seem to be fine when we play them after ending the call, so the latency in the playback seems to be happening on the client side.

Reproduction of this is pretty simple we are running essentially the same code from the setup document (the issue happens regardless of whether we have emitRawAudioSamples on or off).

Is this something you have been observing in your testing? Should we revert back to the previous version?

stopConversation() doesn't stop the conversation?

retell-client-js-sdk@^1.3.2

I refresh the page instead.

Ref: https://discord.com/channels/1186424376300679209/1222558901753483295

import { RetellWebClient } from 'retell-client-js-sdk';

function WebCall() {
  let retellWebClient = new RetellWebClient();
  const [isCallActive, setIsCallActive] = useState(false);

  retellWebClient.on(ClientEventNames.conversationEnded, ({ code, reason }) => {
    console.log('Conversation ended with code "%d" and reason "%s"', code, reason);
    setIsCallActive(false);
  });

  retellWebClient.on(ClientEventNames.error, error => {
    console.error('Conversation error occurred', error);
    setIsCallActive(false);
  });

  async function toggleCall() {
    if (isCallActive) {
      retellWebClient.stopConversation();
      // stop doesn't work, so refresh the page instead
      window.location.reload();
    } else {
      // ... start the call
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.