I am using confBridge in my asterisk for conferencing. I want to detect if number of user remain less than or equal to 1 in ongoing call then terminate the conference call.
I have tried this-
exten => ConfTest,1,System(asterisk -rx "confbridge kick ${DB(CONF/NUM)} ${DB(CONF/ConfTest)}")
exten => ConfTest,n,Set(DB(CONF/ConfTest)=${CHANNEL})
exten => ConfTest,n,Set(ID=${RAND(1,500)})
exten => ConfTest,n,Set(DB(CONF/NUM)=${ID})
exten => ConfTest,n,Set(target=ConfTest1)
exten => ConfTest,n,Originate(SIP/${target},app,confBridge,${ID},default_user)
exten => ConfTest,n,Set(target=ConfTest2)
exten => ConfTest,n,Originate(SIP/${target},app,confBridge,${ID},default_user)
exten => ConfTest,n,Macro(dialout-trunk-predial-hook-test)
exten => ConfTest,n,confbridge(${ID},,src_user)
exten => ConfTest,n,Answer()
exten => ConfTest,n,Set(i=1)
exten => ConfTest,n,While($[${i} = 1])
exten => ConfTest,n,GoToIf($[0${CONFBRIDGE_INFO(parties,${ID})} <= 1]?18:15)
exten => ConfTest,n,NoOp(number of participants in conference call = ${CONFBRIDGE_INFO(parties,${ID})})
exten => ConfTest,n,Wait(1000)
exten => ConfTest,n,EndWhile()
exten => ConfTest,n,System(asterisk -rx "confbridge kick ${DB(CONF/NUM)} ${DB(CONF/ConfTest))
here lines are not executing from while loop.
Is there any thing available to register hangup handler for all the channel involve in conference call.
For example-
debianpc08*CLI> confbridge list 1
Channel User Profile Bridge Profile Menu CallerID
============================= ================ ================ ================ ================
SIP/ConfTest1-0000009c default_user default_bridge ConfTest1
SIP/ConfTest2-0000009d default_user default_bridge ConfTest2
SIP/ConfTest3-0000009b src_user default_bridge ConfTest3
here i want to register hangup handler for all the channels like SIP/ConfTest1-0000009c.
You can use default hangup handler(h-extension) to catch that
;record situation
exten => ConfTest,n,Set(HANGUP_OK=NO)
exten => ConfTest,n,confbridge(${ID},,src_user)
; if user exit confbridge, clear it
exten => ConfTest,n,Set(HANGUP_OK=YES)
; if hanguped in confbridge, do something
exten => h,1,GotoIF($[ "${HANGUP_OK}" == "NO" ]?dosomething,s,1)
You are going the wrong about it. Your best choice for this task would be to use Asterisk ARI and the bridges API. The idea will be very simple, initiate a Stasis application to handle your bridge, put the channels into the bridge. As they come in and out of the bridge, listen to the WebSocket events to see who left and who came in.
You can have a look at http://www.phpari.org for additional information on how to write such an application, the demo dial application should give you ample information on how to do it.
Nir
Related
Hello my èxtensions_conf`, this is a queue;
exten => 1,1,NoOp(call for call center)
same => n,Set(__OTHERCHANNEL=${CHANNEL})
;same => n,Set(CHANNEL(hangup_handler_push)=call-center,csh,1(args))
same => n,Dial(SIP/trunk/XXXXXXXXX,,tTG(msg,1))
exten => msg,1,Goto(anum,1)
exten => msg,2,Goto(cnum,1)
exten => anum,1,BridgeWait()
exten => anum,n,NoOp("after bridgewait")
exten => cnum,1,Playback(hello)
exten => cnum,n,Set(CHANNEL(hangup_handler_wipe)=call-center,csh,1(args))
exten => cnum,n,WaitExten(100)
exten => csh,1,Verbose(0)
same => n,AGI(test.py,${ORIGCHANNEL},${OTHERCHANNEL})
same => n,Return()
;same => n,AGI(test.py,${ORIGCHANNEL})
exten => #,1,NoOp(press #)
same => n,Bridge(${ORIGCHANNEL})
exten => 9,1,AGI(test.py,${ORIGCHANNEL})
same => n,Hangup()
My test.py;
#!/usr/bin/env python3
import sys
from asterisk.agi import AGI
agi = AGI()
if sys.argv[2]:
agi.env['agi_channel'] = sys.argv[2]
agi.hangup(channel=sys.argv[1])
I want to when answered press 9key hangup answered and caller channel. This works fine. But when answered hangup phone, my agi script running in hangup handler does not hangup the caller's channel. Give me RESULT_LINE: 511 Command Not Permitted on a dead channel or intercept routine error. I can try change to àgi_channel`but this not work. How to can fix this problem. How to hangup caller after hangup answered. Thanks for reply.
Since DeadAGI and AGI is now same application, that behavour is normal one.
You are responsible for detect channel is hanguped, for example you can check Dial command response code or issue CHANNEL(state) check.
My plan is to dial a number and when the call get connected, join that call to the Conference room (565601),
but I do not have any idea how to do it.
I have tried this dial plan but it not works
exten => 800,1,dial(PJSIP/4141233908080249372127#US-VOS-Out)
exten => 800,n,ConfBridge(565601)
The second priority is executed when call ends - So nobody is joining the confbridge.
Just use the dial flag G and join each ( caller and callee ) to the confbridge...
exten => 800,1(join_conf_call),dial(PJSIP/4141233908080249372127#US-VOS-Out,,G(2))
exten => 800,2(join_caller),ConfBridge(565601)
exten => 800,3(join_callee),ConfBridge(565601)
The Logic: After call is established caller goto priority 2 and callee to priority 2+1
Second example
exten => 800,1(join_conf_call),dial(PJSIP/4141233908080249372127#US-VOS-Out,,G(2))
exten => 800,2(caller_wait),wait(5)
exten => 800,3(join_callee_first_then_caller),ConfBridge(565601)
The Logic: After call is established caller jumps to priority 2 and wait 5 seconds before joining in priority 3. Callee jumps directly to priority 3.
Last but not least...
exten => 800,1(join_conf_call),dial(PJSIP/4141233908080249372127#US-VOS-Out,,G(2))
exten => 800,2(caller_bye),hangup(16)
exten => 800,3(join_only_callee),ConfBridge(565601)
The Logic: The caller pushes callee to confbridge and leave the show (hangup) - This is usefull in cases caller wants only to join the callee to others in conference
I would like to call a phone, hangup and call an another phone from the server.
Like this :
Server->Phone A->Hangup->Server->phone B
This is what I already tried :
[appel]
exten => a,1,Answer
[do something]
exten => 2,1,Goto(pasCharge)
[pasCharge]
exten => [do something]
exten => ce,2,Dial(SIP/vincent)
exten => [doSomething]
exten => ce,3,Hangup
I have the first call (appel) but not the second (centre). It just hangup after the first.
Could you help me please ?
If you want dialplan be able continue after hangup of first call, you shoudl add g option to dial param
pro-sip.net> core show application Dial
-= Info about application 'Dial' =-
.....
[Syntax]
Dial(Technology/Resource[&Technology2/Resource2[&...]][,timeout[,options[,URL]]])
....
g: Proceed with dialplan execution at the next priority in the current
extension if the destination channel hangs up.
To build on what #arheops was saying, adding the lowercase g in the Dial() command instructs Asterisk that when the called party hangs up, continue to execute commands in the current context at the next priority.
So you could do something like this:
[pasCharge]
exten => ce,2,Dial(SIP/vincent,g)
exten => ce,3,Dial(SIP/Vbourdon,g)
exten => ce,4,[doSomething]
This would dial vincent then Vbourdon, and your doSomething could be a Goto, etc, anything you like.
I need to make a voice translation service on active calls like skype, for that purpose I need to record voice from caller and whisper the translated voice to callee and vise-versa
I need to add to the dialplan lines to playback audio to the other channel with lower voice but current playback app doesn't have this option
any solution for that?
this is my code below
[macro-speech]
;;Speech recognition demo:
;exten => s,1,Answer()
exten => s,1,agi(googletts.agi,"Say something in English, when done press the pound key.",en)
exten => s,n(record),agi(speech-recog.agi,en-us)
exten => s,n,Verbose(1,Script returned: ${confidence} , ${utterance},en-us)
;Check the probability of a successful recognition:
exten => s,n(success),GotoIf($["${confidence}" > "0.6"]?playback:retry)
;Playback the text:
exten => s,n(playback),agi(googletts.agi,"The text you just said was...",en)
exten => s,n,agi(googletts.agi,"${utterance}",en)
;------------- Translate to different languages
;Translate a text string from english to german:
exten => s,n,agi(googletranslate.agi,"${utterance}",de)
exten => s,n,agi(googletts.agi,"${gtranslation}",de)
;------------------------------------------------
exten => s,n,goto(record)
;Retry in case speech recognition wasn't successful:
exten => s,n(retry),agi(googletts.agi,"Can you please repeat more clearly?",en)
exten => s,n,goto(record)
exten => s,n(fail),agi(googletts.agi,"Failed to get speech data.",en)
exten => s,n(end),Hangup()
freepbx11*CLI> core show function VOLUME
-= Info about function 'VOLUME' =-
[Synopsis]
Set the TX or RX volume of a channel.
[Description]
The VOLUME function can be used to increase or decrease the 'tx' or 'rx' gain
of any channel.
For example:
Set(VOLUME(TX)=3)
Set(VOLUME(RX)=2)
Set(VOLUME(TX,p)=3)
Set(VOLUME(RX,p)=3)
[Syntax]
VOLUME(direction[,options])
[Arguments]
direction
Must be 'TX' or 'RX'.
options
p: Enable DTMF volume control
[See Also]
Not available
freepbx11*CLI>
I used these commands for save CallerID in database :
exten => s,1,MYSQL(Connect connid localhost root 123456 CallerID)
exten => s,2,Set(idcaller=${CALLERID(name)})
exten => s,3,MYSQL(Query resultid ${connid} INSERT INTO CallerID SET Num="${idcaller}")
exten => s,4,MYSQL(Disconnect ${connid})
Now i want to execute these commands when extension is ringing ...
It means that first IVR works then the diall extension Id then these Commands have to work ...
where i have to put my commands ?
thanks alot .
You can't do anything on ringing state, it is not implemented in asterisk
You can do that when extension entered before dial - just put that before dial command like
exten => 100,1,MYSQL(Connect connid localhost root 123456 CallerID)
exten => 100,2,Set(idcaller=${CALLERID(name)})
exten => 100,3,MYSQL(Query resultid ${connid} INSERT INTO CallerID SET Num="${idcaller}")
exten => 100,4,MYSQL(Disconnect ${connid})
exten => 100,n,Dial(SIP/100,,ro)
NOTE, MYSQL command is depricated. User func_odbc or realtime.
To do something when extension is ringing you have to use AMI interface and write your own application using it to detect ringing state and write it to database (or do anything else you like).
https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=4817239