Continue executer next extension of contexte after dial call - asterisk

I would like to continue executing the next extension of the below contexte after dial() call is answered.
[sondage-80]
exten => 78767239,1,Answer(500)
same => 2, Set(CHANNEL(language)=moore)
same => 3, Dial(sip/2700, 20, G)
same => 4,AGI(test.php,1612198672)
same => 5,Hangup()
If Dial(sip/2700) is answered, continue immediately in the next extension at the 4 priority.

You can't do like that. You can do something before connecting to caller by
b([[context^]exten^]priority[(arg1[^...][^argN])]): Before initiating an
outgoing call, 'Gosub' to the specified location using the newly created
channel. The 'Gosub' will be executed for each destination channel.
Or you can transfer call to conference and do n-way calling
https://www.voip-info.org/asterisk-n-way-call-howto/

As i know, G needs a target. So try...
same => 3, Dial(sip/2700, 20, G(4))
...then the caller goes after answering the call to priority 4 and callee to priority 4+1. So if you want the callee to go to the AGI then...
same => 4,Hangup() ; Hangup the caller and...
same => 5,AGI(test.php,1612198672) ; ...this is for callee

Related

Asterisk - setup hangup after seconds dialplan otpion S(sec)

When you dial 876, asterisk pbx start a call, send some dtmf code but doesn't close the call after 2 seconds.
The call need to be closed by the user.
[myplan]
exten => _876,1,NoOp(Now should call 207,3 seconds for answer timeout, send DTMF, close the call)
exten => _876,n,Dial(SIP/207,3,D(ww#2334#),S(2))
exten => _876,n,Hangup()
From the manual:
S(x) Hangs up the call x seconds after the called party has answered
the call.
Asterisk 16.13.0
What am I missing?
I think # mean "wait 1 second" so overal time is over 2 second.
So "S" should work after D ends.
Try following:
[myplan]
exten => _876,1,NoOp(Now should call 207,3 seconds for answer timeout, send DTMF, close the call)
exten => _876,n,Set(TIMEOUT(absolute)=2)
exten => _876,n,Dial(SIP/207,3,D(ww#2334#)S(2))
exten => _876,n,Hangup()

dial a call and add to conference room

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

How to call an another phone after hangup the first?

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.

Asterisk:play mp3 sound in holiday for incoming calls

I'm trying to configure Asterisk to play a sound if it's holidays or if it's not during business hours.
After a long search her's what's i came with in Extensions.Conf:
exten => s,n,GotoIfTime(17:31-08:30|fri-mon|*|*?closed,1)
exten => s,n,SetMusicOnHold(default)
[closed]
exten => 6000,1,Answer
exten => 6000,2,MusicOnHold()
exten => 6000,n,Hangup()
i have the following in musiconhold.conf
[default]
mode=files
directory=/var/lib/asterisk/mohmp3
random=yes
How i can achieve this?
Any reply whould be very appreciated
To play a sound, you may use the Playback command.
I tried this out in our office if we get any call to our office number above working hour or on weekend, we will announce a voice that you have called on non working hours and call will be placed in queue.
The call will remain in queue with music to caller. If any employee is available they will receive it.
caller can hangup the call anytime in the queue.
These are my configuration and script which i used in our office
extensions_customs.conf
[Landing]
exten => 600,1,Answer()
exten => 600,2,AGI(work-time.php)
exten => 600,3,Hangup()
queues_additional.conf
[30]
announce-frequency=15
announce-holdtime=no
announce-position=yes
autofill=no
eventmemberstatus=no
eventwhencalled=no
joinempty=yes
leavewhenempty=no
maxlen=0
music=New
periodic-announce-frequency=0
queue-callswaiting=queue-callswaiting
queue-thankyou=queue-thankyou
queue-thereare=queue-thereare
queue-youarenext=queue-youarenext
reportholdtime=no
retry=1
ringinuse=no
servicelevel=60
strategy=rrmemory
timeout=15
weight=0
wrapuptime=0
member=Local/50872#from-queue/n,0,Agent 3,SIP/50872
member=Local/50873#from-queue/n,0,Agent 4,SIP/50873
member=Local/50874#from-queue/n,0,Agent 5,SIP/50874
member=Local/50875#from-queue/n,0,Agent 6,SIP/50875
member=Local/50876#from-queue/n,0,Agent 7,SIP/50876
member=Local/50877#from-queue/n,0,Agent 8,SIP/50877
member=Local/50878#from-queue/n,0,Agent 9,SIP/50878
work-time.php
#!/usr/bin/php-cgi -q
<?PHP
//Set time limit
set_time_limit(50);
//Include PHPAGI
require('phpagi.php');
//Development version. Set to none on production.
error_reporting(E_ALL);
//Create a new object
$agi = new AGI();
$agi->answer();
$tempDate = date('Y-m-d H:i');/**(Fetching data and time from running system)**/
$hours = date('H:i');
$day= date('D', strtotime( $tempDate));
if($hours>='09:00' && $hours<='17:30')
{
if($day=='Sat' || $day=='Sun')
{
$agi->exec('Playback','called-on-non-working');
$agi->exec('Queue','30');/**In queue call will not be hanged until callee hangup**/
}
else
{
$agi->exec('Playback','cce');
$agi->exec('Queue','30');
}
}
else
{
$agi->exec('Playback','called-on-non-working');
$agi->exec('Queue','30');
}
?>
If my office landline is called it will be transfered to extension 600(Landing) there i have my small script running called work-time.php
Before all i have created all extension number in a Queue(See queues_additional.conf)
now script will be executed, script checks for date and time if time is above office timing it will play a file and place the call in queue. Since no is available call will not be answered. And in queue Moh will be played

asterisk phpagi dial into chanspy

I am trying to use phpagi with asterisk to send into chanspy but looks like it's not working. Please help if you can, thank you in advance:
Here's what I got so far:
if($keys=="8888") {
$agi->exec("DIAL","Chanspy(SIP/,q)");
}
You do not "Dial()" to "Chanspy". Chanspy is it's own application and handles the call bridging itself. You have to set a "group" to spy on, or address a specific channel.
Here's a simple way to it with security on the Barge/Spy:
[macro-jkl5_barge_code]
; ${ARG1} - Extension that is monitoring
exten =>s,1, NoOp(Extension Barge & Whisper)
same => n, Answer()
same => n, NoCDR
same => n, Authenticate(12345)
same => n, Wait(1)
same => n, NoOp(** DEBUG: [${SPYGROUP}] )
same => n, ChanSpy(SIP/${ARG1}|qg(${SPYGROUP}))
same => n, Hangup()
... be sure to set "SPYGROUP" somewhere in your call path. Then just call this macro where ever you need it from.
You'll have to do your own reading on how to use it from inside an AGI. The above code is just to give you a sense of how it's used within a dialplan.
Further Reading: http://www.the-asterisk-book.com/unstable/applikationen-chanspy.html

Resources