Calls
Register the invite listener before calling register() for inbound calls.
Use a country-code-qualified destination for outbound calls.
Answer an inbound call
import Softphone from "ringcentral-softphone";
const softphone = new Softphone({
domain: process.env.SIP_INFO_DOMAIN!,
outboundProxy: process.env.SIP_INFO_OUTBOUND_PROXY!,
username: process.env.SIP_INFO_USERNAME!,
password: process.env.SIP_INFO_PASSWORD!,
authorizationId: process.env.SIP_INFO_AUTHORIZATION_ID!,
});
softphone.on("invite", async (inviteMessage) => {
const callSession = await softphone.answer(inviteMessage);
callSession.on("dtmf", (digit) => console.log("DTMF:", digit));
callSession.on("audio", (audio) => {
console.log("Received audio bytes:", audio.length);
});
callSession.once("disposed", () => {
console.log("Call ended");
softphone.revoke();
});
});
await softphone.register();
answer() resolves to the CallSession used for media and call control.
Decline an inbound call
softphone.on("invite", async (inviteMessage) => {
await softphone.decline(inviteMessage);
});
The SDK responds with SIP status 603.
Place an outbound call
await softphone.register();
const callSession = await softphone.call("16505550100");
callSession.once("answered", () => console.log("Call answered"));
callSession.once("busy", () => {
console.log("The destination is busy or cannot be reached");
});
callSession.once("disposed", () => {
console.log("Call session disposed");
softphone.revoke();
});
SIP status 486 causes the outbound session to emit busy and then be disposed.
After the peer answers, use the task-specific controls below and hang up when
the application is finished with the call.
Cancel, hang up, and transfer
Cancel before the peer answers:
await callSession.cancel();
Hang up an active call:
await callSession.hangup();
Transfer an active call:
await callSession.transfer("16505550101");
Hold and unhold
await callSession.hold();
await callSession.unhold();
Hold temporarily stops receiving remote audio. If audio is being streamed to
the peer, pause its Streamer while the call is on hold.
Telephony session and party IDs
Outbound sessions expose optional sessionId and partyId values after
RingCentral supplies them:
callSession.once("answered", () => {
console.log(callSession.sessionId, callSession.partyId);
});
RingCentral does not include these values in the initial inbound invite. For inbound calls, see the call-ID workaround.
Multiple instances
Several instances can register with the same credentials, but only the most recent instance receives inbound calls. See the multiple-instances demo.
Meetings
Conference creation and management use the RingCentral REST API and are outside this SDK's scope. The SDK can still dial a meeting and send its access code with DTMF. See the meeting demo and the conference integration demo.
Limitations
- Only the most recent registration receives inbound calls when credentials are shared by several instances.
- Inbound invites do not provide RingCentral telephony session or party IDs.
- Selecting a custom caller ID is not supported.
- Conference orchestration belongs to the RingCentral REST API, not this SDK.