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.
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');
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...)
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));
that fixed it! thanks for all your help
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));
-->
You should see that my copy/paste missed the other closing ). The code is fixed now.
->add(fopen('customgreeting.wav', 'r'))
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.
What is that status and review related to the greeting uploading?
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
Give the system a while to populate the data. Let me know if you are not able to graduate it by tomorrow.
Hi Phong, the sandbox app still shows no API calls in the last 7 days/24hours
Give me the app client id then.
support graduated me this morning right after I posted a comment, thanks for all you help!
Success! thanks so much!
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));
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
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
thanks, what permissions are needed for that? I dont see any permission that are call write-greeting, most a read permissions.
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.
Hi @ken-nye yes by using this API for your extension: https://developers.ringcentral.com/api-reference/Greetings/createCustomUserGreeting
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