Here is the dial plan
[testInComingCalls]
exten => s,1,Answer
exten => 30953025,1,Dial(SIP/20000,20)
I would like to play an audio file as soon as somebody answered the call..
Please give me some idea how to call a php file, send the input and based on the output forward the call.
Since most of the Dial options act on the called party, not the caller, you have to get a little creative. It is a little odd to do such things to the caller as opposed to the called party, but hey, it's Asterisk: there's usually a way to do whatever you want.
One approach would be to use the lesser known (and somewhat strange) G option. Quoting from the documentation:
If the call is answered, transfer the calling party to the specified priority and the called party to the specified priority plus one.
context
exten
priority
Basically, the G option takes the caller/called channel and - instead of bridging them together - bounces both of them out to the dialplan. You can then get a little creative to perform your Playback operation before putting them in a Bridge together. The following Dialplan should work (caveat: I haven't tested this and I'm sitting on a laptop on a couch, but this should get you close):
[default]
exten => 1000,1,NoOp()
same => n,Dial(SIP/alice,,G(default^bridge_and_play^1))
same => n,Hangup()
exten => bridge_and_play,1,Goto(jump_caller,1)
same => n,Goto(jump_called,1)
same => n,Hangup()
exten => jump_caller,1,NoOp()
same => n,Answer()
same => n,Playback(tt-monkeys)
same => n,Bridge(${bridge_this})
same => n,Hangup()
exten => jump_called,1,NoOp()
same => n,Set(MASTER_CHANNEL(bridge_this)=${CHANNEL})
same => n,Wait(1000)
same => n,Hangup()
Who do you want to play the audio to, the caller or the callee?
You can use the M flag to Dial to run a macro on the call right before it's bridged, it runs on the callee SIP/200000. Example:
[testInComingCalls]
exten => 30953025,1,Dial(SIP/20000,20,M(onanswer))
[macro-onanswer]
exten => s,1,Playback(hello-world)
You need read info about AGI interface, which allow use php via phpagi to control dialplan.
http://www.voip-info.org/wiki/view/Asterisk+AGI
For playback file use STREAM FILE agi command($agi->stream_file in php)
Related
Intro : I am trying to record each calls but I don't want to append them to a same file or overwrite it all the time. I'd like to have a file for each call. The name of the file should be the date+time when the call was made so that it is unique. I can't figure out how to do this.
My current extension.conv :
exten => 1000,1,Answer()
exten => 1000,2,MixMonitor(${DATETIME}.wav,v(0)V(0))
exten => 1000,3,Background(/var/lib/asterisk/sounds/intro2168000)
Problem:
the file is only called ".wav".
Is there a way to make it work ?
That should work on older versions of Asterisk. The ${DATETIME} variable is deprecated and should be replaced with ${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)} on modern versions of Asterisk.
exten => 1000,1,Answer()
exten => 1000,2,MixMonitor(${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}.wav)
exten => 1000,3,Background(/var/lib/asterisk/sounds/intro2168000)
Note your v(0)V(0) wasn't doing anything so can be left off.
Please help in the problem that I encountered recently.
When implementing the function of informing the caller "User talking on the first line Please wait or call back later." With the function "Call Waiting" in the Asterisk I use this macro:
extensions_custom.conf
[from-internal-custom]
exten => _XXX,1,Macro(check-number,${EXTEN})
include => macro-check-number
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(ml))
exten => s,n,NoOp(Exit from macro-check-number)
ml - filename for playback
And this feature works!
But the macro works for the entire Asterisk, this queue calls, group calls - and that is the problem.
I have an idea - a group of calls and queue calls to assign numbers four-digit extensions, for example: 2222 - but are not you should not be, it is a false solution to the problem, because of which in the future could be a problem!
Maybe somebody faced a similar problem?
You don't need to include section in the from-internal-custom context
as extensions_custom.conf file is included in the dial plan.
You need to change the pattern of extension:
[from-internal-custom]
exten => _99XXX,1,Macro(check-number,${EXTEN:2})
[macro-check-number]
exten => s,1,NoOp(Enter in macro-check-number)
exten => s,n,Set(devst=${DEVICE_STATE(SIP/${ARG1})})
exten => s,n,ExecIf($["${devst}" = "INUSE"]?Playback(ml))
exten => s,n,NoOp(Exit from macro-check-number)
You have analyze environment of call based on your dialplan.
For examples of such dialplan you can see recoring macro in freepbx project. However simplest way is just use different context for ringgroup/queues and direct diallling.
The problem was solved in the circuit.
Since we serve telephony server with no more than 250 members - it was decided to create a four-digit number for the groups and queues.
When using ChanSpy() to barge-in or listen is it possible to announce the spied channels that they are being intercepted?
The law says you can intercept if you announce the spied channel.
Currently if I do not use the 'q' option Asterisk beeps and says the channel number only to the interceptor. This is silly because the interceptor already knows this. Nothing is played on the intercepted channels!
[barge-in]
exten => _*224x.#,1,Macro(user-callerid,)
exten => _*224x.#,n,Answer
exten => _*224x.#,n,NoCDR
exten => _*224x.#,n,Wait(1)
exten => _*224x.#,n,ChanSpy(SIP/1,B)
exten => _*224x.#,n,Hangup
There are no way do it like you want with small effort.
Possible solutions on your choice
1) Hire someone who will extend app_spy.c code to play file to other party
2) Use instead transfer to conference, play in conference file you want
3) Create dialplan (above average complexity/expert level required) which will do spychan session,playback first file, after that do other session and connect human.
I'm wondering how I should go about running some applications in the current context, and then switching to another context (as if it had been included).
So, for example, I have several contexts for incoming calls but, for one in particular, I need to perform some extra actions (specifically, I need to Answer() it and delay it for a second). So, suppose that I had something like this:
[main-context]
include => this
include => that
[special-context]
exten => s,1,Agi(agi://<whatever>}
exten => _X.,1,Answer()
same => n,Wait(1)
include => main-context
What I'd like is for calls coming in to special-context to get Answer()ed and then main-context included, as if the extension hadn't been matched in special-context.
(I am already using the s-extension, as shown, but that seems to run in parallel to the normal execution of the extension anyway, so I don't think that would help.)
Is this possible?
You can use goto command.
[special-context]
exten => _X.,1,Answer()
exten => _X.,2,Goto(main-context,${EXTEN},1)
P.S. I higly recommend you read any single asterisk book, for example ORelly's "Asterisk the future of telephony"
Another solution:
[special-context]
exten => s,1,Agi(agi://<whatever>}
exten => _X.,1,Answer()
same => n,Wait(1)
same => n,Dial(Local/${EXTEN}#main-context)
According to the manual, this calls a pseudo-channel (chan_local), which places a call back in to the dialplan.
I'm starting up an AGI interface (in the s-extension) as well, and it should be noted that the extra Dial() interferes with the signalling that you receive on the AGI interface. For me, the solution posted by arheops worked much better.
I'm trying to solve a very painful problem that impedes on my world utilizing my amazing powers as a programmer... (my front gate makes my friends call my cell phone, then I have to press "9" and it lets them in)...
So, my amazing powers have gotten me very far, except this last part I can't get (perhaps due to lack of sleep).
I've got every thing worked out so far: The call-box now dials my Google Voice account, which forwards it to my virtual machine on my laptop running the latest 'trixbox' (Asterisk), which will receives the call via Gizmo5/SIP junk.
What I need now is to have the phone call answered, and then "press" the number "9"... wait about 5 seconds, then hang-up.
I'm sure it's as easy as putting this code somewhere in a config file:
exten => 1234,1,Answer
exten => 1234,n,Press("the flippin 9 key")
exten => 1234,n,Wait(5)
exten => 1234,n,Hangup
But I don't know:
1) Is this possible (pretty sure it is)
2) What file do I edit?
3) Do I need to make an extension first?
4) Is that code in my example above anywhere close?
5) What do I actually need to do!
I greatly appreciate any help on this one.
You're close, try:
exten => 1234,1,Answer
exten => 1234,2,Wait(2) ; Safety time
exten => 1234,3,SendDTMF(9)
exten => 1234,4,Wait(5)
exten => 1234,5,Hangup
This tells Asterisk how to handle a call coming in for 1234
In a "standard" Asterisk installation, this goes in extensions.conf and 1234 should be whatever extension/number the incoming call is coming in on.
extensions.conf has different sections, which can vary based on distribution and local setup, but it's usually best to put this in the [default] section.