Board logo

標題: Some useful dialplans [打印本頁]

作者: ckleea    時間: 2011-10-1 16:27     標題: Some useful dialplans

To reload asterisk
  1. exten = 700,1,Playback(posix-restarting)
  2. exten = 700,2,Wait(1)
  3. exten = 700,3,System(/usr/sbin/asterisk -rx reload)
  4. exten = 700,4,Hangup
複製代碼
settings

To record a message
  1. exten = 310,1,Answer
  2. exten = 310,2,Wait(2)
  3. exten = 310,3,Record(asterisk-recording%d:gsm)
  4. exten = 310,4,Wait(2)
  5. exten = 310,5,Playback(${RECORDED_FILE})
  6. exten = 310,6,Wait(2)
  7. exten = 310,7,Hangup
複製代碼

作者: 角色    時間: 2011-10-1 21:16

看ckleea的东西,犹如看报纸的副刊(如果北方人的说话就如小品)一样。

谢谢ckleea。

角色
作者: bubblestar    時間: 2011-10-1 22:48

Just tried Asterisk reload using the keypad, it works and very convenient.  Thanks ckleea c-hing.  Well done!
作者: ckleea    時間: 2011-10-1 22:49

回復 3# bubblestar

Please share yours as well.
作者: bubblestar    時間: 2011-10-1 22:54

Adding number to blacklist
  1. [blacklist-add]
  2. exten => *22,1,Answer
  3. same => n,Playback(enter-num-blacklist)
  4. same => n,Read(blacklist,then-press-pound,0,,2,10)
  5. same => n,SayDigits(${blacklist})
  6. same => n,Playback(if-correct-press&digits/2)
  7. same => n,Noop(Waiting for input)
  8. same => n,WaitExten(60,)
  9. same => n,Playback(sorry-youre-having-problems&goodbye)
  10. exten => 2,1,Set(DB(BLACKLIST/${blacklist})=1)
  11. same => n,Playback(num-was-successfully&added)
  12. same => n,Wait(1)
  13. same => n,Hangup
複製代碼
Removing number from blacklist
  1. [blacklist-rmv]
  2. exten => #22,1,Playback(entr-num-rmv-blklist)
  3. same => n,Read(blacklist,then-press-pound,0,,2,10)
  4. same => n,SayDigits(${blacklist})
  5. same => n,Playback(if-correct-press&digits/1)
  6. same => n,Noop(Waiting for input)
  7. same => n,WaitExten(60,)
  8. same => n,Playback(sorry-youre-having-problems&goodbye)
  9. exten => 1,1,DBdel(BLACKLIST/${blacklist})
  10. same => n,playback(removed)
  11. same => n,Hangup
複製代碼

作者: 角色    時間: 2011-10-1 22:59

The following script is to record the conversation in the OBi110 channel
  1. ;119 OBi110 OBiTalk
  2. [trunk-obi110-obitalk]
  3. exten => _119.,1,MixMonitor(${EXTEN:3}.wav,a)
  4. exten => _119.,n,Dial(SIP/**9${EXTEN:3}@1910,,)
  5. exten => _119.,n,Hangup()
複製代碼

作者: ckleea    時間: 2011-10-5 20:06

本帖最後由 ckleea 於 2011-10-5 21:10 編輯

I use this dialplan to solve the problem of unable to detect DTMF in WaitExten application.

Now I can use this to answer PSTN to Asterisk, then properly read the DTMF keystrokes and proceed
  1. [ivr-0]
  2. exten => 1001,1,Answer
  3. exten => 1001,n,SIPDtmfMode(rfc2833)
  4. exten => 1001,n,Wait()
  5. exten => 1001,n,Background(thank-you-for-calling,m)
  6. exten => 1001,n,Background(vm-enter-num-to-call,m)
  7. exten => 1001,n,Read(Newext,,9)
  8. exten => 1001,n,GotoIf(${Newext:0:1} = 2,3,6?dlocal)
  9. exten => 1001,n,GotoIf(${Newext:0:1} = 9?dhk)
  10. exten => 1001,n,GotoIf(${Newext:0:1} = 0,4,5,7,8?derr)
  11. exten => 1001,n(dlocal),Dial(LOCAL/${Newext})
  12. exten => 1001,n(dhk),DIAL(SIP/**8133${Newext:1}@obitrunk)
  13. exten => 1001,n(derr),Goto(1001,1)
  14. ;exten => 1001,n,WaitExten()
  15. ;exten => 1001,n, Dial(LOCAL/${Newext})
  16. ;exten => 1001,n,Goto(1001,1)
  17. exten => 1001,n,Hangup
複製代碼

作者: 角色    時間: 2011-10-5 20:25

It seems that your code is different from mine.

YH
作者: ckleea    時間: 2011-10-5 20:39

回復 8# 角色


    Still not complete. Something wrong. But it is approaching success.
作者: ckleea    時間: 2011-10-5 21:10

code updated
作者: 角色    時間: 2011-10-5 21:43

My IVR
  1. ;################## PSTN Gateway ########################

  2. ;TW IVR
  3. exten => 1130,1,Answer
  4. ;exten => 1130,n,Wait(5)  ;for polly TW IVR
  5. exten => 1130,n,Wait(3)
  6. exten => 1130,n,Background(vm-enter-num-to-call)
  7. exten => 1130,n,WaitExten
  8. exten => 1130,n,Playback(vm-goodbye)
  9. exten => 1130,n,Hangup
  10. exten => i,1,Playback(pbx-invalid)
  11. exten => i,2,Goto(1130,1)
  12. exten => t,1,Playback(vm-goodbye)
  13. exten => t,2,n,Hangup
複製代碼

作者: 角色    時間: 2011-10-5 21:44

回復 10# ckleea

你的没有i,t这样的东西。

i: invalide 的时候执行
t: timeout的时候执行

角色
作者: ckleea    時間: 2011-10-5 21:59

回復 12# 角色

I can tell you that my Waitexten cannot accept digit starting from 9
作者: bubblestar    時間: 2011-10-5 22:26

回復 6# 角色


   
Can I use this to record other Asterisk channels?
作者: ckleea    時間: 2011-10-5 22:28

回復 14# bubblestar

Yes. Mximonitor can do
作者: bubblestar    時間: 2011-10-5 22:44

本帖最後由 bubblestar 於 2011-10-5 22:48 編輯

回復 13# ckleea


   
If you doubt about WaitExten(), you should also check whether you have set the autofallthough = yes in the general section under extensions.conf.  They have close relationship with each other after Asterisk version greater than 1.2

http://www.voip-info.org/wiki/view/Asterisk+cmd+WaitExten

Notes
WaitExten does not work in a Macro!
The autofallthrough setting was introduced in Asterisk 1.2 now defaults to 'yes' in Asterisk 1.4; if your dialplan relies on the ability to 'run off the end' of an extension and wait for a new extension without using WaitExten() to accomplish that, you will need set autofallthrough to 'no' in your extensions.conf file. If you want to set autofallthrough to 'no', you must go through your dialplan and add WaitExten() at every place where execute would run off the end of an extension and wait for another one to be dialed.
An examination of the source code seems to suggest that TIMEOUT(response) and TIMEOUT(digit) do not have any effect on WaitExten.


For info., I have my autofallthrough set to yes from the very first beginning when setting up my server.
作者: ckleea    時間: 2011-10-5 22:49

回復 16# bubblestar

I try already but not succeed. Still accepting one to two digits only.
作者: bubblestar    時間: 2011-10-5 23:01

回復 17# ckleea


        
To my understanding, the command Answer() is set to 0.5 seconds by default when picking up the line.  If the same rule is also applied for WaitExten(), only 0.5 seconds is not enough for the caller to input all 8 to 10 digits before it expires.

Hence, I have set WaitExten(10) in my IVR to allow adequate input time.  I found that yours is just using default WaitExten().  You may try to set longer time to accommodate all 8 - 10 digits instead of just 2 as you encountered.
作者: ckleea    時間: 2011-10-6 05:57

回復 18# bubblestar

In fact I have tried various option within WaitExten()
作者: 角色    時間: 2011-10-7 07:19

本帖最後由 角色 於 2011-10-7 09:10 編輯

I do not know whether your gain setting is correct or not?

You may use analogue method by making voice call from your mobile phone to your extension directly and observe the voice volume. In fact, we need a spectrum analysis which would be useful.

YH
作者: ckleea    時間: 2011-10-7 09:02

回復 20# 角色

My set up is to use HKBN 2b for incoming and then go out via PSTN connect via ATA.

HKBN 2b per se is a VOIP connection in my understanding though other people may think it is a PSTN because they can dial in via any physical phone they have.

I suggest you also try to put up 2b into your asterisk 1.8 to test run. I do encounter a few problem now after iphone apps for 2b is available.

Sometimes: registered but cannot dial in or out. Dialing in will ring my iphone despite the apps has been turned off
Sometimes: registered but go to 2b voicemail
Sometimes: dial out always failed.
作者: ckleea    時間: 2011-10-14 06:35

Another macro to handle incoming call
  1. [macro-phone]
  2. exten => s,1,Dial(SIP/${MACRO_EXTEN},25)
  3. exten => s,n,Goto(${DIALSTATUS},1)
  4. exten => ANSWER,1,Hangup
  5. exten => CANCEL,1,Hangup
  6. exten => NOANSWER,1,Voicemail(${MACRO_EXTEN}@default,u)
  7. exten => BUSY,1,Voicemail(${MACRO_EXTEN}@default,b)
  8. exten => CONGESTION,1,Voicemail(${MACRO_EXTEN}@default,b)
  9. exten => CHANUNAVAIL,1,Voicemail(${MACRO_EXTEN}@default,u)
  10. exten => a,1,VoicemailMain(${MACRO_EXTEN}@default)

  11. ; usage
  12. [users]
  13. exten => 5001,1,Macro(phone)
  14. exten => 5002,1,Macro(phone)
複製代碼

作者: ckleea    時間: 2011-10-14 06:45

Superdial macro
  1. [macro-superdial]
  2. ; add some abilities to Dial(Technology/resource[&Technology2/resource2...][|timeout][|options][|URL]):
  3. ;       ${ARG1} - Technology/resource[&Technology2/resource2...] (like SIP/2201)
  4. ;       ${ARG2} - timeout in seconds
  5. ;       ${ARG3} - Dial command options
  6. ;       ${ARG4} - URL (see Dial command for info)
  7. ;       ${ARG5} - Group name (used if you want to limit the number of calls in any way)
  8. ;       ${ARG6} - Max. group number (maximum number of concurrent calls you want to allow for that group)
  9. ;       ${ARG7} - Caller ID name (typically for outgoing calls only)
  10. ;       ${ARG8} - Caller ID number (typically for outgoing calls only)
  11. ;       ${ARG9} - CDR account name (over-rides account group setting in sip.conf or iax.conf)
  12. ;       ${ARG10} - voicemail to send to if noanswer (typically for incoming calls only)
  13. ; Usage instructions:
  14. ;       for an outgoing call, in extensions.conf you just list multiple lines like:
  15. ;               exten => s,1,Macro(superdial,IAX2/voipjet/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,voipjet)
  16. ;               exten => s,2,Macro(superdial,IAX2/alpeh-com/${tfnumber},,,,voip,${MAXVOIPCALLS},yourname,8005551234,aleph)
  17. ;       and it will take the first one that is available
  18. ;
  19. ;       it also works for incoming like so ..
  20. ;               exten => s,1,Wait(2)
  21. ;               exten => s,2,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
  22. ;               exten => s,3,Macro(superdial,${PHONE1},15,Ttm,,pstn,${MAXPSTNCALLS},${CALLERIDNAME},${CALLERIDNUM},pstn,u${GENERALVM})
  23. ;               exten => s,4,Voicemail(b${GENERALVM})
  24. ;       and then goes to unavailable voicemail if one times out .. otherwise (eg if busy) it tries the next extension
  25. ;       if all are busy or unavailable .. it gets to the last priority which is the busy voicemail
  26. ;
  27. exten => s,1,Set(GROUP()=${ARG5})
  28. exten => s,2,Set(GROUPCOUNT=${GROUP_COUNT(${ARG5})})
  29. exten => s,3,GotoIf($[${GROUPCOUNT} > ${ARG6}]?104)
  30. exten => s,4,GotoIf($["${ARG7}" = ""]?macro-superdial,s,6)
  31. exten => s,5,Set(CALLERID(name)=${ARG7})  ; skip this if ARG7 is empty
  32. exten => s,6,GotoIf($["${ARG8}" = ""]?macro-superdial,s,8)
  33. exten => s,7,Set(CALLERID(number)=${ARG8})  ; skip this if ARG8 is empty
  34. exten => s,8,GotoIf($["${ARG9}" = ""]?macro-superdial,s,10)
  35. exten => s,9,SetAccount(${ARG9})  ; skip this if ARG9 is empty
  36. exten => s,10,Dial(${ARG1},${ARG2},${ARG3},${ARG4})
  37. exten => s,11,Goto(s-${DIALSTATUS},1)
  38. exten => s,104,Goto(s-CHANUNAVAIL,1)
  39. exten => s-BUSY,1,Noop
  40. exten => s-NOANSWER,1,GotoIf($["${ARG10}" = ""]?macro-superdial,s-NOANSWER,3)
  41. exten => s-NOANSWER,2,Voicemail(${ARG10})
  42. exten => s-NOANSWER,3,Noop
  43. exten => _s-.,1,Noop
複製代碼

作者: bubblestar    時間: 2011-10-14 10:05

回復 22# ckleea


   
Thanks ckleea c-hing.  This new dialplan is even neater than the one (also using macro) that I am using.  I will replace mine with this one if it can run smoothly after test.
作者: bubblestar    時間: 2011-10-14 10:14

回復 23# ckleea


   
It seems a new improvement has been made on this code.  I will go through the details later tonight but could you briefly highlight the differences between this one with our existing macro super dial ?
作者: ckleea    時間: 2011-10-15 00:13

I have moved all my macro into another conf file to make my extensions.conf nice and tidy.

I will follow this direction to clean up all the unnecessary and clumsy ordering of different labels.
作者: bubblestar    時間: 2011-10-15 00:22

That's a good idea and towards a right direction.  Our dialplan file size is getting larger and it is time to re-organize them in a systematic, manageable and easier way.
作者: ckleea    時間: 2011-10-15 07:18

This is the beginning.

I have defined two users for sip and iax connections using template approach. Few trunks that allow me to use resources. Other being setup in progress.



screenshot.15-10-2011 07.07.50.png

圖片附件: screenshot.15-10-2011 07.07.50.png (2011-10-15 07:15, 34.46 KB) / 下載次數 1095
http://telecom-cafe.com/forum/attachment.php?aid=968&k=46162707afaec57c43846e940a681bd9&t=1732547461&sid=rRTjJq






歡迎光臨 電訊茶室 (http://telecom-cafe.com/forum/) Powered by Discuz! 7.2