npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ringcentral-call

v0.2.21

Published

[![Coverage Status](https://coveralls.io/repos/github/ringcentral/ringcentral-call-js/badge.svg?branch=master)](https://coveralls.io/github/ringcentral/ringcentral-call-js?branch=master) [![NPM Version](https://img.shields.io/npm/v/ringcentral-call.svg?st

Downloads

490

Readme

RingCentral Call JS SDK

Coverage Status NPM Version Build Status

RingCentral Call aims to help developers to make and control call easily with RingCentral Web Phone and Call Control APIs. In this SDK, we use Web Phone for voice transmission, use Call Control API for call control.

Key features

  • Call session management. Combined web phone session from WebRTC and telephony session from the Call Control API
  • Call session event. Handle telephony session event, sync status
  • Session functional API. Request call control API with function
  • Functional API to make and receive calls

Comparing with the RingCentral Web Phone and Call Control SDK

RingCentral Web Phone: connect user with the WebRTC and SIP based on WebSockets. Can only control the call in the current web phone device

RingCentral Call Control: control calls with RESTful APIs, this doesn’t support voice transmission, support to control all calls in current extension user, or account level (admin).

RingCentral Call: voice transmission with WebRTC, control calls with RESTful APIs, support to control all calls in current extension user.

Prerequisites

  • You will need an active RingCentral account to create RingCentral app. Don't have an account? Get your Free RingCentral Developer Account Now!
  • A RingCentral app
    • App type: Browser-Based or Server/Web
    • Permissions: 'Call Control', 'Read Accounts', 'Read Presence', 'Webhook Subscriptions' and 'VoIP Calling'

Install

Use npm or yarn

$ yarn add @ringcentral/sdk @ringcentral/subscriptions ringcentral-call-control ringcentral-web-phone ringcentral-call

Use CDN scripts

<script type="text/javascript" src="https://unpkg.com/es6-promise@latest/dist/es6-promise.auto.js"></script>
<script type="text/javascript" src="https://unpkg.com/pubnub@latest/dist/web/pubnub.js"></script>
<script type="text/javascript" src="https://unpkg.com/whatwg-fetch@latest/dist/fetch.umd.js"></script>
<script type="text/javascript" src="https://unpkg.com/@ringcentral/sdk@latest/dist/ringcentral.js"></script>
<script type="text/javascript" src="https://unpkg.com/@ringcentral/subscriptions@latest/dist/ringcentral-subscriptions.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/sip.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/ringcentral-web-phone.js"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]/build/index.js"></script>

Demo

Online: Demo

Run in local:

$ git clone https://github.com/ringcentral/ringcentral-call-js.git
$ cd ringcentral-call-js
$ yarn
$ yarn build
$ yarn start

Open http://localhost:8080/demo/, and login with RingCentral account to test.

Usage

For this example you will also need to have RingCentral JS SDK, RingCentral JS Subscriptions SDK, RingCentral Web Phone and RingCentral Call Control installed.

Create RingCentral Call instances:

var appClientId = '...'; 
var appClientSecret = '...';
var appName = '...';
var appVersion = '...';
var rcCall;

var sdk = new RingCentral.SDK({
  clientId: appClientId,
  clientSecret: appClientSecret,
  appName: appName,
  appVersion: appVersion,
  server: RingCentral.SDK.server.production // or .sandbox
});
var subscriptions = new RingCentral.Subscriptions({ sdk });

var platform = sdk.platform();

platform
  .login({
    username: '...',
    password: '...'
  })
  .then(function() {
    return platform
            .post('/restapi/v1.0/client-info/sip-provision', {
              sipInfo: [{transport: 'WSS'}]
            })
  })
  .then(function(res) {
    return res.json();
  })
  .then(function(sipProvision) {
    // create RingCentral web phone instance
    var rcWebPhone = new RingCentral.WebPhone(sipProvision, {
      appKey: appClientId,
      appName: 'RingCentral Call Demo',
      appVersion: '0.0.1'
    });

    // create RingCentral call instance
    rcCall = new RingCentralCall({ webphone: rcWebPhone, sdk: sdk, subscriptions: subscriptions });
    return rcCall;
  })

API

Initialize

Firstly, we need to create RingCentral JS SDK instance and RingCentral Web Phone instance. Then pass them when initialize RingCentral Call instance:

var rcCall = new RingCentralCall({ webphone: rcWebPhone, sdk: sdk });

Make a Call

Switch a call from other device

const session = await rcCall.makeCall({
  type: 'webphone',
  toNumber: 'phone number',
  fromNumber: 'from number',
})

Switch Call

Switch a call voice into current web phone instance from other devices

const telephonySessionId = rcCall.sessions[0].id;
const session = await rcCall.switchCall(telephonySessionId);

Events

New call session event

var session = null;

rcCall.on('new', (newSession) => {
  session = newSession;
});

Webphone registered event

rcCall.on('webphone-registered', function () {
  //  web phone feature is ready
});

Call control ready event

rcCall.on('call-control-ready', function () {
  //  call control feature is ready
});

Sessions List

var sessions = rcCall.sessions;

Session API

Hangup a call

session.hangup().then(...)

Hold a call

session.hold().then(...)

Unhold a call

session.unhold().then(...)

To voicemail

session.toVoicemail().then(...)

Reject a call

session.reject().then(...)

Answer a call

session.answer().then(...)

Forward a call

session.forward('forward number').then(...)

Transfer a call

session.transfer('transfer number').then(...)

Mute a call

session.mute().then(...)

Unmute a call

session.unmute().then(...)

Session Event

Status changed event

session.on('status', ({ party }) => {
  // console.log(part)
});

TODO

  • [ ] Conference Call Support