About | Lab | Neigborhood | Most popular | Help us | Forums

Panoramisk / The VoIP druid 

Annonce

On peut être passionné par la téléphonie et prendre soin de soi : "Faites du sport, faites du vélo" est la devise du site d'e-commerce lancé par l'un des auteurs de Panoramisk : bikeo. Si vous faites du vélo, que ce soit en ville, sur la route ou sur les chemins plus accidentés, n'hésitez pas à aller faire un petit tour sur www.bikeo.fr pour vos prochains achats verts.
En plus leur plate-forme de téléphonie utilise Asterisk, comme quoi on peut la convergence est une réalité.

Asterisk::Configure

Context

Writing call plan in extensions.conf for Asterisk can be cumbersome. It is first mandatory to use a text editor, more often a specific format should be respected with one very laborious task of numbering each action of an extension group.

After having made a lot of configuration with many mistakes and time wasted on this specific action, we decided to build a lighter language and a specific tool to create the extensions.conf file. It is available as a library for Perl language and called Asterisk::Configure.

The last release is 1.02

Installing

Since we propose a Perl library, you will need the interpreter, most of UNIX’s systems nowadays have the Perl language pre-installed or available as a package, see your favourite UNIX documentation in order to install it the easiest way.

Then you can download the library : Asterisk-Configuration-1.02.tar.gz.

Installing the module requires the following actions:

  • tar zxf Asterisk-Configuration-1.02.tar.gz
  • cd Asterisk-Configuration-1.02
  • perl Makefile.PL, this action prepares the installation, maybe some required module would be necessary at this step.
  • make install (this is the installation in the Unix directory structure, this action requires to be root).
  • make test: this action is optional, but would verify everything is correctly installed and fully functional. All 20 tests should pass..
  • make clean to clean the temporary directory.

How to use it

What is proposed is a library, you should thus use it in Perl scripts, one is available to start with: exemple-configure.pl.

File format

The syntax used in the files that will be transformed in extensions.conf compatible files is looking like:

 file to-be-created.conf {
     context first-context {
          exten s {
 	    ; comment to be inserted in the final file
            ; command as usual for Asterisk
 	    Set(phone=${CUT(CHANNEL,-,1)})
            Hangup()
          }
     }

     context second-context {
 	exten s {
 	    Set(phone=${CUT(CHANNEL,-,1)})
            ; here we do a Goto towards line prefixed by %%L1%% or %%HANG%%
 	    GotoIf($["${agent}" = ""]?%%HANG%%:%%L1%%)
 	    ;
 %%L1%%     Set(i=1)
 	    Set(q=${DB(agents/queue/${agent})})
 	    Set(del_queue=${CUT(q,',',${i})})
 	    Playback(agent-loggedoff)
 	    Playback(privacy-thankyou)
 %%HANG%%   Hangup()
 	}
     }
 }

More than one file can be created from one original source, each file can contain various contexts. Each context is written with the Asterisk standard syntax, but the extension and the priority are suppressed, since the first is already mentioned at bloc beginning and lines will be numbered automatically.

Each line can be prefixed by a label between %%. This label could be use in application commands like Goto and GotoIf1.

How to use library

Object creation is performed through constructor with either a file name:

$conf = new Asterisk::Configure( File => “file.ast” );

If required a content can be passed directly:
ConfigText:

$c = <<EOF;
file f1.conf {
     context c1_t2-t3 {
	  exten s {
	      Answer()
	      Wait(5)
	      Hangup()
	  }
     }
}
EOF
$conf = new Asterisk::Configure(ConfigText => $c);

Next we process the content and create the call flow with a:

$conf->create;

In order to get the results of the create function, we can get the file list with $conf->getFileList() and each file content for printing or saving on a real file with a $conf->getFile(”f1.conf”) where the argument is the file name.

Improvements

This library is still under development, we try to add features that are required by our customers and ourselves on the flow. If you use it, don’t hesitate to inform us about what could be improved, fixed or add, leave us an email at dev@panoramisk.com.


  1. Gosub and GosubIf aren’t yet implemented []

© 2008 Panoramisk | Creative Commons License wordpress logo