Overview

Last updated: 2024-06-11Contributors
Edit this page

SMS templates are reusable messages that you would frequently need to send your users as SMS messages. They are predefined text messages that can contain text and URLs.

Each SMS template can have maximum 1000 UTF-16 encoded characters. This is also the maximum length of a single SMS message (sent in MMS format) that can be sent out from a RingCentral phone number.

RingCentral platform provides APIs to manage SMS templates for 2 scopes, company templates and user templates (a.k.a personal templates).

Company SMS templates

Company SMS templates can be created, listed, modified and deleted only by users who have the "Edit Company SMS Templates" user permission, this user permission normally included in the default super admin user role. If you want to grant the "Edit Company SMS Templates" permission to other user roles, make sure that the permission is selected for that role.

Company SMS templates can be created for different sites under an account. Each account can have maximum up to 50 predefined company SMS templates. This number includes those templates created for any site under the same account.

The company SMS template name must be unique across all sites. If the same name is reused, the template creation API will fail.

Browse the Company SMS template APIs reference to try online.

User SMS templates

User SMS templates are personal resource. They can be created, listed, managed and accessed by a user who have the "Business SMS" user permission. And the templates are only accessible by that user.

Each user can create maximum up to 25 predefined user SMS templates. A user SMS template name must be unique. If the same name is reused, the template creation API will fail.

Note

Any user with the "Business SMS" user permission can also read the company SMS templates using the user SMS template API by setting the "scope" query parameter to "all" or "company".

Browse the User SMS template APIs reference to try online.

Example of a use case of a user SMS template

Imagine if you are a community manager and you need to send an SMS message every month to remind your community members about the monthly meetup. You can compose the SMS message once, save it as a template. Then every month you need to send the reminder, you can simply load the SMS message from the template and use it to send out the reminder to your community members.

Example code to create a user SMS template

Running the code

  • If you have tried the SMS quick start, you can just copy all the functions below and add them to the quick start project then call the create_user_sms_template() function. Otherwise, edit the variables in ALL CAPS with your app and user credentials before running the code.
  • If you run on your production account, remember to use app credentials for production and change the RingCentral server URL to "https://platform.ringcentral.com"
const RC = require('@ringcentral/sdk').SDK

// Instantiate the SDK and get the platform instance
var rcsdk = new RC({
    server: "https://platform.ringcentral.com",
    clientId: "PRODUCTION-APP-CLIENTID",
    clientSecret: "PRODUCTION-APP-CLIENTSECRET"
});
var platform = rcsdk.platform();

/* Authenticate a user using a personal JWT token */
platform.login({ jwt: "PRODUCTION-JWT" })

platform.on(platform.events.loginSuccess, function(e){
    create_user_sms_template()
});

platform.on(platform.events.loginError, function(e){
    console.log("Unable to authenticate to platform. Check credentials.", e.message)
    process.exit(1)
});

/*
  Create a personal reusable SMS template
*/
async function create_user_sms_template(){
  try {
      let endpoint = "/restapi/v1.0/account/~/extension/~/message-store-templates"
      let bodyParams = {
            displayName: "Weekly meeting reminder",
            body: {
              text: "Please update your slides before the meeting."
          }
    }
    var resp = await platform.post(endpoint, bodyParams)
    var jsonObj = await resp.json()
    console.log(jsonObj)
  } catch(e) {
    console.log("Unable to create a user SMS template.", e.message)
  }
}

/*
  List personal reusable SMS templates
*/
async function list_user_sms_template(){
  try {
    let endpoint = "/restapi/v1.0/account/~/extension/~/message-store-templates"
    var resp = await platform.get(endpoint)
    var jsonObj = await resp.json()
    console.log(jsonObj)
    for (var record of jsonObj.records){
      console.log(record)
    }
  } catch(e) {
    console.log("Unable to list user SMS templates.", e.message)
  }
}
import json
from ringcentral import SDK

#
# Create a personal reusable SMS template
#
def create_user_sms_template():
    try:
        bodyParams = {
            'displayName': "Weekly meeting reminder",
            'body': { 'text': "Please update your slides before the meeting." }
        }
        endpoint = "/restapi/v1.0/account/~/extension/~/message-store-templates"
        resp = platform.post(endpoint, bodyParams)
        jsonObj = resp.json_dict()
        print(json.dumps(jsonObj, indent=2, sort_keys=True))
    except Exception as e:
        print ("Unable to create a user SMS template. " + str(e))


#
# List personal reusable SMS templates
#
def list_user_sms_template():
  try:
      endpoint =  "/restapi/v1.0/account/~/extension/~/message-store-templates"
      resp = platform.get(endpoint)
      jsonObj = resp.json_dict()
      print(json.dumps(jsonObj, indent=2, sort_keys=True))
  except Exception as e:
      print ("Unable to list user SMS templates. " + str(e))

# Authenticate a user using a personal JWT token
def login():
    try:
      platform.login( jwt= "PRODUCTION_JWT" )
      create_user_sms_template()
    except Exception as e:
      print ("Unable to authenticate to platform. Check credentials. " + str(e))

# Instantiate the SDK and get the platform instance
rcsdk = SDK("PRODUCTION-APP-CLIENTID", "PRODUCTION-APP-CLIENTSECRET", "https://platform.ringcentral.com")
platform = rcsdk.platform()

login()
<?php
require('vendor/autoload.php');

// Instantiate the SDK and get the platform instance
$rcsdk = new RingCentral\SDK\SDK( "PRODUCTION-APP-CLIENTID", "PRODUCTION-APP-CLIENTSECRET", "https://platform.ringcentral.com" );
$platform = $rcsdk->platform();

/* Authenticate a user using a personal JWT token */
try {
  $platform->login(["jwt" => "PRODUCTION-JWT"]);
}catch (\RingCentral\SDK\Http\ApiException $e) {
  // Getting error messages using PHP native interface
  print 'Expected HTTP Error: ' . $e;
  exit ("Error message: " . $e->apiResponse->response()->error() . PHP_EOL;
}
create_user_sms_template();

/*
  Create a personal reusable SMS template
*/
function create_user_sms_template(){
  global $platform;
  try {
    $bodyParams = array(
      'displayName' => "Weekly meeting reminder",
      'body' => array(
        'text' => "Please update your slides before the meeting."
        )
    );
    $endpoint = "/restapi/v1.0/account/~/extension/~/message-store-templates";
    $resp = $platform->post($endpoint, $bodyParams);
    $jsonObj = $resp->json();
    print_r (json_encode($jsonObj, JSON_PRETTY_PRINT) . PHP_EOL);
  } catch (\RingCentral\SDK\Http\ApiException $e) {
    exit("Unable to create a user SMS template. " . $e->getMessage() . PHP_EOL);
  }
}

/*
  List personal reusable SMS templates
*/
function list_user_sms_template() {
  global $platform;
  try {
    $endpoint = "/restapi/v1.0/account/~/extension/~/message-store-templates";
    $resp = $platform->get($endpoint);
    $jsonObj = $resp->json();
    print_r (json_encode($jsonObj, JSON_PRETTY_PRINT) . PHP_EOL);
  } catch (\RingCentral\SDK\Http\ApiException $e) {
    exit("Unable to list user SMS templates. " . $e->getMessage() . PHP_EOL);
  }
}
?>
require 'ringcentral'

#
# Create a personal reusable SMS template
#
def create_user_sms_template()
  begin
    bodyParams = {
        'displayName': "Weekly meeting reminder",
        'body': { 'text': "Please update your slides before the meeting." }
    }
    endpoint = "/restapi/v1.0/account/~/extension/~/message-store-templates"
    resp = $platform.post(endpoint, payload: bodyParams)
    puts JSON.pretty_generate(JSON.parse(resp.body.to_json))
  rescue StandardError => e
    puts ("Unable to create a user SMS template." + e.to_s)
  end
end

#
# List personal reusable SMS templates
#
def list_user_sms_template()
  begin
    endpoint =  "/restapi/v1.0/account/~/extension/~/message-store-templates"
    resp = $platform.get(endpoint)
    puts JSON.pretty_generate(JSON.parse(resp.body.to_json))
  rescue StandardError => e
    puts ("Unable to list user SMS templates." + e.to_s)
  end
end

# Authenticate a user using a personal JWT token
def login()
  begin
    $platform.authorize( jwt: "PRODUCTION_JWT" )
    create_user_sms_template()
  rescue StandardError => e
    puts ("Unable to authenticate to platform. Check credentials." + e.to_s)
  end
end

# Instantiate the SDK and get the platform instance
$platform = RingCentral.new( "PRODUCTION-APP-CLIENTID", "PRODUCTION-APP-CLIENTSECRET", "https://platform.ringcentral.com" )

login()