question

Louis-Philippe Perron avatar image
Louis-Philippe Perron asked Phong Vu commented

Answer Call Javascript SDK

Hi,


Already using the Javascript SDK to query for Account, Directory, Presence, Call Status, etc. Also successfully using the SDK to do CallOut sessions.


When trying to Answer calls, the API always answer with 400 or 404 responses.

What would be the SDK usage to answer a call, using the telephonySessionId, partyId & deviceId?


regards,

Thanks!

sdk
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered Phong Vu commented

In order to answer a call programmatically, you need the telephoneSessionId and the partyId. You can get those ids from an active call. The best way to get ac active call info is to implement push notification and subscribe for the presence notification with the detailedTelephonyState set to true, or subscribe for the telephony session notification

7 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Louis-Philippe Perron avatar image Louis-Philippe Perron commented ·

Hi, Sorry I was not clear in my question...

The notification already work ok, and the telephonySessionId + partyId are known and used to proceed with the "Answer".

What I'd like to confirm:

- when I receive the "telephony session" notification for an incoming call, is Answer Call Party the right API to answer the call right away?

- Using the telephonySessionId and callParty from the notification, is that right?

- why am I receiving 400 or 404 responses?

- is there a way to debug further to investigate the problem source?


regards,

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Louis-Philippe Perron commented ·

Can you share some code and also print the error message?

0 Likes 0 ·
Louis-Philippe Perron avatar image Louis-Philippe Perron Phong Vu ♦♦ commented ·
function answer({telephonySessionId, deviceId, partyId}) {
  sdk.platform()
    .post(`/restapi/v1.0/account/~/telephony/sessions/${telephonySessionId}/parties/${partyId}/answer`, {deviceId})
    .then(resp=> {
    console.log("response: ", resp);
  })
    .catch(error=>{
    console.log("error: ", error);
  });
}

assuming the telephonySessionId + partyId received by telephonySession notification and proper deviceId. Does the call needs to be at a specific initialization stage to be ready to be answered?

0 Likes 0 ·
Show more comments

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys