Provider AGI script

From Kolmisoft Wiki
Revision as of 15:17, 18 April 2016 by Ricardass (talk | contribs)
Jump to navigationJump to search

This topic is ADVANCED and shows how to MODIFY MOR call flow. Please do not use this functionality if you are not sure what you are doing!

Asterisk AGI knowledge is necessary to use this feature.

What is it for?

This feature allows to execute custom script which tells MOR to either allow or reject call to specific Provider. This is useful if you require some additional number/Provider validation which is not implemented in MOR.

How does it work?

If this feature is enabled then MOR Core executes custom AGI script. Script is executed just before dial command of each Provider (after all other validations are done by Core). MOR Core passes these variables to script:

  • MOR_AGI_DESTINATION - localized destination number.
  • MOR_AGI_PROVIDER_ID - Provider id which is being validated.

AGI script should validate number/Provider and set these variables back to Core (via AGI):

  • MOR_AGI_STATUS - this variables tells core to allow/reject call. If value is 1, then call is allowed. If value is 0, then call is rejected. This variable is required!
  • MOR_AGI_RESPONSE - variable is used to pass description of why call was rejected or allowed to go to Provider. For example, this variable could contain message "Number is blocked". Variable is optional.
  • MOR_AGI_RUN_TIME - if your script calculates run time, then you can set elapsed time to this variable. Variable is optional.
  • MOR_AGI_TIMEOUT - in case your script has timeout prevention and you want to reject call on timeout, you may set this variable value to 1 and then core will reject call when AGI script timeouts. Variable is optional.

As you can see, call flow can be controlled by using variables MOR_AGI_STATUS and MOR_AGI_TIMEOUT. Also note that variable MOR_AGI_STATUS is required and call will be rejected if this variable is missing (or value is not 1).

If AGI script returns MOR_AGI_STATUS = 0 and rejects call, then other Providers will not be checked. Call will be terminated completely. Following hangupcause codes are assosiated with this feature:

  • 266 Provider skipped because AGI script returned timeout error
  • 267 Provider skipped because AGI script rejected this provider (AGI script status 0)


How to enable this feature

For this feature to work, you need to enable 'Execute AGI script' in selected Provider settings. In addition, you have to set path to AGI script in mor.conf configuration file (variable execute_agi_script).

Example script