FreePBX Extension Registry HOW-TO

Discussion in 'PIAF 3 Add-Ons' started by tshif, Jan 17, 2009.

  1. tshif

    tshif Guru

    Joined:
    Jan 3, 2008
    Messages:
    1,240
    Likes Received:
    2
    FreePBX is designed to keep track of every extension used as a destination in your PBX. When fully utilized, the Extension Registry will prevent you from assigning the same extension more than once, as well as encourage a consistent approach to adding special functions. It also causes the function to show up on the FreePBX Feature Codes page, where it can be enabled, or disabled like any other system feature.

    Many of the best added functions for Asterisk come right from Nerd Uno at Nerd Vittles’ “YeOld Asterisk Add On Shoppe” and install script meister Tom King. I use them, I love them, I wouldn’t want to be without them. But – there has always been one thing I wanted to do for them – and that is get them to register with the FreePBX Extension registry.

    When a destination (such as the Weather Report, or Voice Reminders) inserts a dial plan directly into extension_custom.conf or extensions_override_freepbx.conf within the [from-internal-custom] context – you can bet it’s not properly registered with the FreePBX extension registry.

    I will use one of my favorite Nerd Vittles add –ons, as well as a simpler "Traffic Information" dial plan to demonstrate how you can convert a non registered dial plan fragment into a registered one without loosing any functionality.

    Once you have reviewed one or two of these variations, you should be able to use the same techniques to fine tune your own custom dial plan fragments into actual recognized and registered FreePBX destinations.

    Voice Reminders
    This has got to be one of the coolest applications out there – brought to us by Ward. It uses quite a few special contexts to do its job – and the good news is we get to leave virtually all of them unmodified in any way.

    After installing Voice Reminders as per the instructions found in the forum thread, Locate the dial plan (normally found in either extensions_custom.conf, or extensions_override_freepbx.conf) withing the [from-internal-custom] context, that looks like this:

    exten => 123,1,Answer
    exten => 123,2,Wait(1)
    exten => 123,3,Authenticate(123456)
    exten => 123,4,Goto(reminder,s,1)

    In this case, the extension is “hard wired” into the dial plan as 123. Of course, we could change those to any extension we want – but that won’t get it registered in FreePBX.

    Step one is to put this dial plan into its own context.
    To do that, move the dial plan to the END of the conf file, and place it in its own context called [voice-reminders]. (Don’t use [reminders], because the Voice Reminders already has a context called that!)

    Step two is to replace the hard-wired extension ‘123’ with the letter ‘s’ in all 4 lines of the dial plan. When your done, it should look like this:

    [voice-reminders]
    exten => s,1,Answer
    exten => s,2,Wait(1)
    exten => s,3,Authenticate(123456)
    exten => s,4,Goto(reminder,s,1)

    (Don’t forget to replace 123456 with your actual password)

    Save your changes in the config editor.

    Step three is to create a FreePBX Custom Destination with these settings:
    Custom Destination: voice-reminders,s,1
    Descriptions: Voice Reminders
    Submit your changes.

    Step four is to create a FreePBX Misc Application with these settings:
    Description: Voice Reminders
    Feature Code: whatever extension you want to assign to
    Feature Status: Enabled
    Destination: Custom Destinations: Voice Reminders
    Submit your changes.

    Step five, Apply Configuration Changes, And Continue with Reload.

    That’s all there is to it. Pick up any extension, and dial the number you assigned to the Voice Reminder function in Step 3. It should work as well as ever – and now the Voice Reminders Function is properly registered in FreePBX.

    Traffic Information
    This dial plan connects the user with the traffic Information voice response system. Normally it would be found in the [from-internal-custom] context, and look like this:

    exten => 872,1,Answer
    exten => 872,n,Wait(1)
    exten => 872,n,Playback(pls-wait-connect-call&digits/2&traffic&information)
    exten => 872,n,Dial(iax2/trunkid/18666987232)
    exten => 872,n,Hangup()
    exten => 872,t,Congestion()

    Using the same basic steps and techniques, well convert it to a FreePBX feature like we did with the Voice Reminders.

    Step one is to put this dial plan into its own context.
    To do that, move the dial plan to the END of the conf file, and place it in its own context called [traffic].

    Step two is to replace the hard-wired extension ‘872’ with the letter ‘s’ in all lines of the dial plan. When you’re done, it should look like this:

    [traffic]
    exten => s,1,Answer
    exten => s,n,Wait(1)
    exten => s,n,Playback(pls-wait-connect-call&digits/2&traffic&information)
    exten => s,n,Dial(iax2/trunkid/18666987232)
    exten => s,n,Hangup()
    exten => s,t,Congestion()

    (Don’t forget to replace trunkid with your actual trunk name)

    Save your changes in the config editor.

    Step three is to create a FreePBX Custom Destination with these settings:
    Custom Destination: traffic,s,1
    Descriptions: Traffic Info
    Submit your changes.

    Step four is to create a FreePBX Misc Application with these settings:
    Description: Traffic info
    Feature Code: whatever extension you want to assign to
    Feature Status: Enabled
    Destination: Custom Destinations: Traffic Info
    Submit your changes.

    Step five, Apply Configuration Changes, And Continue with Reload.

    That’s all there is to it. Pick up any extension, and dial the number you assigned to the Traffic Information function in Step 3. It should work as well as ever – and now the Traffic Info function is properly registered in FreePBX.

    Special Cases
    When you are working with a function that places outbound calls as part of its job, the original author may have written it assuming that it would always be running from inside the [from-internal-custom] context.

    Hotel Style Wakeup calls is an excellent example of such a special case. The script that creates the call files creates them in the same context from which it was run, [from-internal-custom].- which allows it access to the outbound routes.

    If you change it so that its running from its own context, such as [special-context-1], the call files it creates will attempt to dial out from that context – and fail.

    In cases like this, there are two possible ways to proceed.

    You may decide to edit the agi script to explicitly state that it will create call files in the [from-internal-custom] context.

    Alternately, in some cases it might work to include the [special-context-1] context in the [from-internal-custom] context.

    To do that, locate the [from-internal-custom] context, and add a line similar to the following:
    include => special-context-1

    In this way, the [special-context-1] context becomes a part of the [from-internal-custom] context, which may resolve this type of issue.

    By taking the time to use the FreePBX extension registry for our custom dial plans, we get the safety of FreePBX watching to make sure we don’t reuse and extension, we get the ability to manage the function on the FreePBX Feature Codes page, and we have a very consistent approach across the board for managing all aspects of the dial plan functions.

    -Tony
     
    krakastan likes this.
  2. foneman

    foneman Guru

    Joined:
    Oct 24, 2007
    Messages:
    297
    Likes Received:
    1
    Sticky That

    Great writeup.
     
  3. tshif

    tshif Guru

    Joined:
    Jan 3, 2008
    Messages:
    1,240
    Likes Received:
    2
    Well Thank's foneman! Always nice to hear kind words.

    Tony
     

Share This Page