question

Shankar Jha avatar image
Shankar Jha asked Phong Vu commented

Getting 404 error on calling call supervision API

I am using softphone sdk for call supervision. I am using a REST API call to activate the call supervision. This API can be used for call supervision. https://developers.ringcentral.com/api-reference/Call-Control/superviseCallSession. This require a `telephonySessionId` for call supervision. I am providing that from the sip message headers using: `p-rc-api-ids': 'party-id=p-a1c1444275c32z185df69b9c9z133db40000-2;session-id=s-a1c1444275c32z185df69b9c9z133db40000'

But I am getting a 404 not found error.

Here is my code


import RingCentral from "@ringcentral/sdk" ; import { nonstandard } from "wrtc" ; import Softphone from "ringcentral-softphone" ; import fs from "fs" ;
const express = require ( "express" );

const rc = new RingCentral ({ server : process . env . RINGCENTRAL_SERVER_URL , clientId : process . env . RINGCENTRAL_CLIENT_ID , clientSecret : process . env . RINGCENTRAL_CLIENT_SECRET , });

( async () => { await rc . login ({ username : process . env . RINGCENTRAL_USERNAME , extension : process . env . RINGCENTRAL_EXTENSION , password : process . env . RINGCENTRAL_PASSWORD , }). catch ( e => console . error ( e )); const softphone = new Softphone ( rc ); await softphone . register ();
softphone . on ( "INVITE" , ( sipMessage ) => { softphone . answer ( sipMessage ); console . log ( sipMessage [ "headers" ][ "p-rc-api-ids" ]); const filename = sipMessage [ "headers" ][ "p-rc-api-ids" ] . split ( ";" )[ 1 ] . split ( "=" )[ 1 ]; console . log ( filename ); softphone . once ( "track" , ( e ) => { console . log ( e ); console . log ( "track" ); const audioSink = new nonstandard . RTCAudioSink ( e . track ); // let speaker = null let prevSampleRate = null ; const audioFilePath = ` ${ filename } .raw` ; if ( fs . existsSync ( audioFilePath )) { fs . unlinkSync ( audioFilePath ); } const writeStream = fs . createWriteStream ( audioFilePath , { flags : "a" }); audioSink . ondata = ( data ) => { writeStream . write ( Buffer . from ( data . samples . buffer )); }; softphone . once ( "BYE" , () => { console . log ( "BYE" ); audioSink . stop (); }); }); });
const app = express (); app . use ( express . json ());
app . get ( "/record/:telephonySessionId/:agentExtensionId" , async function ( req , res ) { let telephonySessionId = req . params [ "telephonySessionId" ]; let agentExtensionId = req . params [ "agentExtensionId" ]; console . log ( telephonySessionId , softphone . device . id );
await rc . post ( `/restapi/v1.0/account/~/telephony/sessions/ ${ telephonySessionId } /supervise` , { mode : "Listen" , supervisorDeviceId : softphone . device . id , agentExtensionId : agentExtensionId , } ) . then ( function ( data ) { console . log ( data ); res . send ( JSON . stringify ( data )); }) . catch ( function ( e ) { console . log ( e ); res . send ( JSON . stringify ( e )); }); } );
const PORT = 5050 ;
const server = app . listen ( PORT , function () { console . log ( `Running on localhost//: ${ PORT } ` ); }); })(). catch (( e ) => console . error ( e ));
call handlingsoftphone
1 comment
1 |3000

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

Phong Vu avatar image Phong Vu ♦♦ commented ·

Please clean up the snippet code to make it readable. Or I have to remove this post.

Thanks!

0 Likes 0 ·

0 Answers

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