Create Team Messaging Team Quick Start
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 create a new RingCentral team in just a few minutes. Let's get started.
Create app and obtain credentials
The first thing we need to do is create an app in the RingCentral Developer Console. This can be done quickly by clicking the "Create Team 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 Team 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 "JWT auth flow."
- Under "Security" add the following permissions:
- Team Messaging
- 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.RC_APP_CLIENT_ID
- set to the Client ID of the app you created aboveRC_APP_CLIENT_SECRET
- set to the Client Secret of the app you created aboveRC_USER_JWT
- set to the JWT credential you created for yourself
Create a Team
Select your preferred language below.
Install RingCentral JavaScript SDK
$ npm install @ringcentral/sdk dotenv --save
Create and edit create-team.js
Create a file called create-team.js
using the contents below.
const RC_SDK = require('@ringcentral/sdk').SDK
const path = require('path')
// Remember to modify the path of your .env file location!
require('dotenv').config({ path: path.resolve(__dirname, '../.env') })
// Instantiate the SDK and get the platform instance
var rcsdk = new RC_SDK({
'server': process.env.RC_SERVER_URL,
'clientId': process.env.RC_APP_CLIENT_ID,
'clientSecret': process.env.RC_APP_CLIENT_SECRET
});
var platform = rcsdk.platform();
/* Authenticate a user using a personal JWT token */
platform.login({ 'jwt': process.env.RC_USER_JWT })
platform.on(platform.events.loginSuccess, function(e){
create_team()
});
platform.on(platform.events.loginError, function(e){
console.log("Unable to authenticate to platform. Check credentials.", e.message)
process.exit(1)
});
/*
* Create a new public team in Team Messaging with 3 internal members including the team owner
*/
async function create_team() {
try {
let bodyParams = {
public: true,
name: "Node JS Team",
// Add internal members using their extension ids
// Get your user extension id by calling the /restapi/v1.0/account/~/extension endpoint!
members: [{id: "590490017"}, {id: "595861017"}],
// You can also add members using their email address, especially for guest members who are not under your account company.
// members: [{email: "[email protected]"}, { email: "[email protected]"}, {id: "extensionId"}],
description: "Let's talk about Node JS"
}
var endpoint = "/team-messaging/v1/teams"
var resp = await platform.post(endpoint, bodyParams)
var jsonObj = await resp.json()
console.log(JSON.stringify(jsonObj))
} catch (e) {
console.log("Unable to create a new team.", e.message)
}
}
Run your code
You are almost done. Now run your script.
$ node create-team.js
Install RingCentral Python SDK
$ pip install ringcentral python-dotenv
Create and Edit create-team.py
Create a file called create-team.py
using the contents below.
from ringcentral import SDK
import os,sys
from dotenv import load_dotenv
load_dotenv()
#
# Create a new public team in Team Messaging with 3 internal members including the team owner
#
def create_team():
try:
bodyParams = {
'public': True,
'name': "Python Team",
# Add internal members using their extension ids
# Get your user extension id by calling the /restapi/v1.0/account/~/extension endpoint!
'members': [{'id': "590490017"}, {'id': "595861017"}],
# You can also add members using their email address, especially for guest members who are not under your account company.
# 'members': [{'email': "[email protected]"}, { 'email': "[email protected]"}, {'id': "extensionId"}],
'description': "Let's talk about Python"
}
endpoint = "/team-messaging/v1/teams"
resp = platform.post(endpoint, bodyParams)
print(resp.text())
except Exception as e:
print ("Unable to create a new team. " + str(e))
# Instantiate the SDK and get the platform instance
rcsdk = SDK( os.environ.get('RC_APP_CLIENT_ID'),
os.environ.get('RC_APP_CLIENT_SECRET'),
os.environ.get('RC_SERVER_URL') )
platform = rcsdk.platform()
# Authenticate a user using a personal JWT token
def login():
try:
platform.login( jwt=os.environ.get('RC_USER_JWT') )
create_team()
except Exception as e:
sys.exit("Unable to authenticate to platform. Check credentials." + str(e))
login()
##############################
Run your code
You are almost done. Now run your script.
$ python create-team.py
Install RingCentral PHP SDK
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar require ringcentral/ringcentral-php vlucas/phpdotenv
Create and edit create-team.php
Create a file called create-team.php
using the contents below.
<?php
// Remember to modify the path ./../ pointing to the location where the RingCentral SDK was installed and the .env file was saved!
require('./../vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . './../');
$dotenv->load();
# Instantiate the SDK and get the platform instance
$rcsdk = new RingCentral\SDK\SDK( $_ENV['RC_APP_CLIENT_ID'],
$_ENV['RC_APP_CLIENT_SECRET'],
$_ENV['RC_SERVER_URL'] );
$platform = $rcsdk->platform();
// Authenticate a user using a personal JWT token
try {
$platform->login( [ "jwt" => $_ENV['RC_USER_JWT'] ] );
create_team();
} catch (\RingCentral\SDK\Http\ApiException $e) {
exit("Unable to authenticate to platform. Check credentials. " . $e->message . PHP_EOL);
}
/*
* Create a new public team in Team Messaging with 3 internal members including the team owner
*/
function create_team(){
global $platform;
try {
$bodyParams = array(
'public' => true,
'name' => "PHP Team",
// Add internal members using their extension ids
// Get your user extension id by calling the /restapi/v1.0/account/~/extension endpoint!
'members' => array ( array ( 'id' => "590490017"), array ( 'id' => "595861017" )),
// You can also add members using their email address, especially for guest members who are not under your account company.
// 'members' => array(array('email => "[email protected]"), array('email' => "[email protected]"), array('id' => "extensionId")),
'description' => "Let's talk about PHP"
);
$endpoint = "/team-messaging/v1/teams";
$resp = $platform->post($endpoint, $bodyParams);
print($resp->text());
}catch (\RingCentral\SDK\Http\ApiException $e) {
// Getting error messages using PHP native interface
print 'HTTP Error: ' . $e->getMessage() . PHP_EOL;
// Another way to get message, but keep in mind, that there could be no response if request has failed completely
print 'Unable to create a new team. ' . $e->apiResponse->response()->error() . PHP_EOL;
}
}
?>
Run your code
You are almost done. Now run your script.
$ php create-team.php
Install RingCentral SDK gem
$ gem install ringcentral-sdk dotenv
Create and Edit create-team.rb
Create a file called create-team.rb
using the contents below.
require 'ringcentral'
require 'dotenv'
# Remember to modify the path to where you saved your .env file!
Dotenv.load("./../.env")
#
# Create a new public team in Team Messaging with 2 members including the team owner
#
def create_team()
begin
bodyParams = {
'public': true,
'name': "Ruby Team",
# Add internal members using their extension ids
# Get your user extension id by calling the /restapi/v1.0/account/~/extension endpoint!
'members': [{ 'id': "590490017"}, { 'id': "595861017"}],
# You can also add members using their email address, especially for guest members who are not under your account company.
# 'members': [{'email': "[email protected]"}, { 'email': "[email protected]"}, {'id': "[extensionId]"}],
'description': "Let's talk about Ruby"
}
endpoint = "/team-messaging/v1/teams"
resp = $platform.post(endpoint, payload: bodyParams)
puts resp.body
rescue StandardError => e
puts ("Unable to create a new team. " + e.to_s)
end
end
# Instantiate the SDK and get the platform instance
$platform = RingCentral.new( ENV['RC_APP_CLIENT_ID'], ENV['RC_APP_CLIENT_IDCLIENT_SECRET'], ENV['RC_SERVER_URL'] )
# Authenticate a user using a personal JWT token
def login()
begin
$platform.authorize(jwt: ENV['RC_USER_JWT'])
create_team()
rescue StandardError => e
puts ("Unable to authenticate to platform. Check credentials." + e.to_s)
end
end
login()
Run your code
You are almost done. Now run your script.
$ ruby create-team.rb
Create a Visual Studio project
- Choose Console Application .Net Core -> App
- Select Target Framework .NET Core 2.1 or higher version
- Enter project name "Create_Team"
- Add NuGet package RingCentral.Net (6.0.0) SDK
- Save the .env file under your project folder. E.g. /Create_Team/bin/Debug/netcoreapp2.2/.env
Edit the file Program.cs
using System;
using System.Threading.Tasks;
using RingCentral;
using dotenv.net;
namespace Create_Team
{
class Program
{
static RestClient restClient;
static async Task Main(string[] args)
{
try
{
DotEnv.Load();
// Instantiate the SDK
restClient = new RestClient(
Environment.GetEnvironmentVariable("RC_APP_CLIENT_ID"),
Environment.GetEnvironmentVariable("RC_APP_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RC_SERVER_URL"));
// Authenticate a user using a personal JWT token
await restClient.Authorize( Environment.GetEnvironmentVariable("RC_USER_JWT") );
await create_team();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
/*
* Create a new public team in Team Messaging with 3 internal members including the team owner
*/
static private async Task create_team()
{
try
{
var bodyParams = new TMCreateTeamRequest();
bodyParams.@public = true;
bodyParams.name = "C# Team";
bodyParams.description = "Let's talk about C#";
// Add internal members using their extension ids.
// Get your user extension id by calling restClient.Restapi().Account().Extension().List() API!
bodyParams.members = new TMCreateTeamRequestMembers[] {
new TMCreateTeamRequestMembers { id = "590490017" },
new TMCreateTeamRequestMembers { id = "595861017" },
};
// You can also add members using their email address, especially for guest members who are not under your account company.
/*
bodyParams.members = new TMCreateTeamRequestMembers[] {
new TMCreateTeamRequestMembers { email = "[email protected]" },
new TMCreateTeamRequestMembers { email = "[email protected]" },
new TMCreateTeamRequestMembers { id = "[extensionId]" },
};
*/
var resp = await restClient.TeamMessaging().V1().Teams().Post(bodyParams);
var jsonStr = JsonConvert.SerializeObject(resp);
Console.WriteLine(jsonStr);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
Run your code
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 "CreateTeam"
- Open the build.gradle file and add the RingCentral Java SDK to the project as shown below:
dependencies {
// ...
implementation 'com.ringcentral:ringcentral:3.0.0'
}
-
On Eclipse menu, select "Run" and choose the "Run Configurations" and in the dialog, select your project and select the "Environments" tab then enter the following variables:
- RC_APP_CLIENT_ID
- RC_APP_CLIENT_SECRET
- RC_SERVER_URL
- RC_USER_JWT
-
Right-click the project in the Package Explorer and choose "Refresh Gradle Project" under the "Gradle" sub-menu
Edit the file 'CreateTeam.java'
package CreateTeam;
import java.io.IOException;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.ringcentral.*;
import com.ringcentral.definitions.*;
public class CreateTeam {
static RestClient restClient;
public static void main(String[] args) {
var obj = new CreateTeam();
try {
// Instantiate the SDK
restClient = new RestClient(System.getenv("RC_APP_CLIENT_ID"), System.getenv("RC_APP_CLIENT_SECRET"), System.getenv("RC_SERVER_URL"));
// Authenticate a user using a personal JWT token
restClient.authorize(System.getenv("RC_USER_JWT"));
obj.create_team();
} catch (RestException e) {
System.out.println(e.getMessage());
} catch (IOException e) {
e.printStackTrace();
}
}
/*
Create a new public team in Team Messaging with 3 internal members including the team owner
*/
public void create_team() throws RestException, IOException{
try {
var bodyParams = new TMCreateTeamRequest();
bodyParams._public = true;
bodyParams.name = "Java Team";
bodyParams.description = "Let's talk about Java";
// Add internal members using their extension id
// Get your user extension id by calling restClient.restapi().account().extension().list() API!
bodyParams.members = new TMCreateTeamRequestMembers[] {
new TMCreateTeamRequestMembers().id("590490017"),
new TMCreateTeamRequestMembers().id("595861017")
};
// You can also add members using their email address, especially for guest members who are not under your account company.
/*
bodyParams.members = new TMCreateTeamRequestMembers[] {
new TMCreateTeamRequestMembers().email("[email protected]"),
new TMCreateTeamRequestMembers().email("[email protected]"),
new TMCreateTeamRequestMembers().id("extensionId"),
};
*/
var resp = restClient.teamMessaging().v1().teams().post(bodyParams);
String jsonStr = new Gson().toJson(resp, new TypeToken<Object>(){}.getType());
System.out.println(jsonStr);
} catch (RestException e) {
System.out.println(e.getMessage());
}
}
}
Build & Run Your Code
You are almost done. Now run your app from Eclipse.
Check the newly created team
Login to your account at https://app.ringcentral.com to see the newly created team.
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.