Skip to main content
The First Step
Jun 23, 2022 6:48 PM UTC
Question

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.


    12 replies

    Jun 29, 2022 6:56 PM UTC
    ken-nyeThe First StepAuthor
    The First Step
    Jun 29, 2022 7:55 PM UTC

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

    Employee
    Jun 30, 2022 3:45 PM UTC

    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.

    Jun 30, 2022 4:03 PM UTC

    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.

    ken-nyeThe First StepAuthor
    The First Step
    Jun 30, 2022 11:13 PM UTC

    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>';
    Jul 2, 2022 5:55 AM UTC

    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

    ken-nyeThe First StepAuthor
    The First Step
    Jul 12, 2022 7:12 PM UTC

    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
    PhongVu
    Community Manager
    Community Manager
    Jul 13, 2022 5:49 PM UTC

    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));
    ken-nyeThe First StepAuthor
    The First Step
    Jul 13, 2022 6:17 PM UTC

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

    -->

    PhongVu
    Community Manager
    Community Manager
    Jul 13, 2022 6:26 PM UTC

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

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