Howto14r2:Getting started with your own PBX voicemail script: Difference between revisions
Line 47: | Line 47: | ||
// invalid version | // invalid version | ||
<exec url="http://192.168.0.5/script.pl?cgpn=$cgpn¶m=value&nextParam=nextValue"/> | <nowiki><exec url="http://192.168.0.5/script.pl?cgpn=$cgpn¶m=value&nextParam=nextValue"/></nowiki> | ||
// valid version | // valid version | ||
<exec url="http://192.168.0.5/script.pl?cgpn=$cgpn&amp;param=value&amp;nextParam=nextValue"/> | <nowiki><exec url="http://192.168.0.5/script.pl?cgpn=$cgpn&amp;param=value&amp;nextParam=nextValue"/></nowiki> | ||
==XML helper functions== | ==XML helper functions== |
Latest revision as of 13:03, 14 March 2025
The innovaphone voicemail is implemented as an XML script running in a PBX Voicemail object. While this is a pretty complete implementation of a voice box, it is possible to modify the script or even write your own scripts. Here is how to start.
Voice mail scripting is a quite powerful tool. Please note that "voice mail script" is rather a misnomer. You can support a variety of applications using this scripting language, not only voice mail.
Applies To
This information applies to
- All V6 and later PBX Platforms
More Information
System Requirements
The PBX voicemail object provides an interpreter for an XML based scripting language. This language is defined in a XML schema file vm.xsd and a documentation is available in vm.htm. Both files can be found in the schema folder in the voicemail application download package on the download page (beware: you must download the full "vm" package, not a single language package only).
To start your own voice mail derivative, just
- copy vm.xml (found in the \drive\CF0\VM\en|de) in your voicemail installation to a new name
- change the URL in the voicemail configuration page to point to the new script
- make the required changes to your new xml copy
To interface the voicemail to other web based applications (such as php or asp scripts on your web server), have a look at the exec tag in vm.htm.
Editing your xml file
Editing your xml script is much easier if you use a dedicated xml editor that is capable of reading the corresponding xml schema file (vm.xsd).
Structure
There is a predefined structure like this example:
<?xml version="1.0" encoding="utf-8" ?>
<voicemail>
<function define="Main">
<!-- some stuff -->
</function>
</voicemail>
You will find a global voicemail tag. Within this tag you can define your own functions.
If the script is executed the Main function will be executed automatically.
The Voicemail XML documentation can be found in https://www.innovaphone.com/xsd/vm.htm.
Global variables from PBX
As of 13r1, scripts that use email functionality (such as email.xml) do not need to include a definition of SMTP connection parameters. The static configuration data from PBX/Config/Authentication/Email Verification can be read in for this purpose.
The following script variables will yield those email settings when read.
- $_pbx_auth_email_server
SMTP server
- $_pbx_auth_email_host
Client host name
- $_pbx_auth_email_addr
Sender Email address
- $_pbx_auth_email_usr
Username for authentication
- $_pbx_auth_email_pwd
Password for authentication
- $_pbx_auth_email_sender
Sender name
Escaping URL parameters in exec command
If you use the exec command in your script you have to encode the &
with &
for additional URL parameters.
// invalid version <exec url="http://192.168.0.5/script.pl?cgpn=$cgpn¶m=value&nextParam=nextValue"/> // valid version <exec url="http://192.168.0.5/script.pl?cgpn=$cgpn&param=value&nextParam=nextValue"/>
XML helper functions
There is not a native method for every logical operation. Here are some helper functions where no native method exist.
disconnect control calls / calls without media
<!-- check if the incoming call was a control call without audio, eg. a presence call -->
<pbx-getcallinfo out-ctl-call="$ctl_call" />
<if cond="$ctl_call">
<dbg string="disconnect control call" />
<pbx-disc />
</if>
encode asterisk
The lib-enc method does not encode "*" in a string.
<function define="encode_asterisk">
<!-- expect existing variable called $string_encode_asterisk -->
<assign out="$string_position" value="1" />
<assign out="$string_position_finished" value="0" />
<assign out="$string_encode_asterisk_tmp" value="" />
<lib-strlen string="$string_encode_asterisk" out="$string_length" />
<while notcond="$string_position_finished">
<index out="$res" value="$string_encode_asterisk" pos="$string_position" size="1"/>
<switch var="$res">
<case equal="*">
<lib-strcat out-string="$string_encode_asterisk_tmp" string="$string_encode_asterisk_tmp" string2="%2a"/>
</case>
<default>
<lib-strcat out-string="$string_encode_asterisk_tmp" string="$string_encode_asterisk_tmp" string2="$res"/>
</default>
</switch>
<add value="$string_position" value2="1" out="$string_position" />
<switch var="$string_position">
<case greater="$string_length">
<assign out="$string_encode_asterisk" value="$string_encode_asterisk_tmp" />
<assign out="$string_position_finished" value="1" />
</case>
</switch>
</while>
</function>
remove first char
<function define="remove_first_char">
<!-- expect existing variable called $string_remove_first_char -->
<lib-strlen string="$string_remove_first_char" out="$file_length" />
<sub value="$file_length" value2="1" out="$file_length" />
<index out="$string_remove_first_char" value="$string_remove_first_char" pos="2" size="$file_length"/>
</function>
Related Articles
- Howto:How to Configure the innovaphone Voicemail
- Howto:Send Email MWI Notification From The innovaphone Voicemail
The most current VoiceMail XML language documentation can be found in vm.htm on www.innovaphone.com/xsd.