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.
Below is an excerpt from the live log.
EXAMPLE 1
We'll show how to put in a simple message into the log file.
- First, create a "description"
- LogMessageExample
- Then select SUBMIT
- Select the LogMessageExample heading that will appear on the upper right
- Now you will see more settings become available that you can use to enter in data.
- 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
- In the commands section, put in this:
NoOp( ########## This is a test #########) - For Destination select
FEATURE CODE ADMIN ---> *43 ECHO TEST - Configuration should now look like this:
- Select SUBMIT and Apply changes
- Call the "500" number from an extensions
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
- CREATE a PINS SET called "TESTPIN" and put a entry of 99
- Now Create a Dynamic Route called "SQLTEST"
(If you aren't familiar with dynamic routes, follow this link for deeper dive) - Select SOURCE TYPE as "Asterisk Variable"
- Variable String = ${PINNUMBER}
- Set 99 = feature code admin EchoTest
- Set 55 = Feature code admin Speaking Clock
Should look like this when you are done: - Save/Submit your changes
- Create a DialPlan Injection called SQLtest
- 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}) - Set the destination to be Dynamic Routes - SQLTEST
- Should look like this:
- Submit and apply your changes.
- 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. - Go into PINSET in the GUI and change 99 to 55, submit and apply your changes
- 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
Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.