Skip to main content

After asking and trying things out I figured out the following:
(1) Assigning Caller ID (CLID) Phone Numbers

To load multiple CLID phone numbers into a RingCentral account, add them as Company Numbers which can be done in the Online Account Portal for the Admin account under:

Home > Phone System > Company Numbers and Info > Add Number

I assigned all of these to Auto-Receptionist.

Once these numbers are loaded as Company Numbers, they should be available to users to use as a CLID. To verify this, retrieve the list of CLID numbers available to a user by calling the following REST API endpoint after the user has authorized the app:

/restapi/v1.0/account/~/extension/~/phone-number

The numbers returned that can be used for Caller ID will have CallerId as one of the elements in the features property.

(2) Selecting the Proper CLID based on Destination Number

In your app, once you have the number to be dialed, find the closest matching area code. The best is if there is an exact match for your area code. After that, find the one you have that is geographically the closest.

To identify the best number to use, an areacode to lat/lon mapping with nearest-neighbor matching can be used. I wasn't able to find a direct code to lat/lon mapping but it's possible to do one of the following:

areacode to lat/lon: You can use a direct areacode to lat/lon database such as the one here: https://github.com/grokify/gotilla/blob/master/strconv/phonenumber/us-area-code-geo.csv
areacode to zipcode with lat/lon: You can use a zipcode dataset with areacode and lat/lon data as mentioned by Benjamin Dean. Zipcodes are useful because more dense areas have more zipcodes ensuring highly populated areas are represented more.
areacode to LOCODE with lat/lon: UN LOCODES also have lat/lon information and can be used. Ideally each LOCODE would be mapped to a population for weighting purposes.
For a quick solution, I took the areacodes and mapped each to the UN LOCODE dataset here:

https://github.com/grokify/datasets/blob/master/areacode/areacodes.pretty.json | Cassandra Database
Once a UN LOCODE is available, the lat/lon in the LOCODE dataset can be used and a distance can be calculated. Of note, some cities do not have lat/lon data it would be ideal to submit that to the UN LOCODE project. Right now this only one primary city per areacode but it can be enhanced to have multiple cities. In the ideal case, all cities with UN LOCODES in the US and Canada would be mapped to areacodes (and zipcodes).

(3) Making the Call with the CLID

Users should login with their own extensions so user calls will not conflict with each other. Then the app can set the preferred CLID using the RingCentral WebRTC SDK using the fromNumber parameter as shown:


var session = webPhone.userAgent.invite('PHONE_NUMBER', {
media: {
render: {
remote: document.getElementById('remoteVideo'),
local: document.getElementById('localVideo')
}
},
fromNumber: 'CALLERID_NUMBER', // Optional, Company Number will be used as default
homeCountryId: '1' // Optional, the value of
}).then(...);

Be the first to reply!

Reply