Author Topic: Dialplanex Package  (Read 13288 times)

benhathaway

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
    • View Profile
Dialplanex Package
« on: May 29, 2009, 10:42:06 AM »
All,

    I have made little package which adds a '#include' statement at the top and bottom of the dialplan allowing you to define your own completely custom dialplan apps in a seperate file and call them from the main file. You could either define  macro at the top of the dialplan and call it from a custom application defined from the Askozai GUI, or you could add to an existing context at the bottom of the dialplan using something like this (for example)
Code: [Select]
[internal] +
<dialplan command here>

    It's been working well for us here, but I would be very interested to know if anyone else has found much use for it? Please paste your example uses on this thread. Also - this is my first askozia package, and one of the first few times I've ever used php, so maybe my code could do with some critique. All comments are welcome!

Many thanks,

Ben Hathaway


benhathaway

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
    • View Profile
Re: Dialplanex Package
« Reply #1 on: June 01, 2009, 11:09:39 AM »
All,

     Here is a small update to the dialplanex package (Version 0.11). Many thanks to Devon from the inetd package for the suggested refactorings.

Code: [Select]
Changelog
---------
* Removed the shellcmd index node in the config file (Thanks to Devon from the inetd package)
* Added changelog file
* Moved the 'reloadExtensions' script out of the data subfolder
* Reworded the packed description to be more concise.

Regards,

Ben Hathaway

devon

  • Full Member
  • ***
  • Posts: 98
  • Karma: 4
    • View Profile
Re: Dialplanex Package
« Reply #2 on: June 07, 2009, 04:13:33 AM »
this is my first askozia package, and one of the first few times I've ever used php, so maybe my code could do with some critique

just wanted to say good job, I'm no pro but I like that all the action takes place in rc as function calls, and it's commented well...my knowledge of the asterisk dialplan is pretty limited, so I too would like to see some examples of how folks are using this...there's a humorous typo in the 'function shutdown()' comment...you must have typed your share of ios commands...

best regards,
devon

benhathaway

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
    • View Profile
Dialplanex : Autoattendant
« Reply #3 on: June 08, 2009, 09:54:12 AM »
Devon,

    Thanks for the notes Devon. Well spotted with the typo - I'd like to say it was deliberate, but I'm afraid it was pure subconcious irritation seeping through - that and lack of sleep caused by my newest daughter.

    Examples for dialplan? Again - I am not expert, but here is an AutoAttendant dialplan app that I have cooked up for Askozia. You would also need to upload/record voice prompts and put them in the right place as well. I would recommend the AstMedia package to help with this process.

Code: [Select]
[AutoAttendant]
;The 'parameters' are as follows
;set(OperatorExtension="number")  - the default extension to call as the operator
;set(disaPassword=XXXX) - if set, enables a Direct Inward Dialtone app
;
;Note that extension '9' at this prompt is the DISA app

include => internal
exten => s,1,Answer()
exten => s,n,BackGround(custom/welcome)
exten => s,n,WaitExten(4)

exten => 9,1,NoOp(Executing the Special DISA Extension)
exten => 9,2,GotoIf(${disaPassword}?3:i|1)
exten => 9,3,DISA(${disaPassword}|dial-anywhere)

exten => i,1,Playback(custom/notvalid)
exten => i,n,WaitExten(4)

exten => t,1,Playback(custom/transfering)
;exten => t,n,Macro(main|SIP/${OperatorExtension}|${OperatorExtension}|$OperatorExtension}|to)
exten => t,n,Dial(Local/${OperatorExtension}@internal)
exten => t,n,Hangup()

[dial-anywhere]
include =>  SIP-Handset-ID-Extension
;Choose a SIP Handset ID that allows dialing out of all providers

So this application can be 'called' from a normal askozia dialplan app as follows..

Code: [Select]
1,Answer()
2,Wait(1)
3,set(OperatorExtension="2001")
4,set(disaPassword=XXXX)
5,ChannelRedirect(${CHANNEL}|AutoAttendant|s|1)
6,Hangup()

I use the 'redirect' function rather than any kind of macro call as this effectively wipes the slate clean in terms of any existing dialplan pattern matches. Askozia includes a lot of catch-all type pattern matching at the top of each new application and this (I found) interferes with the code in the dialplan extension. However, channel variables are passed along nicely, so that's good.

Again - if anyone is more familiar with dialplan coding, please give me your comments / suggestions for improvements. To be honest - I imagine that an AutoAttendant feature is such a common requirement that we should package this up into it's own autoattendant package.... Maybe one day... after my daughter starts sleeping through the night... hopefully this will happen before I loose my sanity completely!

Regards,

Ben.
« Last Edit: June 08, 2009, 10:16:59 AM by benhathaway »

benhathaway

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
    • View Profile
Dialplanex : Callback
« Reply #4 on: June 08, 2009, 10:32:02 AM »
All,

     If anyone else is interested in novel dialplan apps, here is a Callback feature that I created for testing. It's not very elegant, but does the job I think. It goes like this:

     Extension number XXXX can be dialed from anywhere (particularly the AutoAttendant app mentioned in a previous post) followed by the phone number or extension you wish to call (including any provider-specific prefixes). You are then told that the callback has been initiated. It then hangs up. A few moments later Askozia will call the extension listed and offer you the music on hold. If you are expecting this, then you know to dial '0' to get the DISA dialtone, followed by the DISA password. This then gives you another dialtone and you can route the call down any other provider (or internal extension) that you may have definied. Here is the code:

Code: [Select]
;Performs a callback. For testing only

[macro-callback]
;Arguments:
; 1) The extension number to dial
; 2) callback destination context

exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,Playback(custom/callback)
exten => s,n,System(echo Channel: Local/${ARG1}@dial-anywhere > /var/spool/asterisk/callback.call)
exten => s,n,System(echo MaxRetries: 3 >> /var/spool/asterisk/callback.call)
exten => s,n,System(echo RetryTime: 30 >> /var/spool/asterisk/callback.call)
exten => s,n,System(echo WaitTime: 30 >> /var/spool/asterisk/callback.call)
exten => s,n,System(echo Context: ${ARG2} >> /var/spool/asterisk/callback.call)
exten => s,n,System(echo Extension: s >> /var/spool/asterisk/callback.call)
exten => s,n,System(echo Priority: 1 >> /var/spool/asterisk/callback.call)
exten => s,n,System(echo Callerid: Callback >> /var/spool/asterisk/callback.call)
exten => s,n,System(cp /var/spool/asterisk/callback.call /var/spool/asterisk/callback_backup.call)
exten => s,n,System(echo sleep 5 > /var/spool/asterisk/doCallback)
exten => s,n,System(echo mv /var/spool/asterisk/callback.call /var/spool/asterisk/outgoing/ >> /var/spool/asterisk/doCallback)
exten => s,n,System(sh /var/spool/asterisk/doCallback &)
exten => s,n,Hangup()

[callbackContext]
exten => s,1,set(disapassword=XXXX)
exten => s,n,Answer()
exten => s,n,waitExten(90|m)
exten => 0,1,disa(${disaPassword}|dial-anywhere)
exten => 0,n,NoOp(Fell out of DISA)
exten => 0,n,Hangup()
exten => i,1,Playback(custom/invalid)
exten => i,n,waitExten(10|m)
exten => i,n,Hangup()
exten => t,1,Hangup()

[dial-anywhere]
include =>  SIP-Handset-ID-Extension
;Choose a SIP Handset ID that allows dialing out of all providers

Then, to call the application I added some code to the 'bottom' dialplan extension to add callback handling. NNNN = extension prefix to use when initiating a callback.

Code: [Select]
[internal] +
exten => _NNNN.,1,NoOp(Callback initiated to : ${EXTEN:4})
exten => _NNNN.,n,Answer()
exten => _NNNN.,n,macro(callback|${EXTEN:4}|callbackContext|)
exten => _NNNN.,n,Hangup()

Anyway - I hope someone finds this useful or can help me perfect it a little. Again - you will also need to create the custom voice prompts and put them in the right place. AstMedia is probably the best way to do this.

Regards,

Ben Hathaway

kimran

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
    • View Profile
Re: Dialplanex Package
« Reply #5 on: June 09, 2009, 06:47:38 PM »
have u guys tried Giovanni's auto attendant,it works great.

socrat3

  • Full Member
  • ***
  • Posts: 57
  • Karma: -1
    • View Profile
Re: Dialplanex Package
« Reply #6 on: June 21, 2009, 11:59:46 PM »
but where put the code ?

nttranbao

  • Jr. Member
  • **
  • Posts: 26
  • Karma: 0
    • View Profile
Re: Dialplanex Package
« Reply #7 on: August 12, 2009, 05:21:50 AM »
Thank you very much for this amazing tool. It works like I want it to.  Thanks for the #include, now I have full dialplan programming feature.

Also for your IVR, works like a charm. It really saves me some times coding.

@socrat3: you put your custom dialplan in /storage/dialplanex.pkg/data/extendedDialplan_top.conf

Regards,

Bao Nguyen
« Last Edit: August 12, 2009, 05:23:34 AM by nttranbao »

josepedro

  • Newbie
  • *
  • Posts: 17
  • Karma: 3
    • View Profile
Re: Dialplanex Package
« Reply #8 on: March 03, 2010, 02:35:30 AM »
Hello Ben. I need your package to do some testing but, where can I download it? I can't see any link to download it.

josepedro

  • Newbie
  • *
  • Posts: 17
  • Karma: 3
    • View Profile
Re: Dialplanex Package
« Reply #9 on: March 03, 2010, 09:29:52 AM »
I'm sorry Ben. It was too late yesterday and I didn't even see the links...
I'll test it and tell you all about it.
Thanks a lot!

josepedro

  • Newbie
  • *
  • Posts: 17
  • Karma: 3
    • View Profile
Re: Dialplanex Package
« Reply #10 on: April 20, 2010, 02:07:12 PM »
OK. Now I know the issue about the links. You can only see the links and download the package if you login to the forum. You cannot see it as guest.
I have been testing this package and it is just great! My goal was to setup an Automatted Attendant or IVR to implement the typical "If you know your party's extension, please dial it know..." working. There is no way to make this work with the standard Askozia distribution but you can do it using your package. Askozia 1.x is based on Asterisk 1.4.x but some things work a little different than in Asterisk 1.4.x, and this is one of them. I had a SuSE Linux box with Asterisk 1.4.x running and I already had this code working fine in that box:
Code: [Select]
exten => s,1,Wait,1 ; Wait a second
exten => s,2,Answer ; Answer the line
exten => s,3,DigitTimeout(12) ; Set Digit Timeout to 12 seconds
exten => s,4,ResponseTimeout(30) ; Set Response Timeout to 30 seconds
exten => s,5,BackGround(message) ; Your message "If you know your party's extension..."
exten => s,6,Dial(SIP/9&SIP/1005&SIP/1011&SIP/1014,10)
exten => s,7,Dial(SIP/9&SIP/1001&SIP/1004&SIP/1005&SIP/1006&SIP/1014,5)
exten => s,8,Dial(SIP/9&SIP/1001&SIP/1003&SIP/1004&SIP/1005&SIP/1006&SIP/1007&SIP/1009&SIP/1014,8)
exten => s,9,Voicemail(9999) ; General Voicemail
exten => s,10,Hangup ; Hangup the call

exten => t,1,Hangup

exten => i,1,Goto(s,6)

This code doesn't work in Askozia 1.x because Askozia "captures" and "applies" directly the first keystroke on the calling phone, so if somebody calls from outside, and he is hearing the message and he presses "1002" to get to that extension, Askozia 1.x captures and applies only the first digit (only number 1 in this case) and completely ignores the rest of the keys pressed by the user.
Using the dialplanex package, however, you can do this, and it works fine. First, I downloaded and installed the Recordings pacakge to create my custom message and I called it "message.gsm". Then, following your instructions I created an application that calls an Asterisk 1.4.x menu and this works fine.
In fact, this is great because you can see in all the Askozia web site, the support site and the forums, everyone states that "Askozia 1.x does not support a complete IVR or Automatted Attendant". Well this is true with the standard distribution but if you add this package, you can have a complete IVR. At least, I think you can set up any IVR that Asterisk 1.4.x supports. Somebody can correct me with this statement if I am wrong about it.

josepedro

  • Newbie
  • *
  • Posts: 17
  • Karma: 3
    • View Profile
Re: Dialplanex Package
« Reply #11 on: April 26, 2010, 01:17:49 PM »
This is a IVR example that I have already running. I will show how to set it up step by step so everyone can understand it and use it:

1.- Download and install the Recordings Package. Once you have it running, record a message that says "If you know your party's extension dial it now, if not wait please" and once you have recorded it, rename it "message.gsm".

2.- Create a new application. Mine is using extension 00001111 and it is called "Main Menu" but you can choose the extension number and the name you want. Use this code for the application:
Code: [Select]
1,Answer()
2,Wait(1)
3,ChannelRedirect(${CHANNEL}|MenuAsterisk|s|1)
4,Hangup()

3.- Create a new file called "extendedDialplan_top.conf". You can do this in your own computer. Copy this code inside this file:
Code: [Select]
[MenuAsterisk]

include => internal

exten => s,1,Wait,1 ; Wait a second
exten => s,2,Set(DATAPATH=/storage/recordings.pkg/data/recordings)
exten => s,3,Answer ; Answer the line
exten => s,4,Background(${DATAPATH}/message) ; Welcome message
exten => s,5,Dial(SIP/9&SIP/1005&SIP/1011&SIP/1014|10|tom)
exten => s,6,Voicemail(9) ; General Voicemail
exten => s,7,Hangup ; Hangup the call

exten => t,1,Hangup

exten => i,1,Goto(s,5)

4.- Copy this file to your askozia box to the /storage/dialplanex.pkg/data location. There are several ways to do this but the easiest way to do it is installing and using the inetd Package.

5.- Edit your each one of your Providers and select in "Incoming Extensions" the Application you created in step 2.

As you can see, we are using extension number 9 for our operator, and Voicemail(9) gets you to the operator's voicemail.

This example implements the "if you know your party's extension..." feature, but you could easily set up any asterisk 1.4.x IVR following this example.