Howto:Getting started with your own PBX voicemail script
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>
</syntaxhighlighting>
You will find a global ''voicemail'' tag. Within this tag you can define your own functions.<br>
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.
==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===
<syntaxhighlight xml>
<!-- 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
The most current VoiceMail XML language documentation can be found in vm.htm on www.innovaphone.com/xsd.