CallFire Solutions

Round Robin Transfers



Often clients want each incoming call to route to the next transfer number in a given order, where phone A gets the first call, phone B the second, etc. We call this a Round Robin.

A Round Robin can’t be set up within the IVR itself, because it needs to make use of an external counter to keep track of which number is next in the cycle for the next transfer. To accomplish this, we will make use of the Google Scripting feature in Google Sheets to create a web app. The transfer itself is a simple flow:


Create the Web Service

To create the web service, first create a Google Sheet with the number “1” in cell A1, and an “x” in cell C1. Click on “Tools” ==> “Script Editor…” In the Script Editing Window, paste the following:




Notice that the doGet service creates a named value, “cycle” for the spreadsheet. Also, the string after “SpreadsheetApp.openByID(“…” is the ID Key of the sheet you’ve just created. You’ll find it in the URL for the sheet.


To create the web service, first click on “File” and “Save,” and give your script a name. Our example uses “RR2” for Round Robin 2. Then click “Publish,” and “Deploy as Web App…” Give your project a version number. Execute the app as “Previous publisher,” and set “Who has access to the app:” as “Anyone, even anonymous.” (No one actually has access without the App Key). You will need the App Key section from the “Current web app URL:” line. It is the long string after “macro/s/”.


The IVR will use two different <get> tags to interact with your sheet. In the first, to get the current Cycle Number from the sheet, the URL is:;tq=select%20A%20where%20C%20%3D%20%22x%22%0A&amp;tqx=out:csv


The section starting “/1E-Fgx…/” is actually the Google Sheet ID Key. Unencoded, the URL query says “select A where C = x.” Since C1 is “x” it returns the number currently in A1. It also says to return the data in A1 as a csv value.


The second <get> tag updates cell A1 with a new value. The URL is:;col=1&amp;cycle=${cycle}


The “/AKfycb…/” is the App Key of the web service mentioned above. Notice the URL defines the target as row 1, column 1, or cell A1, and accepts the named value “cycle” which will go there as the variable ${cycle} from our IVR.


Create the IVR Script

We’re now ready to create our IVR. The following script gets our value from the spreadsheet, and tells it we want the response as a csv field, placing it in the variable "cycle." It then defines the variable “count,” which is the total number of phone numbers in our round robin. The <stash> “TransferNum” is there for troubleshooting purposes. Copy this entire script to the appropriate place (i.e., your transfer section) in your IVR.


The If-Else section evaluates if our number “cycle” has reached the end of our list, in other words, is equal to our “count.” If so, it sets “cycle” back to 1. If not, it increments “cycle” by 1.


The last section lists all the available phone numbers and assigns them numbers. The <stash> “transfer” assembles the correctly nested variables for the <transfer> tag.


Besides replacing the Sheet ID Key and App Key in the correct <get> tags, the only changes needed are the correct number of phone numbers in the setvar that creates the "count" variable, and the actual phone numbers with their assigned cycle numbers in the setvar list.


Have more questions? Submit a request