RingCX List Active Calls Quick Start

Last updated: 2023-12-08Contributors
Edit this page

Welcome to the RingCX Platform. In this Quick Start, we are going to read a list of active calls from an account. Let's get started.

Create an App

The first thing we need to do is create an app in the RingCentral Developer Portal. This can be done quickly by clicking the "Create App" button below. Just click the button, enter a name and description if you choose, and click the "Create" button. If you do not yet have a RingCentral account, you will be prompted to create one.

Create App

  1. Login or create an account if you have not done so already.
  2. Go to Console/Apps and click 'Create App' button.
  3. Select "REST API App" under "What type of app are you creating?" Click "Next."
  4. Under "Auth" select "JWT auth flow"
  5. Under "Security" add the following permissions:
    • SMS
    • ReadAccounts
  6. Under "Security" select "This app is private and will only be callable using credentials from the same RingCentral account."

When you are done, you will be taken to the app's dashboard. Make note of the Client ID and Client Secret. We will be using those momentarily.

Install RingCX SDK Wrapper for Node JS

$ npm install ringcentral-engage-voice-client

Create and Edit list-active-calls.js

Create a file called list-active-calls.js. Be sure to edit the variables in ALL CAPS with your app and user credentials.

const EngageVoice = require('ringcentral-engage-voice-client').default
const path = require('path')
// Remember to modify the path to where you saved your .env file!
require('dotenv').config({ path: path.resolve(__dirname, '../.env') })

const RunRequest = async function () {
    // Instantiate the SDK wrapper object with your RingCentral app credentials
    const ev = new EngageVoice({
        clientId: process.env.RC_CLIENT_ID,
        clientSecret: process.env.RC_CLIENT_SECRET
    })

    try {
        // Authorize with your RingCentral Office user credentials
        await ev.authorize({ jwt: process.env.RC_JWT })

        // Get Active Calls
        const endpoint = "/api/v1/admin/accounts/{accountId}/activeCalls/list?product=ACCOUNT&productId={accountId}"
        const response = await ev.get(endpoint)
        console.log(response.data);
    }
    catch (err) {
        console.log(err.message)
    }
}

RunRequest();

Run Your Code

You are almost done. Now run your script.

$ node list-active-calls.js

Install RingCX SDK Wrapper for Node JS

$ npm install engagevoice-sdk-wrapper --save

Create and Edit list-active-calls.js

Create a file called list-active-calls.js. Be sure to edit the variables in ALL CAPS with your app and user credentials.

<?php
// Remember to modify the path to where you installed the RingCentral SDK and saved your .env file!
require('./../vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();

$ev = new EngageVoiceSDKWrapper\RestClient(
    $_ENV['RC_CLIENT_ID'],
    $_ENV['RC_CLIENT_SECRET']
);

try{
    $resp = $ev->login( [ "jwt" => $_ENV['RC_JWT'] ], function($response){
      list_account_active_calls($resp->agentDetails[0]->accountId);
    });
}catch (Exception $e) {
    print $e->getMessage();
}

function list_account_active_calls($accountId){
    global $ev;
    $endpoint = "admin/accounts/~/activeCalls/list";
    $params = array (
      'product' => "ACCOUNT",
      'productId' => $accountId
    );
    try{
        $resp = $ev->get($endpoint, $params);
        print ($resp."\r\n");
    }catch (Exception $e) {
        print ($e->getMessage());
    }
}

Run Your Code

You are almost done. Now run your script.

$ node list-active-calls.php

Install RingCX SDK Wrapper for Python

$ pip install engagevoice-sdk-wrapper

Create and Edit list-active-calls.py

Create a file called list-active-calls.py. Be sure to edit the variables in ALL CAPS with your app and user credentials.

import os, sys, time
from dotenv import load_dotenv
from ringcentral_engage_voice import RingCentralEngageVoice

load_dotenv()

def list_active_calls():
    try:
        params = "product=ACCOUNT&productId={accountId}"
        response = ev.get("/api/v1/admin/accounts/{accountId}/activeCalls/list", params).json()
        print(response)
    except Exception as e:
        print(e)

# Instantiate the SDK wrapper object with your RingCentral app credentials
ev = RingCentralEngageVoice(
    os.environ.get('RC_CLIENT_ID'),
    os.environ.get('RC_CLIENT_SECRET')
)

try:
    # Authorize with your RingCentral Office user credentials
    ev.authorize(
        jwt=os.environ.get('RC_JWT')
    )
    list_active_calls()
except Exception as e:
    print(e)

Run Your Code

You are almost done. Now run your script.

$ python list-active-calls.py

Need Help?

Having difficulty? Feeling frustrated? Receiving an error you don't understand? Our community is here to help and may already have found an answer. Search our community forums, and if you don't find an answer please ask!

Search the forums »

What's Next?

When you have successfully made your first API call, it is time to take your next step towards building a more robust RingCX application.