Live Chat

Quality SealVoiceNation is Your Quality Answering Service

% 877-774-1717

DASHBOARD LOGIN


You are here

Documentation

Working With SmartRoutes

Extending the capabilities of FreePBX

SmartRoutes is a powerful query builder for FreePBX that allows you to control the way inbound calls are routed. Below are two (2) examples of how you can use SmartRoute to improve your Asterisk platform.

The latest release of this module can be found at SmartRoutes home.

For documentation, tips, hints, and applications, visit help.

Submit a bug report at bugs.

Default Trunk Route

Should this SmartRoute be the iniital route for processing trunk calls?  (Note: Will bypass static routes - but can be sent to static routes as destination below).

Queries

Queries designates the initial search that the SmartRoute needs to perform. There are two types of Queries - Basic and Advanced.

Basic

  • Table
    The name of the table to search.
  • Search Column
    The name of the column to search
  • Look For
    Look for the "Extension", "Called Number (DID)", or "Caller ID".
  • Return Column
    What column should be returned when a match is found? Note that this value will be assigned to the Asterisk var DBRESULT.

Advanced

  • SQL
    The SQL query to use. You can return up to 5 columns and they will be assigned to the associated Asterisk vars. The first column returned will be the key used to match a destination below. The other columns can be assigned to Asterisk dialplan vars for use in the dialplan, as a CID name prefix, recorded into the CDR, etc.
    Note that any Asterisk vars in the query need to be indicated as they are in Asterisk with '${asteriskvar}'.
  • AST Vars 1-5
    Note: The first value returned is used for the destination match.
    Up to five results from the query can be assigned to Asterisk dialplan vars. Examples would be: CALLERID(name), CDR(userfield), OUTCID_2, or a custom variable that you put in the FreePBX Caller ID prefix field.
    Note that you can leave a return value blank and not assign a var.
    Note that the vars entered here do not need to be formatted as Asterisk vars but just include the var name.

Data Queries

These queries are used to pull data related to this call or route that can be used in the routing or for other purposes (like setting CDR fields or caller id name prefix).
Enter your own SQL with multiple returns (up to 5 returns per query). The returns will be assigned to the Asterisk vars specified so that they can be used in the dialplan (or replace/update existing Asterisk dialplan vars).
These queries are only performed if a match is found on the first return from the main query against destination match values below.

  • SQL
    Enter an SQL query to use. You can return up to 5 columns and they will be assigned to the associated Asterisk vars. The first column returned will be the key used to match a destination below. The other columns can be assigned to Asterisk dialplan vars for use in the dialplan, as a CID name prefix, recorded into the CDR, etc.
    Note that any Asterisk vars in the query need to be indicated as they are in Asterisk with '${asteriskvar}'.
  • Assign AST Vars 1-5
    Up to five results from the query can be assigned to Asterisk dialplan vars. Examples would be: CALLERID(name), CDR(userfield), OUTCID_2, or a custom variable that you put in the FreePBX Caller ID prefix field.
    Note that you can leave a return value blank and not assign a var.
    Note that the vars entered here do not need to be formatted as Asterisk vars but just include the var name.

Destinations

Destinations

  • Match Type
    When comparing the main query "key" and matching a destination, what type of operator should we use? EXACT looks for a perfect match. GREATER looks for the first match where the key is greater than the match. LESSER looks for the the first match where the key is lesser than the match.
  • Default Destination
    Default destination of this route if no match found. Choose between "Dynamic Routes", "Extensions", "Feature Code Admin", "IVR", "Phonebook Directory", "Queues", "SmartRoutes", "Terminate Call", OR "Trunks".

Database Settings

Settings

  • Database Type
    Select the database type you wish to use. Choose between "ODBC (Recommended)", OR "MySQL (Deprecated)"
  • MySQL Host
    Enter the MySQL Host (if using MySQL) DEPRECATED.
  • MySQL Database
    Enter the MySQL Database (if using MySQL).
  • MySQL Username
    Enter the MySQL Username (if using MySQL).
  • MySQL Password
    Enter the MySQL Password (if using MySQL).
  • Enable database tracking of current calls?
    This setting causes current calls to be tracked in a database for call traffic shaping with SmartRoutes. NOTE: It will require that this SmartRoute use the FreePBX 'asterisk' database (and the 'smartroutes_currentcalls' table).
    When enabled, current calls are tracked in a table so that you can perform a lookup in the table to count the number of calls to a specific DID, from a given CID, or in total and route calls differently based on the call volume. Using this feature, if a single DID floods your system with calls then you can send all calls (after the first xx calls) to a lower priority so that other customers/DIDs aren't affected or first send calls to a high-volume announcement. Sample settings to return the number of calls to this DID:
    host: localhost, database: asterisk, table: smartroute_currentcalls
    sql: SELECT COUNT(*) FROM (SELECT src,dst,uniqueid FROM smartroute_currentcalls WHERE (dst= AND calldate < DATE_SUB(NOW(), INTERVAL 2 MINUTE))) as T

Options

Options

Define the route settings for the SmartRoute.

  • Limit CID Digits
    Enter the trailing xx digits to keep from the caller ID (effectively stripping unnecessary prefixes). Leave blank or enter 0 for no stripping of initial caller ID digits. This is important if your SIP provider puts extra digits at the beginning of your caller ID number and that number format isn't accepted by another SIP provider the call may go out on.
  • Alert Info
    ALERT_INFO can be used for distinctive ring with SIP devices.
  • CID name prefix
    You can optionally prefix the Caller ID name. ie: If you prefix with "Sales:", a call from John Doe would display as "Sales:John Doe" on the extensions that ring.
  • Music on Hold
    Set the MoH class that will be used for calls that come in on this route. For example, choose a type appropriate for routes coming in from a country which may have announcements in their language.
  • Signal RINGING
    Some devices or providers require RINGING to be sent before ANSWER. You'll notice this happening if you can send calls directly to a phone, but if you send it to an IVR, it won't connect the call.
  • Pause Before Answer
    An optional delay to wait before processing this route. Setting this value will delay the channel from answering the call. This may be handy if external fax equipment or security systems are installed in parallel and you would like them to be able to seize the line.

Privacy

  • Privacy
    If no Caller ID has been received, Privacy Manager will ask the caller to enter their phone number. If an user/extension has Call Screening enabled, the incoming caller will be be prompted to say their name when the call reaches the user/extension.
  • Max Attempts
    Number of attempts the caller has to enter a valid callerID
  • Min Length
    Minimum amount of digits callerID needs to contain in order to be considered valid

Fax Detect

  • Detect Faxes
    Attempt to detect faxes on this DID.