News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Can I upload greeting to Announcement-Only Extensions
Tags: rest api
Jun 23, 2022 at 11:48am   •   8 replies  •  0 likes
ken-nye

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.


8 Answers
answered on Jul 15, 2022 at 1:05pm  

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


 0
on Jul 15, 2022 at 3:11pm   •  0 likes

set this flag to apply after changing it

->request('/account/1030240019/extension/1030288019/greeting?apply=true'); 
on Jul 15, 2022 at 3:17pm   •  0 likes

you say after, so do I need to run the upload request, then come back and run a different request for the apply=true... I just changed the apply=true on the upload request and got this error

  "errorCode" : "CMN-100",
  "message" : "Mandatory parameter [answeringRule] not specified",
  "errors" : [ {
    "er (truncated...)
		
on Jul 19, 2022 at 7:53am   •  0 likes

There is a mistake in the API reference. Login your app with the announcement only extension and call the code below:

$request = $rcsdk->createMultipartBuilder()
                 ->setBody(array(
                     'type' => 'Announcement',
                     'answeringRule' => array (
                       'id' => 'business-hours-rule'
                     )
                 ))
                 ->add(fopen('your-file.mp3', 'r'), 'your-file.mp3', [], 'binary')
                 ->request('/account/~/extension/~/greeting?apply=true');

$resp = $platform->sendRequest($request);
print_r ("Announcement content posted and applied. Response: " . json_encode($resp->json(), JSON_PRETTY_PRINT));
on Jul 19, 2022 at 9:53am   •  0 likes

that fixed it! thanks for all your help

answered on Jul 13, 2022 at 11:17am  

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

PHP Parse error:  syntax error, unexpected ';', expecting ')' in C:\SurfNetUSA\SNC\php\upload_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 RingCentral\SDK\SDK($client_id, $client_secret, RingCentral\SDK\SDK::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));

-->


 0
on Jul 13, 2022 at 11:26am   •  0 likes

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

->add(fopen('customgreeting.wav', 'r'))
on Jul 13, 2022 at 11:38am   •  0 likes

with that sucess bring another issue , my AP calls are not update in the Status and Review, I dont know if there is a quick fix, but I did create a TT, as I saw that has happened to others in the past.

on Jul 13, 2022 at 12:14pm   •  0 likes

What is that status and review related to the greeting uploading?

on Jul 13, 2022 at 3:05pm   •  0 likes

now that I have it working, I want to be able to graduate it to production, but I currently cannot because the APi calls are not showing up in the sandbox

on Jul 13, 2022 at 10:06pm   •  0 likes

Give the system a while to populate the data. Let me know if you are not able to graduate it by tomorrow.

on Jul 14, 2022 at 7:53am   •  0 likes

Hi Phong, the sandbox app still shows no API calls in the last 7 days/24hours

on Jul 14, 2022 at 9:43am   •  0 likes

Give me the app client id then.

on Jul 14, 2022 at 11:27am   •  0 likes

support graduated me this morning right after I posted a comment, thanks for all you help!

on Jul 13, 2022 at 11:30am   •  0 likes

Success! thanks so much!

answered on Jul 13, 2022 at 10:49am  

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 RingCentral\SDK\SDK($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));

 0
answered on Jul 12, 2022 at 12:12pm  

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 RingCentral\SDK\SDK(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

 0
answered on Jun 30, 2022 at 4:13pm  

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>';

 0
on Jul 1, 2022 at 10:55pm   •  0 likes

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

answered on Jun 30, 2022 at 8:45am  

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.


 0
answered on Jun 29, 2022 at 12:55pm  

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


 0
on Jun 30, 2022 at 9:03am   •  0 likes

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.

answered on Jun 29, 2022 at 11:56am  

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


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us