Playback
Playback will play the whole sound file(s), and when complete, return control.
Playback(filename1[&filename2...][,options])
- Sound files are stored in the /var/lib/asterisk/sounds
( the directory path can be changed in asterisk.conf )
* Compare with the Background()
opts:
- Default: 有無 answer 都 play
- skip: Play the sound file only if the channel has already been answered.
Example:
exten=s,5,Playback(record/who)
; default language code.
SetLanguage(language)
Failing that, it will play the non-language-specific edition.
Background(beep)
which plays a sound file but returns control immediately,
allowing Asterisk to perform other commands on this channel while the sound file is playing.
ResponseTimeout(60)
Set maximum timeout awaiting response
If the user does not type an extension in this amount of time,
control will pass to the 't' extension if it exists, and if not,
the call would be terminated.
'Set(TIMEOUT(digit)=timeout)'
Once a user begins typing an extension, the user has a maximum of DigitTimeout seconds to type additional digits before Asterisk considers the extension to be complete.
If not specified in the dialplan, the default is 5 seconds.
Ringing()
Request that the channel indicate ringing tone to the user.
On an unanswered SIP channel this will send a "180 Ringing" to the endpoint.
* On an answered channel Ringing returns immediately and moves to the next step in the dialplan.
exten => s,1,Answer
exten => s,n,Ringing
exten => s,n,Wait(2)
exten => s,n,do something else
Answer()
If the channel is ringing, answer it, otherwise do nothing.
Record()
plays a beep, and then begins recording audio until you press the hash key '#'
Example
exten => 1014,1,Answer(500) same => n,Record(en/custom-menu.wav) same => n,Wait(1) same => n,Playback(custom-menu) same => n,Hangup
Read()
Read a variable in the form for DTMF tones as pressed by the caller
Read(variable[,filename][,maxdigits][,option][,attempts][,timeout])
variable: variable where the user's response will be stored.
filename: file to play before reading digits.
maxdigits: maximum acceptable number of digits.
option
s(skip):to return immediately if the line is not up.
Example
exten=> s,1,NoOP("test read() function") same=> n,Set(wait=3) same=> n,Set(gottries=0) same=> n(BEGIN),Playback("you-can-press") same=> n,Set(timer=${EPOCH}) same=> n,Read(get,"silence/1",,,,${wait}) same=> n,Set(timer=$[${EPOCH}-${timer}]) same=> n,GotoIf($[${timer}==$[${wait}+1]]?GOTNOTHING:GOTSOMETHING same=> n(GOTNOTHING),NoOP(GotNoThing) same=> Set(gottries=$[${gottries}+1] same=> n,GotoIf($[${LEN(${get})} == 0]?:GOTDIGIT) same=> n,GotoIf($[${gottries}>3]?END:BEGIN) same=> n(GOTSOMETHING),NoOP(GotSomeThing) same=> n,GotoIf($[${LEN(${get})} == 0]?BEGIN:GOTDIGIT) ; Got Value same=> n(GOTDIGIT),SayDigits(${get}) same=> n(END),Hangup()
P.S.
'#' is the End-Of-Input Key. It is NOT possible to accept '#' with Read()
/var/lib/asterisk/sounds/en/silence 內有 1.wav ~ 10.wav
WaitExten(10)
Waits for an extension to be entered; gives the caller the opportunity to push a new extension onto the stack
SayXXX
exten => 6592,1,SayDigits(123)
exten => 6593,1,SayNumber(123)
exten => 6594,1,SayAlpha(hello)
exten => 6595,1,SayPhonetic(hello)
Dial()
Dial(type/identifier, timeout, options)
TtRr
t: Allow the called user to transfer the call by hitting the blind xfer keys
T: Allow the calling user to transfer the call by hitting the blind xfer keys
R: Indicate ringing to the calling party when the called party indicates ringing
r: Generate a ringing tone for the calling party
PSTN -> Asterisk -> SIP
extensions.conf
[outgoing] exten=>s,1,Answer() exten=>s,2,Dial(SIP/100, ,t) ( t option use for blind the # key to transfer) exten=>101,1,dial(SIP/101,30,txk) exten=>101,2,goto(s,2)
Dial 與 Bridge 的分別
Dial
* When a channel executes Dial then Asterisk will attempt to contact devices passed to the application.
* If an answer is received then the two channels will be bridged.
Bridge
* When a channel executes Bridge then Asterisk will attempt to bridge the two existing channels;
* For Bridge to work, two channels are required to exist.