I have a php script that run when call is answered it's in [macro-blkvm-clr]
macro. the php get 3 parms the first param should be the caller number this is my line
exten => s,n,AGI(/var/lib/asterisk/agi-bin/alertcalls.php,${CALLERID(num)},1,${MASTER_CHANNEL(CONNECTEDLINE(num))})
I don't know why but when it asterisk send the parameter to php it set it to the answered phone. for example ext 300 call to ext 200 and in the log that what I see
Executing [s#macro-blkvm-clr:2] AGI("PJSIP/200-00000253", "/var/lib/asterisk/agi-bin/alertcalls.php,200,1,200") in new stack
why is that. and how can I send the real ext that call (in this case 300)
thks for all helper and sorry for my English I hope I was clear
You can save the
exten => s,n,SET(VAR1=${CALLERID(num)})
exten => s,n,AGI(/var/lib/asterisk/agi-bin/alertcalls.php,${VAR1},1,${MASTER_CHANNEL(CONNECTEDLINE(num))})
Becuase macro executed for CALLED party channel(it was invented to do privacy) before connect called and calling channel.
You can see all variables by do Dumpchan as first priority in macro.
Save the caller ID number into a channel variable before you Answer() the call, and then reference that.
You should always be able to reference ${CALLERID(num)}, but if it's not working for you at that point, the above is an easy work around.
Related
I need to execute AGI scripts when following events occur:
An incoming call (it is simple just call AGI() function).
When a call is "Ringing" (I cannot figure it out!). <-- Problem, how to do this?
When a call is "Answered" (I do it using U(answer^${CALLID}) option in Dial()).
When a call hangs up (I do it using h special extension).
My dialplan looks like this:
[from_origin]
exten => _X.,1,NoOp(${CALLER_USERNAME} from ${CHANNEL(pjsip,remote_addr)})
same => n,AGI(agi://127.0.0.1/incoming)
same => n,Dial(${DIALSTR},45,U(answer^${CALLID}))
exten => h,1,AGI(agi://127.0.0.1/hangup,${CDR(uniqueid)})
[answer]
exten => s,1,Set(theCallID=${ARG1})
same => n,AGI(agi://127.0.0.1/answered)
same => n,Return()
Look, I have called 3 fast-agi scripts: incoming, answered and hangup. Now I need to call similar script like ringing when the called party is "ringing". How to achieve this ?
Ringing status is status of the channel(chan_pjsip.so) and it not sent outside channel code.
So no, you can't get it in Dial app. Because it can't be get for some channels types and Dial still should work for those types.
For some channels you can get it via AMI in event listening loop in NewState event. But there are no garantee it will be exactly at same time when you got ringing sip message.
https://wiki.asterisk.org/wiki/display/AST/Asterisk+11+ManagerEvent_Newstate
I want to detect incoming calls in a queue, abandoned before being answered by a member of the queue.
The queue_log file makes mention of these ones, so one approach would be to use this. But I'd like to handle this situation within my dialplan, with a command that issues a notification to a discord salon when such calls are detected.
I've tried to use the h extension :
exten = h,1,NoOp("hangup ! cause : ${HANGUPCAUSE}")
same = n,GotoIf($[ ${HANGUPCAUSE} != 16 ]?done)
same = n,system(/myTools/discord-notification "Missed call from ${CALLERID(num)}.")
same = n(done),NoOp()
It works, but it does not differentiate answered calls from not answered / abandoned calls (they both issue a 16 hangup cause).
I've also tried to add a hangup handler using hangup_handler_push but it does not make any difference.
How can I detect such calls within the asterisk diaplan ?
You have use queue_log(probably queue_log in mysql) or check QUEUESTATUS variable after end of call in top level of dialplan.
Besides QUEUESTATUS , Asterisk Queue app sets another channel variable upon completition when a call is abandoned : ${ABANDONED}.
I had to do it manually using this method :
Setting a shared channel variable abandoned to true before executing Queue app, then changing its value to false when the call is answered via Queue GoSub parameter.
And then you can catch its final value via h extension.
exten => _X!,1,Set(SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})=true)
exten => _X!,n,Queue(${EXTEN},,,,,,,cust-Queue-GoSub)
exten => _X!,n,Set(SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})=false)
exten => _X!,n,HangUp()
exten => h,1,NoOp(Abandoned : ${SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})})
[cust-Queue-GoSub]
exten => s,1,Set(SHARED(ABANDONSTATUS,${CHANNEL(LINKEDID)})=false)
exten => s,n,Return()
My code is simple A calls to B the they both entered into meetme conference
[from-pstn]
exten=> _X.,n,Answer()
same => n,dial(DAHDI/g0/0${9xxxxxxxxx},20,mM(MYCONFO))
[macro-MYCONFO]
exten => s,n,Meetme(1234,sdrM)
But when A calls to B only B enters the conference and A is not able to enter conference , A only hears musiconhold
yes i have read meetme and n way dialout
Can anybody help me with that
I think for this you should use option G from DIAL command:
http://www.voip-info.org/wiki/view/Asterisk+cmd+Dial
G(context^exten^pri): If the call is answered, transfer both parties to the specified context and extension. The calling party is transferred to priority x, and the called party to priority x+1. This allows the dialplan to distinguish between the calling and called legs of the call (new in v1.2). You cannot use any options that would affect the post-answer state if this option is used.
So dialplan should be:
[from-pstn]
exten=> _X.,n,Answer()
same => n,dial(DAHDI/g0/0${9xxxxxxxxx},20,mG(MYCONFO,s,1))
[MYCONFO]
exten => s,1,Meetme(1234,sdrM)
exten => s,2,Meetme(1234,sdr)
You code is incorrect.
Please read again documentation about in-call-macro. It have alot of limits
Try use goto.
If not work, try use transfer from external application with UserEvent
ps. yes, it work as described in n-way-howto too.
I'm kinda new at asterisk and i have to do a process after hangup, i have a code that is something like this:
exten => 12345,1,wait(1)
same => n,agi(myagi.php)
same => n,hangup()
exten => h,1,noop("hangup")
same => n,System(sleep 1m)
same => n,agi(sendemail.php)
so, the call wont hangup when it goes to the h extension because of the sleep, but i need the delay before sending the email, how do i disconnect the caller but still continue the process in the h extension? or is there another way to do this?
Thank You
You'll need to change your setup to send the email asynchronously. Basically in your dialplan you will call a shell script that only executes the email script in the background and returns immediately. You'll add the delay into the email script using PHP's sleep() function. I've not done this before so don't have any sample code to offer, but this looks like a good place to start.
Best way is mark cdr,for example CDR(userfield)=EMAILTO:address.
After that check all cdrs every few seconds/minutes and do action you needed.
Please never use h-extension for task that can take more then 0.5 sec, that can cause issues.
I am using Asterisk-java AGi and I want to use googleTTS agi in my server.
Can I use google tts agi inside my agi?Is there any command for that?
Sorry to take 4 years to give you an answer, but you can do this using the command "channel.exec()".
Probably you could solve this by yourself. Posting this answer just for documentation purposes.
public void service(AgiRequest request, AgiChannel channel)
throws AgiException
{
// Answer the channel...
answer();
// ...say hello...
channel.exec("AGI","googletts.agi","Olá Mundo!","pt-BR");
// ...and hangup.
hangup();
}
Unfortunately, you can't use AGI inside another AGI !
AGI use STDIN/STDOUT to read/write information from Asterisk ...
What you really want to do is call the two AGI's sequentially (in your dialplan) and pass the information to your AGI script.
So, in your AGI script (the one using Asterisk-Java) set a variable to the value you want for TTS, then... Finish execution of your AGI script and pass it back to the dialplan, and use that variable for google TTS.
exten => your_exten,1,Noop(Begin here)
same => n, Answer()
same => n, AGI(/path/to/your/AGI.script) ; or fastAGI etc.
same => n, Noop(This is the variable I set in my agi script: ${TEXT_TO_SPEAK})
same => n, AGI(googletts.agi,${TEXT_TO_SPEAK},en)
same => n, Hangup()
Don't get caught in the trap of trying to control everything in Asterisk through your AGI script. You're wasting your time, and using Asterisk inefficiently if you do that. Call your AGI applications when you need to do something that Asterisk cannot do.