Html |
---|
<div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.11'; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> |
...
Html |
---|
<div class="lang-box-pdf"> <div> <div class="google-lang"> <div id="google_translate_element"> </div> <script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en', includedLanguages: 'de,es,fr,it,nl', autoDisplay: false}, 'google_translate_element'); } </script> <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> </div> <div class="pdf-button"> <a href="#https://confluence.wildix.com/spaces/flyingpdf/pdfpageexport.action?pageId=23986355" alt="Convert to .pdf" title="Convert to .pdf"><img src="https://confluence.wildix.com/download/attachments/14549012/pdf-button-download-wildix-documentation.png"></a> </div> </div> </div> |
...
Info |
---|
Smart Dialplan explains how to use Custom Applications in Wildix Dialplan to interact with external software and databases. Updated: April 2018 Permalink: |
Table of Contents |
---|
Part 1: AGI in “Custom Application”
...
This Dialplan is assigned to user 102
NoOp function serves to display the variable value in logs:
Conditions in Dialplan
You can use execute a conditional jump to another Dialplan procedure, based on the boolean result (true or false) of the Gotoif function.
Syntax to execute a jump: GotoIf(condition?label1:label2)
...
The condition syntax is the following one: $[expr1operatorexpr2], where
expr can be a variable, a value, a function, an expression (expressions can be nested)
operator as a rule it is relational (comparison) operator ( =, <>..); for nested expressions it’s possible to use logical operators AND, OR, NOT (explained below)
...
expr1 >= expr2 → greater than or equal
Example:
In this example:
set(FOO=1) - we introduce FOO variable with the value 1.
...
condition: $[${FOO} = 1]
label1: users,101,1
label2: users,102,1
Condition practical examples and useful functions
Example 1: Check if a device is INUSE before sending a call.
GotoIf($[ ${DEVICE_STATE(SIP/100)} == NOT_INUSE ]?context,101,1)
The function DEVICE_STATE(SIP/100) returns the state of the device, results can be:
UNKNOWN | NOT_INUSE | INUSE | BUSY | INVALID | UNAVAILABLE | RINGING | RINGINUSE | ONHOLD
Example 2: Check if there are available users in a call group before sending a call.
GotoIf($[ ${QUEUE_MEMBER(2,ready)} == 0 ])?context,101,1)
The function QUEUE_MEMBER(2,ready) count the number of ready members of a call group which are identified by the ID 2
Example 3: check if the CALLERID(number) matches a regular expression
GotoIf($[${REGEX("^0[6-7][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$" ${CALLERID(number)})}]?noanswer,01,1)
The function REGEX("<regular expression>" <data>)returns true if the regular expression matches the data.
In the example above we check if the caller is a French mobile phone:
Start by 0 then a 6 or 7 then followed by 8 digits => ^0[6-7][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$
...
Set(foo=${CURL(http://192.168.1.1/echo.php)})
Dial(SIP/${foo})
Add parameters in CURL url
In the following example the PHP script returns “102” if “callernum” parameter is 0612345678, else the script returns “101”.
...
Set MySQL privileges for the PBX to be able to remotely access to this database.
Use DTMF in call
...
SayDigits(digits)
Says the digits, one by one, digits can be a variable.
SayNumber(number, gender)
Says number
gender is "f" for female voice; "m" - for male ;"c" - for neutral
Example:
Read(FOO,00000/smartdialplan/numcommande,3,,,10)
SayNumber(${FOO},f)
Dial(SIP/${FOO})
Implementation of Smart Dialplan: limited access to the phone based on the amount of credits purchased
...
You need to:
Upload PHP AGI (phpagi.sourceforge.net) to /var/www/agi/phpagi/phpagi.php
Upload test script to /var/www/scripts/test.php
...
Then you can use “remote script” in dialplan, example: Remote script
Microsoft SQL Integration
Create /rw2/var/www/scripts/sqllookup.php
Code Block |
---|
#!/usr/bin/php
<?php
require_once '/var/www/autoload.php';
$agi = new AGI();
$dsn="dblib:host=IP:PORT;dbname=DBNAMEK";
$conn = new PDO($dsn, "USER", "PASSWORD");
$cid = substr($agi->request[agi_callerid],1);
$sql = "Exec dbo.SPR_CRM_ValidateCustomer @Phonenumber = '".$agi->request[agi_callerid]."'";
fwrite(STDERR, "\n".$cid.$sql."\n");
$result = $conn->query($sql);
if ($result) {
foreach ($result as $row) {
$agi->exec('Set', "STOREID=". $row[StoreID]);
}
} else {
foreach ($conn->errorInfo() as $row) {
fwrite(STDERR, print_r($row));
}
fwrite(STDERR, "\nPDO::errorCode(): ". $conn->errorCode(). " ".$conn->errorInfo()."\n");
}
?> |
Call Remote script it in Dialplan:
...
Specify the call destination and the channel to use:
Channel: <channel>: Channel to use for the call.
CallerID: "name" <number> Caller ID, please note: it may not work if you do not respect the format: CallerID: "Some Name" <1234>
MaxRetries: <number> Number of retries before failing (not including the initial attempt, e.g. 0 = total of 1 attempt to make the call). Default is 0.
RetryTime: <number> Seconds between retries. Default is 300 (5 min).
WaitTime: <number> Seconds to wait for an answer. Default is 45.
If the call answers, connect it here:
Context: <context-name> Context in extensions.conf
Extension: <ext> Extension definition in extensions.conf
Priority: <priority> Priority of extension to start with
Set: Set a variable to be used in the extension logic (example: file1=/tmp/to)
Application: Application to run (use it instead of specifying context, extension and priority)
Data: The options to be passed to the application
Use Callfile in dialplan
Create a script file in /var/www/scripts dir.
This script will be executed by dialplan.
Copy a template file and move the duplicated file to /var/spool/callweaver/outgoing/
callfile.sh
Code Block |
---|
------------------------------------------------------ #! /bin/sh cp /var/www/scripts/test.call /var/www/scripts/temp.call mv /var/www/scripts/temp.call /var/spool/callweaver/outgoing/ ------------------------------------------------------ Give permissions to execute the script. #chmod +x /var/www/scripts/callfile.sh Create a template file in /var/www/scripts dir. Test.call ------------------------------------------------------ Channel: SIP/0276510950/0970720101 Application: Playback Data: 00000/callfile/message --------------------------------------------------------- |
Call a remote script in dialplan.
Part 4: use device comment field for customize CID of outgoing call
...