Grokify
Grokify

Reputation: 16354

How to set RingCentral hold music?

RingCentral has the ability to upload custom Hold Music via the UI. Can this be done via the API, as user and as an admin for other users? Searching the API Reference for hold music didn't turn up an API.

Here's some info on this functionality:

Here's what the UI looks like:

enter image description here

Upvotes: 1

Views: 204

Answers (2)

Grokify
Grokify

Reputation: 16354

There are two steps to this:

  1. Get the Answering Rule ID of the rule you want to change. This can be a standard rule such as business-hours-rule, or it can be a custom rule that you have created. You can call the Get Call Handling Rules API to get a list of current standard and custom rules.
  2. Call the Update Greeting API with type set to HoldMusic and answeringRuleId set to the id you wish to update, e.g. business-hours-rule

There are actually several ways to call the Update Greeting API:

  1. multipart/form-data with individual string parts. In this approach, separate parts are sent with names type, answeringRuleId, and binary
  2. multipart/form-data with JSON metadata part. In this approach, a JSON MIME part named json is sent with a payload like: {"type": "HoldMusic", "answeringRule": { "id": "12345678" }}
  3. multipart/mixed

I tend to prefer the first approach (multipart/form-data with individual string parts) because it's easy to use with tools like cURL and many HTTP clients.

Here's an example using Go:

package main

import(
    "log"
    "net/http"
    "net/url"
    "os"

    "github.com/grokify/gotilla/mime/multipartutil"
    "github.com/grokify/oauth2more/ringcentral"
)

func main() {

    // Get the Client (*http.Client):
    client, err = ringcentral.NewClientPassword(
        ringcentral.ApplicationCredentials{
            ClientID:     os.Getenv("RINGCENTRAL_CLIENT_ID"),
            ClientSecret: os.Getenv("RINGCENTRAL_CLIENT_SECRET"),
            ServerURL:    os.Getenv("RINGCENTRAL_SERVER_URL")},
        ringcentral.PasswordCredentials{
            Username:  os.Getenv("RINGCENTRAL_USERNAME"),
            Extension: os.Getenv("RINGCENTRAL_EXTENSION"),
            Password:  os.Getenv("RINGCENTRAL_PASSWORD")})
    if err!=nil {
        log.Fatal(err)
    }

    // Create the HTTP Request (*http.Request)
    params := url.Values{}
    params.Set("type", "HoldMusic")
    params.Set("answeringRuleId", "business-hours-rule")

    req, err := multipartutil.NewRequest(
        http.MethodPost,
        "https://platform.ringcenral.com/restapi/v1.0/account/~/extension/~/greeting",
        params,
        []multipartutil.FileInfo{
            {
                MIMEPartName: "binary",
                Filepath:     "mygreeting.wav",
            },
        },
    )

    // Send the request
    resp, err = client.Do(req)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("STATUS: %v\n", resp.StatusCode) 
}

Upvotes: 0

Oleg Bannyi
Oleg Bannyi

Reputation: 21

Try API for creating custom user greeting and set greeting type as HoldMusic https://developers.ringcentral.com/api-reference/Rule-Management/createCustomUserGreeting

Create custom user greeting API

Upvotes: 2

Related Questions