Legacy Dev Forum Posts

 View Only

Sign Up

Inbound call not ringing/answered

  • 1.  Inbound call not ringing/answered

    Posted 06-05-2025 18:03

    filippo.galbusera | 2023-08-29 07:53:02 UTC | #1

    Hello everyone, I'm trying to handle an inbound call throught Javascript SDK and WebRtcSDK in a test custom phonebar application we're implementing for our customer. We have 2 kind of issues:

    1. when an inbound call is received, our "phonebar" does not ring (maybe be something is missing in WebRtcSDK config/handshake)
    2. when we try to answer the received inbound call following the suggestions provided with these articles/topics (https://developer.genesys.cloud/forum/t/answering-inbound-call-using-javascript-sdk/12549 and

    https://developer.genesys.cloud/forum/t/answering-inbound-calls-via-js-sdk-with-webrtc-station/7026) our code fails and the call conversation is not successfully connected with our test "phonebar"

    This is the function we wrote to initialize the WebRtcSDK in our code:

    function initWebRtcSDK() {
    
          webRtcSDK = new window.GenesysCloudWebrtcSdk.GenesysCloudWebrtcSdk({
            accessToken: currentToken,
            organizationId: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
            environment: 'mypurecloud.ie'      
          });
    
          webRtcSDK.on('sdkError', (event) => {
            console.log(`Event sdkError -> ${JSON.stringify(event, null, 2)}`);
          });
    
          webRtcSDK.on('pendingSession', (event) => {
            console.log(`Event pendingSession -> ${JSON.stringify(event, null, 2)}`);
            if (!pendingPropose) {
              pendingPropose = event;
              document.getElementById("btnAnswer").disabled = false;
    
              webRtcSDK.acceptPendingSession({ conversationId: pendingPropose.conversationId })
                .then((data) => {
                  console.log("acceptPendingSession completed");
                })
                .catch((err) => {
                  console.log("There was a failure calling acceptPendingSession");
                  console.error(err);
                });
    
            }
          });
    
          webRtcSDK.on('ready', () => {
            console.log("Event ready received: webRtcSDK successfully started!");
          });
          webRtcSDK.on('sessionStarted', (event) => {
            console.log('Event sessionStarted ->', event);
            if (pendingPropose) {
              webRtcSDK.acceptSession({ conversationId: pendingPropose.conversationId })
                .then((data) => {
                  console.log("acceptSession completed");
                })
                .catch((err) => {
                  console.log("There was a failure calling acceptSession");
                  console.error(err);
                });
            }
          });
    
          webRtcSDK.initialize().then(() => {
            // the web socket has connected and the SDK is ready to use
            console.log('WebRTC SDK initialize terminated!');
            //TODO: add GUI initialization
          });
    
        }

    Receiving the call (even if the phonebar is not ringing...) we enable the "Answer" button tocall the following function:

    function answerBtnPressed() {
          let pendingconvId = pendingPropose.conversationId;
          conversationsApi.getConversationsCall(pendingconvId)
            .then((conversationData) => {
              document.getElementById("btnAnswer").disabled = true;
              console.log(`getConversationsCall success! data: ${JSON.stringify(conversationData, null, 2)}`);
              // Retriving our participant ID
              let currentPartecipant = conversationData.participants.find(partecipant => partecipant.user.id === currentUser.id);
              // body of the "answer" request
              let body = {};
              body["state"] = "connected";
              // trying to connect our participant to the conversation
              conversationsApi.patchConversationsCallParticipant(pendingPropose.conversationId, currentPartecipant.id, body)
                .then((dataAnswer) => {
                  console.log(`patchConversationsCallParticipant success! data: ${JSON.stringify(dataAnswer, null, 2)}`);
                  activeCallID = pendingPropose.conversationId;
                })
                .catch((err) => {
                  console.log("There was a failure calling patchConversationsCallParticipant");
                  console.error(err);
                });
            })
            .catch((err) => {
              console.log("There was a failure calling getConversationsCall");
              console.error(err);
            });
        }

    After btn answer has been pressed, the call is not connected (we cannot ear anything) and after few seconds terminates to a voice email.

    Can anyone suggest what are we missing?

    Thank you for your time


    system | 2023-09-29 07:53:48 UTC | #2

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 21742