question

ken-nye6499 avatar image
ken-nye6499 asked ken-nye6499 commented

Can I upload greeting to Announcement-Only Extensions

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.


rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Suyash Joshi avatar image
Suyash Joshi answered
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

ken-nye6499 avatar image
ken-nye6499 answered Suyash Joshi commented

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

1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Suyash Joshi avatar image Suyash Joshi ♦ commented ·

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.

0 Likes 0 ·
Craig Chan avatar image
Craig Chan answered

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.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

ken-nye6499 avatar image
ken-nye6499 answered Suyash Joshi commented

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>';
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Suyash Joshi avatar image Suyash Joshi ♦ commented ·

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

0 Likes 0 ·
ken-nye6499 avatar image
ken-nye6499 answered

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
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered

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));
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

ken-nye6499 avatar image
ken-nye6499 answered ken-nye6499 commented

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

-->

9 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

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

->add(fopen('customgreeting.wav', 'r'))
0 Likes 0 ·
ken-nye6499 avatar image ken-nye6499 Phong Vu ♦♦ commented ·

Success! thanks so much!

0 Likes 0 ·
ken-nye6499 avatar image ken-nye6499 Phong Vu ♦♦ commented ·

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.

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ ken-nye6499 commented ·

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

0 Likes 0 ·
Show more comments
ken-nye6499 avatar image
ken-nye6499 answered ken-nye6499 commented

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

4 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image Phong Vu ♦♦ commented ·

set this flag to apply after changing it

->request('/account/1030240019/extension/1030288019/greeting?apply=true'); 
0 Likes 0 ·
ken-nye6499 avatar image ken-nye6499 Phong Vu ♦♦ commented ·

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...)
		
0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ ken-nye6499 commented ·

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));
0 Likes 0 ·
Show more comments

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys