Company Answering Rules

Last updated: 2024-01-31Contributors
Edit this page

Company Answering Rules can be used to create and manage the logic for routing calls through IVR menus, as well as routing calls to extensions that not directly associated with an individual user. For example, the following are all extension types for which Company Answering Rules would be appropriate:

  • Call Queues
  • Department Groups
  • IVR Menu Extensions

If you are unfamiliar with answering rules, we recommend you read our Answering Rules Overview.

Creating a Company Custom Answering Rule

Be mindful of the following when constructing a request to create a user custom answering rule:

  • Provide a meaningful name for the rule using the name parameter.
  • Set the type parameter as "Custom."
  • Set the enabled parameter to True if the rule needs to be in effect immediately. Otherwise, set it to False.
  • Specify one or more conditions (see below).
  • Specify the action to take using the callHandlingAction field (see table below).
  • Specify the extension and greetings parameters. More details

Finally, make a POST request to the following endpoint:

/restapi/v1.0/account/{accountId}/extension/{extensionId}/answering-rule

Call Handling Actions

Action Description
Operator Play company greeting and forward to an operator extension.
Disconnect Play back company greeting then hangup.
Bypass Skip company greeting and forward to a selected extension.

Call Handling Conditions

The following parameters are used for specifying call handling conditions.

  • callers: a list of callers' phone numbers or contact names
    • callerId:
    • name:
  • calledNumbers: a list of recipients' phone numbers
    • phoneNumber: a phone number belonging to the user/extension
  • schedule: week day and time or time ranges or business hours and after hours parameters
    • weeklyRanges: week day and time ranges
    • ranges: date and time ranges
    • ref: "BusinessHours" or "AfterHours". Business hours can be set using the Business Hours API Reference

Sample code

Create a Company Custom Answering Rule

The following code sample shows how to create a company custom answering rule that will re-route all incoming calls to a voice mailbox during a company business hours, and then disconnect.

const RC = require('@ringcentral/sdk').SDK
require('dotenv').config();

var rcsdk = new RC({
    'server':       process.env.RC_SERVER_URL,
    'clientId':     process.env.RC_CLIENT_ID,
    'clientSecret': process.env.RC_CLIENT_SECRET
});
var platform = rcsdk.platform();
platform.login({ 'jwt':  process.env.RC_JWT })

platform.on(platform.events.loginSuccess, function(response) {
  create_company_custom_answering_rule();
});

async function create_company_custom_answering_rule() {
  var params = {
    enabled: true,
    type: "Custom",
    name: "Company off time",
    callHandlingAction: "Disconnect",
  };
  try {
    var resp = await platform.post(
      "/restapi/v1.0/account/~/answering-rule",
      params
    );
    var jsonObj = await resp.json();
    console.log(jsonObj);
  } catch (e) {
    console.log(e.message);
  }
}
#!/usr/bin/python

# You get the environment parameters from your 
# application dashbord in your developer account 
# https://developers.ringcentral.com

import os
import sys

from dotenv import load_dotenv
from ringcentral import SDK
load_dotenv()

rcsdk = SDK( os.environ.get('RC_CLIENT_ID'),
             os.environ.get('RC_CLIENT_SECRET'),
             os.environ.get('RC_SERVER_URL') )
platform = rcsdk.platform()
try:
  platform.login( jwt=os.environ.get('RC_JWT') )
except Exception as e:
  sys.exit("Unable to authenticate to platform: " + str(e))

params = {
    'enabled': True,
    'type': 'AfterHours',
    'name': "Company off time",
    'schedule' : {
      'weeklyRanges': {
        'monday': [{ 'from': "09:00",'to': "10:00" }],
        'friday': [{ 'from': "10:00", 'to': "15:00" }]
      }
    },
    'callHandlingAction': "TakeMessagesOnly"
  }
resp = platform.post('/restapi/v1.0/account/~/answering-rule', params)

print( resp.text() )
<?php
/* You get the environment parameters from your 
   application dashbord in your developer account 
   https://developers.ringcentral.com */

require('vendor/autoload.php');
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../');
$dotenv->load();

$rcsdk = new RingCentral\SDK\SDK( $_ENV['RC_CLIENT_ID'],
                                  $_ENV['RC_CLIENT_SECRET'],
                                  $_ENV['RC_SERVER_URL'] );
$platform = $rcsdk->platform();
$platform->login( [ "jwt" => $_ENV['RC_JWT'] ] );

$params = array (
    'enabled' => true,
    'type' => "Custom",
    'name' => "My weekly meetings",
    'schedule' => array (
      'weeklyRanges' => array (
        'monday' => array ( array ('from' => "09:00", 'to' => "10:00")),
        'friday' => array ( array ('from' => "10:00", 'to' => "15:00"))
      )
    ),
    'callHandlingAction' => "TakeMessagesOnly"
);
$resp = $platform->post('/account/~/answering-rule', $params);

print_r ($resp->text());
?>
using System;
using System.Threading.Tasks;
using RingCentral;

namespace CompanyCustomAnsweringRule
{
  class Program
  {
    static RestClient restClient;
    static async Task Main(string[] args)
    {
      restClient = new RestClient(
      Environment.GetEnvironmentVariable("RC_CLIENT_ID"),
      Environment.GetEnvironmentVariable("RC_CLIENT_SECRET"),
      Environment.GetEnvironmentVariable("RC_SERVER_URL"));
      await restClient.Authorize(Environment.GetEnvironmentVariable("RC_JWT"));
      await create_company_custom_answering_rule();
    }
    static private async Task create_company_custom_answering_rule()
    {
      var parameters = new CompanyAnsweringRuleRequest();
      parameters.enabled = true;
      parameters.type = "Custom";
      parameters.name = "My weekly meetings";
      var schedule = new CompanyAnsweringRuleScheduleInfoRequest();
      var weeklyRanges = new CompanyAnsweringRuleWeeklyScheduleInfoRequest();
      var meetingTime = new CompanyAnsweringRuleTimeIntervalRequest();
      meetingTime.from = "09:00";
      meetingTime.to = "10:00";
      weeklyRanges.monday = new CompanyAnsweringRuleTimeIntervalRequest[] { meetingTime };

      meetingTime = new CompanyAnsweringRuleTimeIntervalRequest();
      meetingTime.from = "10:00";
      meetingTime.to = "15:00";
      weeklyRanges.friday = new CompanyAnsweringRuleTimeIntervalRequest[] { meetingTime };

      schedule.weeklyRanges = weeklyRanges;
      parameters.schedule = schedule;
      parameters.callHandlingAction = "TakeMessagesOnly";

      var response = await restClient.Restapi().Account().AnsweringRule().Post(parameters);
      var jsonStr = JsonConvert.SerializeObject(response);
      Console.WriteLine(jsonStr);
    }
  }
}
package com.ringcentral;

import com.ringcentral.*;
import com.ringcentral.definitions.*;
import java.io.IOException;

public class CreateCompanyAnsweringRule {
    static RestClient rc;

    public static void main(String[] args) {
        var obj = new CreateCompanyAnsweringRule();
    rc = new RestClient( System.getenv("RC_CLIENT_ID"),
                 System.getenv("RC_CLIENT_SECRET"),
                 System.getenv("RC_SERVER_URL") );
    try {
        rc.authorize( System.getenv("RC_JWT") );
        obj.create_company_custom_answering_rule();
    } catch (RestException | IOException e) {
        e.printStackTrace();
    }
    }

    public static void create_company_custom_answering_rule() throws RestException, IOException {
    var schedule = new CompanyAnsweringRuleScheduleInfoRequest();
    var weeklyRanges = new CompanyAnsweringRuleWeeklyScheduleInfoRequest();
    var meetingTime = new CompanyAnsweringRuleTimeIntervalRequest();
    meetingTime.from = "09:00";
    meetingTime.to = "10:00";
    weeklyRanges.monday = new CompanyAnsweringRuleTimeIntervalRequest[] { meetingTime };

    meetingTime = new CompanyAnsweringRuleTimeIntervalRequest();
    meetingTime.from = "10:00";
    meetingTime.to = "15:00";
    weeklyRanges.friday = new CompanyAnsweringRuleTimeIntervalRequest[] { meetingTime };

    schedule.weeklyRanges = weeklyRanges;

    var parameters                = new CompanyAnsweringRuleRequest();
    parameters.enabled            = true;
    parameters.type               = "Custom";
    parameters.name               = "My weekly meetings";
    parameters.schedule           = schedule;
    parameters.callHandlingAction = "TakeMessagesOnly";

    CompanyAnsweringRuleInfo response = rc.restapi().account().answeringRule().post(parameters);
    System.out.println( "Rule created. ID: " + response.id );
    }
}
#!usr/bin/ruby

# You get the environment parameters from your 
# application dashbord in your developer account 
# https://developers.ringcentral.com

require 'ringcentral'
require 'dotenv/load'

$rc = RingCentral.new(ENV['RC_CLIENT_ID'],
                      ENV['RC_CLIENRT_SECRET'],
                      ENV['RC_SERVER_URL'])

$rc.authorize(jwt: ENV['RC_JWT'])

params = {
    enabled: true,
    type: 'Custom',
    name: 'My weekly meetings',
    schedule: {
      weeklyRanges: {
        monday: [{ from: "09:00", to: "10:00" }],
        friday: [{ from: "10:00", to: "15:00" }]
      }
    },
    callHandlingAction: "TakeMessagesOnly",
}
resp = $rc.post('/restapi/v1.0/account/~/answering-rule', payload: params)

puts resp.body

Upon successful API call completion, the response contains the id (ruleId) and other information of the newly created rule.

{
  "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/178009114/extension/178009114/answering-rule/227207004",
  "id": "227207004",
  "type": "Custom",
  "name": "My weekly meetings",
  ...
}

List Company Answering Rules

To list all company answering rules make a GET request to the following endpoint:

/restapi/v1.0/account/{accountId}/answering-rule

Required permission(s): ReadAccounts

Upon successful API call completion, the response contains a list of all existing answering rules (including the default rules).

{
  "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/11111111/answering-rule?page=1&perPage=100",
  "records": [
    {
      "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/11111111/answering-rule/33333333",
      "id": "33333333",
      "type": "Custom",
      "name": "Company Custom Rule 1",
      "enabled": true,
    },
    {
      "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/account/11111111/answering-rule/business-hours-rule",
      "id": "business-hours-rule",
      "type": "BusinessHours",
      "enabled": true
    }
  ],
  "paging": {...},
  "navigation": {...}
}

Fetch a Single Company Answering Rule

To fetch the details associated with an individual company answering rule, make a GET request to the following endpoint, where [ruleId] is the ID of an existing rule:

/restapi/v1.0/account/{accountId}/answering-rule/[ruleId]

Hints

A valid ruleId can be retrieved using the previous API to read all user answering rules.

The ruleId of the default Business Hours and After Hours rule is business-hours-rule and after-hours-rule, respectively.

Required permission(s): ReadAccounts

Upon successful API call completion, the response contain detailed information of a rule.

{
    "uri": "http://platform.ringcentral.com/restapi/v1.0/account/11111111/answering-rule/business-hours-rule",
    "id": "business-hours-rule",
    "type": "BusinessHours",
    "enabled": true,
    "schedule": {
        "ref": "BusinessHours"
    },
    "callHandlingAction": "ForwardCalls",
    "forwarding": {
        "notifyMySoftPhones": true,
        "notifyAdminSoftPhones": false,
        "softPhonesRingCount": 1,
        "ringingMode": "Sequentially",
        "rules": [
            {
                "index": 1,
                "ringCount": 4,
                "forwardingNumbers": [
                    {
                        "uri": "http://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/forwarding-number/33333333",
                        "id": "33333333",
                        "phoneNumber": "+16505551212",
                        "label": "My Cisco SPA-303 Desk Phone"
                    }
                ]
            },
            {
                "index": 2,
                "ringCount": 8,
                "forwardingNumbers": [
                    {
                        "uri": "http://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/forwarding-number/44444444",
                        "id": "44444444",
                        "phoneNumber": "+4155551212",
                        "label": "Home"
                    }
                ]
            },
            {
                "index": 3,
                "ringCount": 12,
                "forwardingNumbers": [
                    {
                        "uri": "http://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/forwarding-number/55555555",
                        "id": "55555555",
                        "phoneNumber": "+12125551212",
                        "label": "Mobile"
                    }
                ]
            }
        ]
    },
    "greetings": [
        {
            "type": "Voicemail",
            "prompt": {
                "id": "0",
                "type": "message",
                "name": "No One Available"
            }
        },
        {
            "type": "Introductory"
        },
        {
            "type": "AudioWhileConnecting",
            "prompt": {
                "id": "6",
                "type": "music",
                "name": "Acoustic"
            }
        },
        {
            "type": "ConnectingMessage",
            "prompt": {
                "id": "3",
                "type": "message",
                "name": "Forward hold 1"
            }
        }
    ],
    "screening": "Never",
    "voicemail": {
        "enabled": true,
        "recipient": {
            "uri": "http://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222",
            "id": 22222222
        }
    }
}

Update a Company Answering Rule

To update a company answering rule specify only the parameter values which need to be updated. Then make a PUT request to the following endpoint, where [ruleId] is the ID of an existing rule:

/restapi/v1.0/account/{accountId}/answering-rule/[ruleId]

Hints

A valid ruleId can be retrieved using the previous API to read all user answering rules.

The ruleId of the default Business Hours and After Hours rule is business-hours-rule and after-hours-rule, respectively.

Required permission(s): EditAccounts

Delete a Company Answering Rule

To delete a company answering rule, make a DELETE request to the following endpoint, where the ruleId is the id of an existing rule.

/restapi/v1.0/account/{accountId}/answering-rule/[ruleId]

Hints

A valid ruleId can be retrieved using the previous API to read all user answering rules.

The ruleId of the default Business Hours and After Hours rule is business-hours-rule and after-hours-rule, respectively.

Required permission(s): EditAccounts