SMS Quick Start
Things to know before you begin
- SMS prices changed in 2022.
- Our SMS content and messaging policies will help you stay compliant.
- When you are finished with this quick start, checkout our SMS Best Practices Guide.
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 send your first SMS on the platform in just a few minutes. Let's get started.
Create App and Get Credentials
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 SMS 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 SMS App Show detailed instructions
- Login or create an account if you have not done so already.
- Go to Console/Apps and click 'Create App' button.
- Select "REST API App" under "What type of app are you creating?" Click "Next."
- Under "Authentication" select "Password-based auth flow."
- Under "Security" add the following permissions:
- SMS
- ReadAccounts
- 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:
- Download our env-template and save it as a file named
.env
. - Edit your newly downloaded
.env
file, setting its variables with the proper values for the app you created above..
Send an SMS
Select your preferred language below.
Install RingCentral JavaScript SDK
$ npm install @ringcentral/sdk dotenv --save
Create and edit sms.js
Create a file called sms.js
. Be sure the values in your .env
file have been set properly, including the SMS_RECIPIENT
variable.
/* You get the environment parameters from your
application dashbord in your developer account
https://developers.ringcentral.com */
const RC = require('@ringcentral/sdk').SDK
require('dotenv').config();
const RECIPIENT = process.env.SMS_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, function(e){
read_extension_phone_number()
});
async function read_extension_phone_number(){
try {
var resp = await platform.get("/restapi/v1.0/account/~/extension/~/phone-number")
var jsonObj = await resp.json()
for (var record of jsonObj.records){
for (feature of record.features){
if (feature == "SmsSender"){
return send_sms(record.phoneNumber)
}
}
}
} catch(e) {
console.log(e.message)
process.exit(1)
}
}
async function send_sms(fromNumber){
try {
var resp = await platform.post('/restapi/v1.0/account/~/extension/~/sms', {
from: {'phoneNumber': fromNumber},
to: [{'phoneNumber': RECIPIENT}],
text: 'Hello World!'
})
var jsonObj = await resp.json()
console.log("SMS sent. Message status: " + jsonObj.messageStatus)
} catch(e) {
console.log(e.message)
process.exit(1)
}
}
Run your code
You are almost done. Now run your script.
$ node sms.js
Install RingCentral Python SDK
$ pip install ringcentral python-dotenv
Create and edit sms.py
Create a file called sms.py
. Be sure the values in your .env
file have been set properly, including the SMS_RECIPIENT
variable.
#!/usr/bin/python
# You get the environment parameters from your
# application dashbord in your developer account
# https://developers.ringcentral.com
import os
import sys
from dotenv import load_dotenv
from ringcentral import SDK
load_dotenv()
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(jwt=os.environ.get('RC_JWT'))
except Exception as e:
sys.exit("Unable to authenticate to platform. Check credentials." + str(e))
print(f'Login with JWT successful.')
RECIPIENT = os.environ.get('SMS_RECIPIENT')
def read_extension_phone_number():
try:
resp = platform.get("/restapi/v1.0/account/~/extension/~/phone-number")
jsonObj = resp.json()
except e:
sys.exit("Unable to fetch SMS-enabled phone numbers")
for record in jsonObj.records:
for feature in record.features:
if feature == "SmsSender":
return send_sms(record.phoneNumber)
sys.exit("No SMS-enabled phone number found")
def send_sms(fromNumber):
try:
resp = platform.post('/restapi/v1.0/account/~/extension/~/sms',
{
'from' : { 'phoneNumber': fromNumber },
'to' : [ {'phoneNumber': RECIPIENT} ],
'text' : 'Hello World!'
})
jsonObj = resp.json()
except:
sys.exit("Unable to send SMS")
print (jsonObj.messageStatus)
read_extension_phone_number()
Run your code
You are almost done. Now run your script.
$ python sms.py
Install RingCentral PHP SDK
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require ringcentral/ringcentral-php vlucas/phpdotenv
Create and edit sms.php
Create a file called sms.php
. Be sure the values in your .env
file have been set properly, including the SMS_RECIPIENT
variable.
<?php
/* You get the environment parameters from your
application dashbord in your developer account
https://developers.ringcentral.com */
require('vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();
$RECIPIENT = $_ENV['SMS_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'] );
read_extension_phone_number();
function read_extension_phone_number(){
global $platform;
$resp = $platform->get("/restapi/v1.0/account/~/extension/~/phone-number");
$jsonObj = $resp->json();
foreach ($resp->json()->records as $record){
foreach ($record->features as $feature){
if ($feature == "SmsSender"){
return send_sms($record->phoneNumber);
}
}
exit("No phone number found with 'SmsSender' feature enabled.");
}
}
function send_sms($fromNumber){
global $platform,$RECIPIENT;
try {
$resp = $platform->post('/account/~/extension/~/sms',
array(
'from' => array ('phoneNumber' => $fromNumber),
'to' => array(
array('phoneNumber' => $RECIPIENT)
),
'text' => 'Hello World!'
));
print("SMS sent. Message status: " . $resp->json()->messageStatus . PHP_EOL);
} catch (\RingCentral\SDK\Http\ApiException $e) {
exit("Message: " . $e->message . PHP_EOL);
}
}
?>
Run your code
You are almost done. Now run your script.
$ php sms.php
Create a Visual Studio project
- Choose Console Application .Net Core -> App
- Select Target Framework .NET Core 2.1
- Enter project name "Send_SMS"
- 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;
/* You get the environment parameters from your
application dashbord in your developer account
https://developers.ringcentral.com */
namespace Send_SMS
{
class Program
{
const string SMS_RECIPIENT = "<ENTER PHONE NUMBER>";
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();
read_extension_phone_number().Wait();
}
static private async Task read_extension_phone_number()
{
var resp = await restClient.Restapi().Account().Extension().PhoneNumber().Get();
foreach (var record in resp.records)
{
foreach(var feature in record.features)
{
if (feature == "SmsSender")
{
send_sms(record.phoneNumber).Wait();
goto LoopEnd;
}
}
}
LoopEnd:
Console.WriteLine("\nDone.");
}
static private async Task send_sms(string fromNumber)
{
var parameters = new CreateSMSMessage();
parameters.from = new MessageStoreCallerInfoRequest {
phoneNumber = fromNumber
};
parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest {
phoneNumber = Environment.GetEnvironmentVariable("SMS_RECIPIENT")
} };
parameters.text = "Hello World!";
var resp = await restClient.Restapi().Account().Extension().Sms().Post(parameters);
Console.WriteLine("SMS sent. Message status: " + resp.messageStatus);
}
}
}
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 "Send_SMS"
-
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 "Send_SMS"
package SendSMSQuickStart;
public class SendSMSQuickStart {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
Edit the file "SendSMSQuickStart.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.
package com.ringcentral;
import java.io.IOException;
import com.ringcentral.*;
import com.ringcentral.definitions.*;
public class SendSMSQuickStart {
static String SMS_RECIPIENT = System.getenv("SMS_RECIPIENT");
static RestClient rc;
public static void main(String[] args) {
var obj = new SendSMSQuickStart();
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.read_extension_phone_number();
} catch (RestException | IOException e) {
e.printStackTrace();
}
}
public void read_extension_phone_number() throws RestException, IOException{
var resp = rc.restapi().account().extension().phoneNumber().get();
OUTERMOST: for (var record : resp.records) {
for(var feature : record.features) {
if (feature.equalsIgnoreCase("SmsSender")) {
send_sms(record.phoneNumber);
break OUTERMOST;
}
}
}
}
public void send_sms(String phoneNumber) throws RestException, IOException {
CreateSMSMessage postParameters = new CreateSMSMessage();
postParameters.from = new MessageStoreCallerInfoRequest().phoneNumber(phoneNumber);
postParameters.to = new MessageStoreCallerInfoRequest[]{
new MessageStoreCallerInfoRequest().phoneNumber(SMS_RECIPIENT)
};
postParameters.text = "Hello World from Java";
var response = rc.restapi().account().extension().sms().post(postParameters);
System.out.println("SMS sent. Message status: " + response.messageStatus);
}
}
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 sms.rb
Create a file called sms.rb
. Be sure the values in your .env
file have been set properly, including the SMS_RECIPIENT
variable.
#!usr/bin/ruby
# You get the environment parameters from your
# application dashbord in your developer account
# https://developers.ringcentral.com
require 'ringcentral'
require 'dotenv/load'
RECIPIENT = ENV['SMS_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'] )
def read_extension_phone_number()
resp = $rc.get('/restapi/v1.0/account/~/extension/~/phone-number')
for record in resp.body['records'] do
for feature in record['features'] do
if feature == "SmsSender"
return send_sms(record['phoneNumber'])
end
end
end
end
def send_sms(phoneNumber)
resp = $rc.post('/restapi/v1.0/account/~/extension/~/sms', payload: {
from: {phoneNumber: phoneNumber},
to: [{phoneNumber: RECIPIENT}],
text: 'Hello World!'
})
puts "SMS sent. Message status: " + resp.body['messageStatus']
end
read_extension_phone_number()
Run your code
You are almost done. Now run your script.
$ ruby sms.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!
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.