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
Related
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
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 am trying to configure a dialplan to GoTo a different context if the SIP header has a diversion number in it.
This is not working, as it is failing silently.
Here is my extensions.conf file.
[from-external]
exten => _+<phone_number>,1,Noop(incoming call)
same => n,Answer()
same => n,Set(diversion=${SHELL(node ${scripts}/parsePhoneNumber.js ${SIP_HEADER(diversion)})})
same => n,GotoIf($["${diversion}" = ""]?1004,1:have_diversion])
same => n(have_diversion),Noop(in existing diversion)
[MissingDiversion]
exten => 1004,1,Noop(in missing diversion)
same => n(missing_diversion_label),Noop(in missing diversion)
The log is:
== Using SIP RTP CoS mark 5
-- Executing [+16167270007#from-external:1] NoOp("SIP/incoming-trunk2-00000021", "incoming call") in new stack
-- Executing [+16167270007#from-external:2] Answer("SIP/incoming-trunk2-00000021", "") in new stack
-- Executing [+16167270007#from-external:3] Set("SIP/incoming-trunk2-00000021", "diversion=") in new stack
-- Executing [+16167270007#from-external:4] GotoIf("SIP/incoming-trunk2-00000021", "1?1004,1:have_diversion]") in new stack
-- Goto (from-external,1004,1)
So, it looks like the GOTO is working, but it is not reaching where I want it to reach. I do not see the log for in missing diversion.
I have tried variants of the GotoIf line, which also don't work:
same => n,GotoIf($["${diversion}" = ""]?
same => n,GotoIf($["${diversion}" = ""]?[MissingDiversion,1004]:have_diversion])
same => n,GotoIf($["${diversion}" = ""]?[MissingDiversion,1]:have_diversion])
same => n,GotoIf($["${diversion}" = ""]?[MissingDiversion,1004,1]:have_diversion])
Also, I just use a label withing the original context [from-external] - the GotoIf actually works. It is the jumping to a new context that fails.
I am running Asterisk 11.6
Found the problem, it was a redundant extra ']' at the end of the GotoIf statement.
should be:
same => n,GotoIf($["${diversion}" = ""]?1004,1:have_diversion)
and not:
same => n,GotoIf($["${diversion}" = ""]?1004,1:have_diversion])
You should include your new context into from-external OR do goto as MissingDiversion,1004,1
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
I am trying to learn how i can add call forwarding facility for few phones by default in Asterisk via conf files entries. My Asterisk version 1.6.2.6
I read http://www.voip-info.org/wiki/view/Asterisk+call+forwarding
In my scenario i have 3 entries like 10,11,12 which always answer the calls.
But i am trying to do call forwarding ie if 10 busy then call should go to 11, if 11 busy then call goes to 12,if 12 then call end with recorded tape that 'all are busy'.
For that i read above link data, as per my knowledge i have to change my dial plan. but in examples all showing first i should click # key & save it. but i need by default call forwarding. As if phone 50 calls 10 then if 10 not busy then it goes to 10 only. But if 51 calls 10 then it goes to 11 because 10 busy with 50.
I am giving example of phone 10 entries in Asterisk conf files same for other also.
My extension.conf entries:
exten => 0010,2,Queue(0010)
exten => 0110,1,Dial(SIP/0110)
exten => 0210,1,Dial(SIP/0210)
My sip.conf entries:
[0010]
username = 0010
secret = 0010
type = friend
insecure = port,invite
host = dynamic
context = users
[0110]
username = 0110
secret = 0110
type = friend
insecure = port,invite
host = dynamic
context = users
[0210]
username = 0210
secret = 0210
type = friend
insecure = port,invite
host = dynamic
context = users
My queues.conf entries:-
[0010]
member => SIP/0010
Where & what i should add in above entries so call forwarding done in my Asterisk?
Please check this book
http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html#asterisk-ACD
Or this book
http://cdn.oreilly.com/books/9780596510480.pdf
Both have full description for your case.
I'm using Asterisk 10,centos 6. and I'V done changes in conf file as below for call forwarding
"extension.conf"
exten => 0010,1,Wait(0.05)
exten => 0010,2,Queue(0010)
exten => 0010,n,Dial(SIP/0011,15)
exten => 0010,n,Dial(SIP/0012,15)
exten => 0110,1,Dial(SIP/0110)
exten => 0210,1,Dial(SIP/0210)
"queues.conf"
;----------------------QUEUE TIMING OPTIONS------------------------------------
timeout = 15
retry = 5
;timeoutpriority = app|conf
timeoutpriority = conf
[0010]
member => SIP/0010
[0011]
member => SIP/0011
[0012]
member => SIP/0012
Please suggest wheather i'm right if not then please suggest some answer based on given .conf files