function telecoms.ivr.create

Create a new IVR menu.

Having an IVR menu allows you to present your callers with options in order to route them through to the correct destination. Eg, when your customers call you, you might want them to hear "press 1 for sales, 2 for support, 3 for accounts" and then have choose one of those options. Where their call is then routed to depends on which option they choose.

Although virtually all of the options for creating an IVR menu are optional, if you supply too few you will be able to create an IVR that has little or no functionality. You should consider the following components as the minimum required:

Arguments:

argrequired?syntaxinfo
custIDNposintcustID of account in which you are creating an IVR menu (default is your own account)
descYstringa brief textual description of your IVR menu (max 100 characters)
prompt_fg_soundclipIDNposintID of soundclip played to the caller when they arrive at the menu (uninterruptable)
prompt_bg_soundclipIDNposintID of soundclip played to the caller when they arrive at the menu (interruptable)
goodchoice_fg_soundclipIDNposintID of soundclip played to the caller when they select a valid option (uninterruptable)
badchoice_fg_soundclipIDNposintID of soundclip played to the caller when they enter a non-existant option (uninterruptable)
badchoice_bg_soundclipIDNposintID of soundclip played to the caller when they enter a non-existant option (interruptable)
nochoice_fg_soundclipIDNposintID of soundclip played to the caller if they fail to enter a valid option after a set time (see timeout_response) (uninterruptable)
maxreplay_hangup_fg_soundclipIDNposintID of soundclip played to the caller prior to cutting them off after the max number of menu repeats (unterruptable)
timeout_digitNposintTimeout (in seconds) to wait for further user digits once they have started typing (default 3)
timeout_responseNposintTimeout (in seconds) to wait for the user to choose a menu option (default 10)
default_choiceNposintThe selection to assume the user made if they failed to make a selection after timeout_response seconds
nochoice_maxreplaysNposintMax number of times the menu is replayed to the customer (without them making a selection) before defaulting or hanging up
optionsNarr:arrDefinition of the menu options available to the caller
modeNenum:normal|cgi_simple|cgi_fulldefines mode for the IVR menu (default "normal")
cgi_maxdigitsconditionalstringrequired if mode=cgi_simple; max number of digits to accept from the user
cgi_simple_goodchoice_optconditionalunsintrequired if mode=cgi_simple; the "keypress" to route the call to after the user has provided their input
cgi_full_init_urlNstringoptional if mode=cgi_full; the http/https URL of a script to query to find out the max number of digits a user can enter in this menu
cgi_full_init_methodNenum:GET|POSThttp method to use when sending data to the script defined in cgi_full_init_url. Default=GET.
cgi_full_response_urlconditionalstringrequired if mode=cgi_full; the http/https URL of a script to query for call routing instructions
cgi_full_response_methodNenum:GET|POSThttp method to use when sending data to the script defined in cgi_full_response_url. Default=GET.
cgi_full_failchoiceconditionalunsintrequired if mode=cgi_full; the "keypress" option to route the call to if the script defined in cgi_full_response_url cannot be reached

Further argument information

prompt_fg_soundclipID

If defined, this sound clip is played to the caller when they arrive at the menu. This sound clip is not interruptable by the caller, ie the caller must listen to the entire sound clip before they can make any menu selections. Any keypresses they make while this sound clip is playing are ignored.

If this argument is defined as well as prompt_bg_soundclipID, both sound clips are played but this one is played first.

prompt_bg_soundclipID

If defined, this sound clip is played to the caller when they arrive at the menu. This sound clip can be interrupted by the caller, ie the caller has called you previously and already knows which option they want, they can make their selection without having to listen to the entire message play first.

If this argument is defined as well as prompt_fg_soundclipID, both sound clips are played but this one is played second. In this instance, the user must listen to the first sound clip in its entirity (because it is uninterruptable), but they may interrupt the second one (this one) by making a selection. This might be useful if you have to play a disclaimer that your callers must hear in full (prompt_fg_soundclipID) before presenting them with the menu options which they may choose to interrupt (prompt_bg_soundclipID).

goodchoice_fg_soundclipID

If defined, this sound clip is played to the caller in acknowledgement of them choosing a valid menu option prior to routing the call to the destination defined by that option. This sound clip is not interruptable so you should keep it short, eg something like "thank you".

This sound clip would be played to the caller regardless of which (valid) option they chose.

badchoice_fg_soundclipID

If defined, this sound clip is played to the caller if they enter a non-valid option. It is uninterruptable. The caller must listen to the enture sound clip. Any further keypresses they make during its playback will be ignored.

If both this (badchoice_fg_soundclipID) and badchoice_bg_soundclipID are defined, both are played but this one is played first.

badchoice_bg_soundclipID

If defined, this sound clip is played to the caller if they enter a non-valid option. It is interruptable, so they can immediately follow up by keying a valid option while this sound clip is playing.

If both badchoice_fg_soundclipID and this (badchoice_bg_soundclipID) are defined, both sound clips are played but this one is played second. In this instance, the user must listen to the first sound clip in its entirity (because it is uninterruptable), but they may interrupt the second one (this one) by making a new selection.

nochoice_fg_soundclipID

If defined, this sound clip is played to the caller after 'timeout_response' seconds (see the timeout_response argument) if they fail to enter any options (whether valid or not) in that time. This might happen if someone is calling from an old fashioned phone that does not have a DTMF (tone dial) keypad, eg one of the old rotary dial telephones.

maxreplay_hangup_fg_soundclipID

If defined, this sound clip is played to the caller if/when:

In the above circumstances, the system will hang up the call but just before doing this, it will play this sound clip to the caller. If this sound clip is not defined, the system will just hang up the call without playing a message.

timeout_digit

This setting only comes into effect if some of the defined menu options have a different number of digits than some of the others.

If all menu options have the same number of digits (in most cases, menu options will be a single digit, eg "press 1 for sales, press 2 for support or press 0 to hear these options again"), then the system will action the caller's selection as soon as they have entered the requisite number of digits.

If, however, some options have more digits (eg "press 1 for sales, 2 for support or press 100 for accounts)", if the caller presses 1, the system doesn't know whether they want option 1 or may be in the middle of entering "100". In these cases, as soon as the caller has started pressing digits, it will wait for a period of time before assuming that they have finished typing. The length of time it waits, in seconds, is defined in the timeout_digit argument.

If, in the above example, the caller enters "100", the system knows that there are no options with more than 3 digits so it will act immediately on their selection.

If an impatient caller wants to choose one of the shorter options, instead of them having to wait for timeout_digit seconds before their selection is actioned, they may press "#" to indicate that they have finished entering digits.

If this argument is not supplied, the system will assume a default setting of 3 seconds.

timeout_response

This is the number of seconds that the system will wait for a caller to begin entering their selection.

If the caller fails to enter anything after this time ...

If this argument is not supplied, the system will assume a default setting of 10 seconds.

default_choice

If this is defined, the system will assume that the seletion the user made was the one that corresponds to the default_choice digits. The call will then proceed as if the caller actually entered these digits.

nochoice_maxreplays

Set this to the number of times you want the IVR menu to be repeated if the user does not make a selection. If the user has not made a selection after the max number of replays has been reached, then

options

This argument is where you define the options that the caller can enter, and what happens when they choose one.

The argument takes a list of option records (list/array/whatever, depending on what it's called in your chosen programming language). Each option record consists of these elements:

The following elements are mutually exclusive. Whichever you supply depends on what value you defined in the routeto_type element:

mode

The IVR system has 3 main modes of operation:

With the CGI modes, you still need to define an option in the options argument that defines each destination the call could route to. The difference is that the system then routes the call through to the option whose keypress value matches the value in the cgi_simple_goodchoice_opt argument (if in cgi_simple mode) or as specifed in the response to a remote script from your web site (in cgi_full mode).

With cgi_full mode, It's perhaps easiest to think of the remote script telling the IVR system to "route the call as if the user pressed '3'" (for example). An option for keypress '3' still needs to be defined; it's just that the user won't specifically enter that themselves.

mode "cgi_simple"

In this mode, the IVR menu acts mainly as a data gathering exercise. User input doesn't play any part in call routing, but the digits entered by the user are stored within the call data records (CDRs) in an IVRTRACE parameter within the "extra_params" field. This field is not normally returned by default so you have to request it with the telecoms.calldata.detail.get:optfields argument.

cgi_simple IVR menus can be used as end of call IVR menus, which allows the operator to key in some data about the call for later analysis once the caller has hung up.

mode "cgi_full"

This allows an IVR menu to be integrated with a script on your web site to allow a script on your web site to make call routing decisions in real time depending on user input.

This can be useful, for example, if you wanted to route premium customers to a different department. In this example, you might set up the IVR menu to prompt the user for an account number. Our system will then make an HTTP connection to a script on your site with details about the call, including the digits the caller entered. Your system could then check what they entered against information in your database and then in the response instruct the IVR system which of the pre-defined options to route the call to. If the user entered a valid account number, you may choose to route them to a sub-menu that prompts them to enter a PIN. This sub-menu would also connect to a script on your web site in order to verify the PIN is the correct one for that account. The IVR system can then be instructed to route them through to the appropriate department, or redirect them back to the main menu, or whatever.

cgi_maxdigits

This parameter is required when the IVR menu is operating in cgi_simple mode. It tells the IVR system the maximum number of digits to accept from the user. See the description of the mode argument for more information on cgi_simple mode.

cgi_simple_goodchoice_opt

This parmeter is required when the IVR menu is operating in cgi_simple mode.

When you define a cgi_simple IVR, you need to specify one option in the options parameter with a keypress value. This parameter should contain the digits that match that keypress option so that the system knows where to route the call once the user has entered digits. See the description of the mode argument for more information on cgi_simple mode.

cgi_full_init_url

See the example given in telecoms.ivr.create:cgi_full_response_url for an example of how this parameter is used.

cgi_full_init_method

Specifies whether calls to the script defined in cgi_full_init_url parameter should use the HTTP GET or HTTP POST method. If unspecified, the system defaults to using HTTP GET.

cgi_full_response_url

In cgi_full mode, the IVR system queries a remote script at the URL given in this parameter to find out where to route the call. This is probably easier to explain by example. You might set up the following IVR menu on a tech support line so that you can divert premium customers to your premium tech suopport department and everybody else to the basic level tech support department:

You then use telecoms.num.route to route a phone number at this IVR menu, using the ivrID that telecoms.ivr.create returned to you.

A call comes in and arrives at the IVR menu. The following (example) happens:

In a live system you would probably want to perform other validation steps, eg asking a caller to enter their PIN after they've entered their account number. To do that, you would create an additional cgi_full IVR menu that prompts them for their PIN and calls your remote script with the digits they entered. Amongst the parameters that are sent will be the same uniqueID value so you will be able to correlate the various calls to your remote script with the same call (the uniqueID value is unique to a phone call, but is repeated with any script called from within that phone call). You would amend your main menu so that the option defined with keypress 2 would route to the second IVR menu, not directly to your support department's phone number.

With several steps of data entry, your script can build up a database record of information provided by the customer and take appropriate action.

cgi_full_response_method

Specifies whether calls to the script defined in cgi_full_response_url parameter should use the HTTP GET or HTTP POST method. If unspecified, the system defaults to using HTTP GET.

cgi_full_failchoice

See the example given in telecoms.ivr.create:cgi_full_response_url for an example of how this parameter is used.

Return values

The function will return the ivrID that can be then used to route numbers (or other ivr menu options) to this menu.

Example 1

Create an IVR menu that plays "Welcome to ACME Ltd. Please press 1 for sales, 2 for support". The sales team are on 02031234567 and the support team are on 01234567890. If the caller presses any keys other than 1 or 2, they hear a "unrecognised selection" message.

Because your callers often know the option they require, you want them to be able to interrupt the welcome message by pressing the option they want. Because of this, you choose to define the initial welcome message with the prompt_bg_soundclipID argument instead of the prompt_fg_soundclipID argument.

You will previously have used the telecoms.soundclip.create function to upload the sound files for the welcome message and unrecognised selection message, and assigned them each the "ivr.prompt" role. These have soundclipIDs 1 and 2 respectively.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
      "password" : "YOURPASSWORD",
      "username" : "YOURUSERNAME"
   },
   "func" : "telecoms.ivr.create",
   "args" : {
      "options" : [
         {
            "desc" : "sales team",
            "routeto_type" : "number",
            "destnumber" : "02031234567",
            "keypress" : "1"
         },
         {
            "routeto_type" : "number",
            "desc" : "support team",
            "keypress" : "2",
            "destnumber" : "01234567890"
         }
      ],
      "desc" : "ACME Ltd main menu",
      "badchoice_fg_soundclipID" : 2,
      "prompt_bg_soundclipID" : 1
   }
}

The response

The response returns with the ivrID (ivrID=2 in this example). This can then be used to route a number to this menu with the telecoms.num.route function.

JSON example response:

{
   "results" : {
      "eventID" : "1477542",
      "ivrID" : "2"
   },
   "success" : "1"
}

Example 2

You decide to improve on the previous example by having an option "0" to repeat the menu so that the caller gets to hear the options again. You therefore include another option for keypress "0" with a routeto_type of "ivr". Because you want to route back to this menu, you can supply an ivrID of 0.

Also, you want to add another option "9" to redirect the caller to the switchboard on 02031002999. When being transferred to the main switchboard, you want your callers to hear a message saying "transferring you to the main switchboard" before being put through. For this you have previously used the telecoms.soundclip.create function to upload that sound clip and assign it the "ivr.prompt" role. This sound clip has soundclipID 84.

You also decide that they should be transferred here if they don't make a selection. Therefore you also define option "9" as the default choice.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
    "func" : "telecoms.ivr.create",
    "args" : {
       "options" : [
          {
             "routeto_type" : "number",
             "desc" : "sales team",
             "keypress" : "1",
             "destnumber" : "02031234567"
          },
          {
             "destnumber" : "01234567890",
             "keypress" : "2",
             "desc" : "support team",
             "routeto_type" : "number"
          },
          {
             "desc" : "switchboard",
             "routeto_type" : "number",
             "destnumber" : "02031002999",
             "keypress" : "9",
             "fg_soundclipID" : 84
          },
          {
             "routeto_type" : "ivr",
             "desc" : "repeat the menu",
             "keypress" : "0",
             "ivrID" : 0
          }
       ],
       "default_choice" : "9",
       "badchoice_fg_soundclipID" : 2,
       "desc" : "ACME Ltd main menu",
       "prompt_bg_soundclipID" : 1
    }
}

JSON example response:

{
   "success" : "1",
   "results" : {
      "ivrID" : "2",
      "eventID" : "1477545"
   }
}

Example 3

Set up a menu such that the caller enters a 3 digit code to choose who to be transferred to. If they enter 100, transfer the call over SIP to dave100@davesip.example.com. If they enter 101, pass them through to a route plan you've previously created with the telecoms.routeplan.create function, which gave it a routeplanID of 116. If they don't enter anything, just hang up.

Because Dave's SIP gateway is listening to SIP on a non-standard port (port 59001), we have to specifiy this as well in the SIP parameters.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
    "func" : "telecoms.ivr.create",
    "args" : {
       "desc" : "ACME Ltd main menu",
       "options" : [
          {
             "routeto_type" : "sip",
             "desc" : "Dave via SIP",
             "keypress" : "100",
             "destargs" : {
                "port" : "59001",
                "ext" : "dave100",
                "host" : "davesip.example.com"
             }
          },
          {
             "keypress" : "101",
             "routeplanID" : 116,
             "desc" : "support team",
             "routeto_type" : "routeplan"
          }
       ],
       "badchoice_fg_soundclipID" : 2,
       "prompt_bg_soundclipID" : 1
    }
}

JSON example response:

{
   "success" : "1",
   "results" : {
      "ivrID" : "3",
      "eventID" : "1477548"
   }
}