Wednesday, March 11, 2020

Dialplan Injection Asterisk

Here's some examples of how to use the Dialplan Injection module in the ISSABEL PBX asterisk distribution.

EXAMPLE 1

We'll show how to put in a simple message into the log file.


  1. First, create a "description"
  2. LogMessageExample
  3. Then select SUBMIT
  4. Select the LogMessageExample heading that will appear on the upper right
  5. Now you will see more settings become available that you can use to enter in data.
  6. Extension:  Put in an extension number that you can call that will activate this.  Can be a test number.  500 has been used in this example
  7. In the commands section, put in this:

    NoOp( ########## This is a test #########)
  8. For Destination select
    FEATURE CODE ADMIN --->  *43 ECHO TEST
  9. Configuration should now look like this:
  10. Select SUBMIT and Apply changes
  11. Call the "500" number from an extensions

Below is an excerpt from the live log.

You'll see in the LIVE log your code being executed and displaying the "This is a test" message and the dialplan continuing onto *43 Echo Test




EXAMPLE 2

Here's something more advanced.

We'll use dialplan injection to query the SQL database for a dataset, then use dynamic routes to direct the call based on the value returned.

Disclosure
We can do this example below using DYNAMIC ROUTES only, but were showing how we can collect a variable and pass it between modules in a call.

The DIALPLAN INJECTION  will read the PINSET database and pull a value in it.

Then the DYNAMIC ROUTES will send the call based on the value the DIALPLAN INJECTION module retrieved

If its a "99" we'll send it to ECHOTEST
If its a "55" we'll send it to a SPEAKING CLOCK

  1. CREATE a PINS SET called "TESTPIN" and put a entry of 99
  2. Now Create a Dynamic Route called "SQLTEST"
    (If you aren't familiar with dynamic routes, follow this link for deeper dive)
  3. Select SOURCE TYPE as "Asterisk Variable"
  4. Variable String = ${PINNUMBER}
  5. Set 99 = feature code admin EchoTest
  6. Set 55 = Feature code admin Speaking Clock

    Should look like this when you are done:
  7. Save/Submit your changes
  8. Create a DialPlan Injection called SQLtest
  9. Extension: The number you call to run this script

    COMMANDS
    the following below.  Change dblogin/dbpass for your SQL server)

    Set(dblogin=LOGIN)
    Set(dbpass=PASSWORD)
    MYSQL(Connect connid localhost ${dblogin} ${dbpass} asterisk)
    MYSQL(Query resultid ${connid} select passwords from pinsets where description 'TESTPINS')
    MYSQL(Fetch fetchid ${resultid} PINNUMBER)
    NoOp(##### retrived ${PINNUMBER})
    MYSQL(Disconnect ${connid})
    MYSQL(Clear ${resultid})
  10. Set the destination to be Dynamic Routes - SQLTEST
  11. Should look like this:
  12. Submit and apply your changes.
  13. Run your script by dialing the 500 test number

    You should get a "You are now in an echo test" when you make your call.
  14. Go into PINSET in the GUI and change 99 to 55, submit and apply your changes
  15. Run your script by dialing the 500 test number

    You should get a "The Current Time is..." when you make your call.

    The code will query the PINSET database, pull the value of TESTPINS and store it "PINNUMBER" variable.  It is Passed to Dynamic Routes and the variable controls the call direction.

Here is what the log should look somewhat look like.


Example 3

Quick example, if selections are made in an IVR you can use this to track the picks

In dialplan injection use this code to store the text VALUE in the userfield in the CDR tabel

set(CDR(userfield)=VALUE)

This example shows how each IVR selection can be saved




No comments:

Post a Comment