RingOut Quick Start

Last updated: 2022-01-13 Contributors Byrne ReesePaco Vu
Edit this page

Welcome to the RingCentral Platform. RingCentral is the leading unified communications platform. From one system developers can integrate with, or build products around all the ways people communicate today: SMS, voice, fax, chat and meetings.

In this Quick Start, we are going to help you connect two people in a live phone call using our RingOut API, which dials two phone numbers, and then connects the two people when they answer. 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 RingOut 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 RingOut 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 "Authentication" select "Password-based auth flow."
  5. Under "Security" add the following permissions:
    • RingOut
  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.

Download and edit a .env file

Follow the instructions found in our guide to running Developer Guide code samples. Or:

  1. Download our env-template and save it as a file named .env.
  2. Edit your newly downloaded .env file, setting its variables with the proper values for the app you created above..

Place a Call

Select your preferred language below.

Install RingCentral JavaScript SDK

$ npm install @ringcentral/sdk --save

Create and edit ringout.js

Create a file called ringout.js. Be sure the values in your .env file have been set properly, including the RINGOUT_RECIPIENT variable.

const RC = require('@ringcentral/sdk').SDK

const RECIPIENT    = process.env.RINGOUT_RECIPIENT

var rcsdk = new RC({
    'server':       process.env.RC_SERVER_URL,
    'clientId':     process.env.RC_CLIENT_ID,
    'clientSecret': process.env.RC_CLIENT_SECRET
});
var platform = rcsdk.platform();
platform.login({
    'username':  process.env.RC_USERNAME,
    'password':  process.env.RC_PASSWORD,
    'extension': process.env.RC_EXTENSION
})

platform.on(platform.events.loginSuccess, () => {
  call_ringout()
})

async function call_ringout() {
  try {
    var resp = await platform.post('/restapi/v1.0/account/~/extension/~/ring-out', {
      'from': { 'phoneNumber': process.env.RC_USERNAME },
      'to': { 'phoneNumber': RECIPIENT },
      'playPrompt': false
    })
    var jsonObj = await resp.json()
    console.log("Call placed. Call status: " + jsonObj.status.callStatus)
  } catch (e) {
    console.log(e.message)
  }
}

Run your code

You are almost done. Now, load your variables into your local environment, and run your script.

$ source .env
$ node ringout.js

Install RingCentral Python SDK

$ pip install ringcentral python-dotenv

Create and edit ringout.py

Create a file called ringout.py. Be sure the values in your .env file have been set properly, including the RINGOUT_RECIPIENT variable.

#!/usr/bin/env python
from ringcentral import SDK
import os,sys
from dotenv import load_dotenv
load_dotenv()

RECIPIENT = os.environ.get('RINGOUT_RECIPIENT')

rcsdk = SDK( os.environ.get('RC_CLIENT_ID'),
             os.environ.get('RC_CLIENT_SECRET'),
             os.environ.get('RC_SERVER_URL') )
platform = rcsdk.platform()
try:
  platform.login(os.environ.get('RC_USERNAME'),
                 os.environ.get('RC_EXTENSION'),
                 os.environ.get('RC_PASSWORD') )
except Exception as e:
  sys.exit("Unable to authenticate to platform: " + str(e))

resp = platform.post('/restapi/v1.0/account/~/extension/~/ring-out',
              {
                  'from' : { 'phoneNumber': os.environ.get('RC_USERNAME') },
                  'to'   : { 'phoneNumber': RECIPIENT },
                  'playPrompt' : False
              })
print(f'Call placed. Call status: {resp.json().status.callStatus}')

Run your code

You are almost done. Now run your script.

$ python ringout.py

Install RingCentral PHP SDK

$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require ringcentral/ringcentral-php vlucas/phpdotenv

Create and edit ringout.php

Create a file called ringout.php. Be sure the values in your .env file have been set properly, including the RINGOUT_RECIPIENT variable.

<?php
require('vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();

$RECIPIENT    = $_ENV['RINGOUT_RECIPIENT'];

$rcsdk = new RingCentral\SDK\SDK( $_ENV['RC_CLIENT_ID'],
                                  $_ENV['RC_CLIENT_SECRET'],
                                  $_ENV['RC_SERVER_URL'] );
$platform = $rcsdk->platform();
$platform->login( $_ENV['RC_USERNAME'],
                  $_ENV['RC_EXTENSION'],
                  $_ENV['RC_PASSWORD'] );

$resp = $platform->post('/account/~/extension/~/ring-out',
    array(
      'from' => array('phoneNumber' => $_ENV['RC_USERNAME'] ),
      'to' => array('phoneNumber' => $RECIPIENT),
      'playPrompt' => false
    ));

print_r ("Call placed. Call status: " . $resp->json()->status->callStatus);
?>

Run your code

You are almost done. Now run your script.

$ php ringout.php

Create a Visual Studio project

  • Choose Console Application .Net Core -> App
  • Select Target Framework .NET Core 2.1
  • Enter project name "Call_Ringout"
  • Add NuGet package RingCentral.Net (4.1.0) SDK

Edit the file Program.cs

Be sure to edit the variables in ALL CAPS with your app and user credentials. Be sure to also set the recipient's phone number.

using System;
using System.Threading.Tasks;
using RingCentral;

namespace Call_Ringout
{
    class Program
    {
        static RestClient restClient;
        static void Main(string[] args)
        {
            restClient = new RestClient(
                Environment.GetEnvironmentVariable("RC_CLIENT_ID"),
                Environment.GetEnvironmentVariable("RC_CLIENT_SECRET"),
                Environment.GetEnvironmentVariable("RC_SERVER_URL"));
            restClient.Authorize(
                Environment.GetEnvironmentVariable("RC_USERNAME"),
                Environment.GetEnvironmentVariable("RC_EXTENSION"),
                Environment.GetEnvironmentVariable("RC_PASSWORD")).Wait();
            call_ringout().Wait();
        }

        static private async Task call_ringout()
        {
            var parameters = new MakeRingOutRequest();
            parameters.from = new MakeRingOutCallerInfoRequestFrom {
                phoneNumber = Environment.GetEnvironmentVariable("RC_USERNAME")
            };
            parameters.to = new MakeRingOutCallerInfoRequestTo {
                phoneNumber = Environment.GetEnvironmentVariable("RINGOUT_RECIPIENT")
            };
            parameters.playPrompt = false;

            var resp = await restClient.Restapi().Account().Extension().RingOut().Post(parameters);
            Console.WriteLine("Call Placed. Call status" + resp.status.callStatus);
        }
    }
}

Run Your App

You are almost done. Now run your app from Visual Studio.

Create a Java project (using Eclipse IDE)

  • Create a new Java project
  • Select the Gradle Project wizard
  • Enter project name "Call_RingOut"
  • Open the build.gradle file and add the RingCentral Java SDK to the project as shown below:
dependencies {
    // ...
    compile 'com.ringcentral:ringcentral:1.4.0'
}
  • Right-click the project in the Package Explorer and choose "Refresh Gradle Project" under the "Gradle" sub-menu

Create a new Java Class

Select "File -> New -> Class" to create a new Java class named "RingoutQuickStart"

package RingoutQuickStart;

public class RingoutQuickStart {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }
}

Edit the file "RingoutQuickStart.java".

Be sure to edit the variables in ALL CAPS with your app and user credentials. Be sure to also set the recipient's phone number.

import com.ringcentral.*;
import com.ringcentral.definitions.*;
import java.io.IOException;

public class RingoutQuickStart {
    static String RINGOUT_RECIPIENT = System.getenv("RINGOUT_RECIPIENT");
    static RestClient rc;

    public static void main(String[] args) {
        var obj = new RingoutQuickStart();
        rc = new RestClient( System.getenv("RC_CLIENT_ID"),
                             System.getenv("RC_CLIENT_SECRET"),
                             System.getenv("RC_SERVER_URL") );
        try {
            rc.authorize( System.getenv("RC_USERNAME"),
                          System.getenv("RC_EXTENSION"),
                          System.getenv("RC_PASSWORD") );
            obj.call_ringout();
        } catch (RestException | IOException e) {
            e.printStackTrace();
        }
    }
    public void call_ringout() throws RestException, IOException {
        MakeRingOutRequest requestBody = new MakeRingOutRequest();
        requestBody.from(new MakeRingOutCallerInfoRequestFrom().phoneNumber(
                                                                 System.getenv("RC_USERNAME")
        ));
        requestBody.to(new MakeRingOutCallerInfoRequestTo().phoneNumber(RINGOUT_RECIPIENT));
        requestBody.playPrompt = false;

        var response = rc.restapi().account().extension().ringOut().post(requestBody);
        System.out.println("Call Placed. Call status: " + response.status.callStatus);
    }
}

Run Your App

You are almost done. Now run your app from Eclipse.

Install RingCentral Ruby SDK

$ gem install ringcentral-sdk dotenv

Create and edit ringout.rb

Create a file called ringout.rb. Be sure the values in your .env file have been set properly, including the RINGOUT_RECIPIENT variable.

require 'ringcentral'
require 'dotenv/load'

RECIPIENT = ENV['RINGOUT_RECIPIENT']

$rc = RingCentral.new(ENV['RC_CLIENT_ID'],
                      ENV['RC_CLIENRT_SECRET'],
                      ENV['RC_SERVER_URL'])

$rc.authorize(username: ENV['RC_USERNAME'],
              extension: ENV['RC_EXTENSION'],
              password: ENV['RC_PASSWORD'])

resp = $rc.post('/restapi/v1.0/account/~/extension/~/ring-out', payload: {
    from: { phoneNumber: ENV['RC_USERNAME'] },
    to: { phoneNumber: RECIPIENT },
    playPrompt: false
})

puts "Call placed. Call status: " + resp.body['status']['callStatus']

Run your code

You are almost done. Now run your script.

$ ruby ringout.rb

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 RingCentral application.

Take your next step »