Skip to main content

We have a status hotline Announcement-Only Extension that we use to update the status of our network, to let people call in and listen to a messaging saying if we are up or down. Is there a function in the API that would allow me to upload a new announcement? Or is there another way this can be accomplished without have to call in and manually record a new message.


Hi @ken-nye yes by using this API for your extension: https://developers.ringcentral.com/api-reference/Greetings/createCustomUserGreeting


thanks, what permissions are needed for that? I dont see any permission that are call write-greeting, most a read permissions.


On that page at the top is "App Permission". It looks like that permission is "Edit Extensions". If this answers your question, please click "Accept" to accept Suyash's answer.


In your App you need to have "EditExtensions" permission. Please refer to the top of the API reference page linked above and it will tell you about permission.


I am trying to use the PHP Script , I belive all I have to change is these 2 values, but when I run the script with my sandbox app info I get error 500, also when I use the "try it out" I get an error unknown AccountID when I use the sandbox accountID, if I use ~ it works.

$accountId = '<ENTER VALUE>';
$extensionId = '<ENTER VALUE>';

500 error could be because of something went wrong in the Sandbox environment, try again and let me know. You can use call this API endpoint that will give you actual account ID that you can use later if you don't want to to use '~' : GET /restapi/v1.0/account/~ https://developers.ringcentral.com/api-reference/account


ok, Im trying to figure this out, but Im having trouble understanding the sample code, nowhere in the code does it show you where to put the filename or path, it doesn't show where to put and of the information needed to actually upload a new greeting. Am I missing some part? In the Try it out, I can enter the filename , but the example doesnt reflect that.

// https://developers.ringcentral.com/my-account.html#/applications
// Find your credentials at the above url, set them as environment variables, or enter them below

// PATH PARAMETERS
$accountId = '';
$extensionId = '';

// OPTIONAL QUERY PARAMETERS
$queryParams = array(
//'apply' => undefined
);

require('vendor/autoload.php');
$rcsdk = new RingCentralSDKSDK(getenv('clientId'), getenv('clientSecret'), getenv('serverURL'));
$platform = $rcsdk->platform();
$platform->login(getenv('username'), getenv('extension'), getenv('password'));
$r = $platform->post("/restapi/v1.0/account/{$accountId}/extension/{$extensionId}/greeting", $formData, $queryParams);
// PROCESS RESPONSE

Here is how you can call the API using the RingCentral PHP SDK to create an extension custom greeting.

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

$RINGCENTRAL_CLIENTID = "Your-App-Client-Id";
$RINGCENTRAL_CLIENTSECRET = "Your-App-Client-Secret";
$RINGCENTRAL_SERVER = 'https://platform.ringcentral.com'; // or 'https://platform.devtest.ringcentral.com' for sandbox account

$RINGCENTRAL_USERNAME = "";
$RINGCENTRAL_PASSWORD = "";
$RINGCENTRAL_EXTENSION = "";

$rcsdk = new RingCentralSDKSDK($RINGCENTRAL_CLIENTID, $RINGCENTRAL_CLIENTSECRET, $RINGCENTRAL_SERVER);

$platform = $rcsdk->platform();
$platform->login($RINGCENTRAL_USERNAME, $RINGCENTRAL_EXTENSION, $RINGCENTRAL_PASSWORD);

$request = $rcsdk->createMultipartBuilder()
->setBody(array(
'type' => 'Announcement'
))
->add(fopen('audio_file.mp3', 'r'))
->request('/account/~/extension/~/greeting?apply=false');

$resp = $platform->sendRequest($request);
print_r ("Greeting Posted. Response: " . json_encode($resp->json(), JSON_PRETTY_PRINT));

thanks so much, Im very close now, It is throwing this error

PHP Parse error:  syntax error, unexpected ';', expecting ')' in C:SurfNetUSASNCphpupload_Greeting.php on line 26

on this line

                 ->request('/account/~/extension/~/greeting?apply=false');

here is all the code

$accountId = 'xxxx27004';
$extensionId = 'xxxx27004';
$client_id = "xxxx-2krefmxJbw";
$client_secret = "xxxx_yjIw9J5CmtgRSbuQIg0Jur1-Dg";
$Accountnumber = "xxxx70098";
$extension = "101";
$pw = "xxxx";

require('vendor/autoload.php');
$rcsdk = new RingCentralSDKSDK($client_id, $client_secret, RingCentralSDKSDK::SERVER_SANDBOX);
$platform = $rcsdk->platform();
$platform->login($Accountnumber,$extension,$pw);


$request = $rcsdk->createMultipartBuilder()
->setBody(array(
'type' => 'Announcement'
))
->add(fopen('customgreeting.wav', 'r')
->request('/account/~/extension/~/greeting?apply=false');

$resp = $platform->sendRequest($request);
print_r ("Greeting Posted. Response: " . json_encode($resp->json(), JSON_PRETTY_PRINT));

-->


You should see that my copy/paste missed the other closing ). The code is fixed now.

->add(fopen('customgreeting.wav', 'r'))

Now Im in production, my code is not giving errors, but when I listen to the announcement, it doesn't change. I first got all the extensions to find our hotline announcement only extension

{ "uri": "https://platform.ringcentral.com/restapi/v1.0/account/1030240019/extension/1030288019", "id": 1030288019, "extensionNumber": "1", "contact": { "firstName": "hotline", "email": "@surfnetc.com", "pronouncedName": { "type": "Recorded", "text": "hotline", "prompt": { "id": "3782273019", "contentType": "audio/wav", "contentUri": "https://media.ringcentral.com/restapi/v1.0/account/1030240019/extension/1030288019/greeting/3782273019/content" } } }, "name": "hotline", "type": "Announcement", "status": "Enabled", "permissions": { "admin": { "enabled": false }, "internationalCalling": { "enabled": false } }, "profileImage": { "uri": "https://platform.ringcentral.com/restapi/v1.0/account/1030240019/extension/1030288019/profile-image" }, "hidden": false }

Then I used that info to build my request

->request('/account/1030240019/extension/1030288019/greeting?apply=false');

then I uploaded the new greeting and got this response.

Greeting Posted. Response: { "uri": "https://platform.ringcentral.com/restapi/v1.0/account/1030240019/extension/1030288019/greeting/761570018", "id": "761570018", "type": "Announcement", "contentType": "audio/wav", "contentUri": "https://media.ringcentral.com/restapi/v1.0/account/1030240019/extension/1030288019/greeting/761570018/content" }

but when I listen the hotline announcement, it hasnt changed.

Where did I go wrong?

thanks for any and all help


set this flag to apply after changing it

->request('/account/1030240019/extension/1030288019/greeting?apply=true'); 

Reply