Reply
 
Thread Tools Display Modes
  #1  
Old 03-01-08, 01:27 AM
jeremywillden jeremywillden is offline
Guru
 
Join Date: Feb 2008
Posts: 145
Custom trunks for custom applications
This is more of a tutorial than a question. I did a lot of trial-and-error getting this figured out, so I wanted to document it somewhere (to benefit the whole PiaF community).

Background: I'm trying out VoicePulse for some of my outbound calling, but I want to use their "least cost" automatic routing function. In short, they provide some code to insert into your dialplan that does a cost lookup in real-time as the call is placed providing the per-minute charge for the call, allowing you to automatically route a call to another provider if the per-minute price is better. Their application code is available, but integrating it with a system while still using FreePBX for administering the system as a whole is not obvious (and not easy).

This technique is more universally applicable if you want to put just a little custom code in your system, but don't want to make everything else hard to maintain. I haven't completed the whole Voicepulse integration, but I've got a clean way to call custom code when dialing out through a trunk.

First, create a Custom Trunk in FreePBX
Browse to your.pbx.ip.address/admin and select Trunks. Click on "Add Custom Trunk." Set your Outbound Caller ID (I'm not sure if it will be used as configured, but it can't hurt) and, if desired, the Maximum Channels. For Dial Rules, make sure you don't accidentally pass a number without an area code by including the rules 1+NXXNXXXXXX, 1512+NXXXXXX (where 512 is your local area code). If you use a dialing prefix, you can add a 9| in front of the patterns to strip the extra digit, if desired. Finally, the Custom Dial String for this trunk is:

Local/$OUTNUM$@leastcost-custom

The "$OUTNUM$" token inserts the number dialed into the dial string. I used the context name "leastcost-custom," but you can call your context anything you like, but include "custom" in the name. Save the trunk and apply the settings.

Next, Create the Custom Context to handle the calls
Select "Tools" in FreePBX and go to "Config Edit" to add the custom context. Select the file "extensions-custom.conf" and add the following before the [from-internal-custom] context:
[leastcost-custom]
;exten => _X.,1,Dial(SIP/arrivaltel/${EXTEN},120,tr)
exten => _X.,1,Dial(IAX2/voicepulse1/${EXTEN},120,tr)
exten => _X.,2,Hangup

(Note that I have a commented out line for a SIP trunk, but I'm actually using an IAX2 trunk.)
Don't forget to click Update to save your changes and re-read config to apply the settings.
For the moment, this does nothing more than place the call out through the IAX2 trunk called voicepulse1 (the same name used in the "Trunks" section of FreePBX) but any arbitrary code can be inserted here, including routing to the least cost code from VoicePulse. I plan to update this post once I have that working.

Finally, Configure (an) outbound route(s) to use the trunk
Set this trunk as the only one for one of your outbound routes for testing. Once you are sure the code is working correctly, add the trunk to whatever outbound routes you please. Be sure that any Dial Patterns passed by the routes will be valid after being processed by your trunk Dial Rules.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:56 PM.


Design by Vjacheslav Trushkin, color scheme by ColorizeIt!.
Powered by vBulletin®
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007-2008, Ward Mundy & Associates