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.
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 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.
I have been building a Window Form desktop application using C# that interfaces with Asterisk using Asterisk.NET.
My first problem is catch a Incoming call and transfer it to specific exten.
The first my idea is using OriginateAction, when a call come, I use Dial event and catch it and use OriginateAction to call to a specific exten.
RedirectAction originateAction = new RedirectAction();
originateAction.Channel = e.Channel;
originateAction.Context = "default";
originateAction.Exten = "203";
originateAction.Priority = 1;
ManagerResponse originateResponse = manager.SendAction(originateAction);
Console.WriteLine(originateResponse);
But it not work like my wish.
The second my idea is using RedirectAction:
RedirectAction originateAction = new RedirectAction();
originateAction.Channel = e.Channel;
originateAction.Context = "default";
originateAction.Exten = "203";
originateAction.Priority = 1;
ManagerResponse originateResponse = manager.SendAction(originateAction);
Console.WriteLine(originateResponse);
And it not work.
I have find on many websites but the documents is very little.
How can I solve this issue?
Thanks!
I would suggest using some kind of dynamic dialplan instead of "catching" calls reactively. Why not use an AGI script?
Essentially, your application tells a database or other central system what to do when calls matching certain criteria come in. Then Asterisk runs the script you setup when calls reach a certain context (such as all incoming calls), and then the script routes the call dynamically based on the inputs given by your application.
Since you seem to like .NET, here's a .NET AGI project to help you get started: AsterNET. It looks like the library you mentioned, Asterisk.NET, is also capable of Fast CGI (what AGI uses), but the last release was in 2009, whereas AsterNet is active as recently as 3 months ago.
I personally use phpAGI to do all kinds of neat ACD and call routing stuff in our call center.
For more info on AGI, see the official docs.
Edit:
I should probably also explain some basic call flow terminology (from the docs):
Originate: Generates an outgoing call to a Extension/Context/Priority or Application/Data. Example: User clicks a button, Originate a call to their desk phone, when they answer that call, it executes dialplan, or a dialplan application.
Redirect: Redirect (transfer) a call. Example: Agent and Customer are talking, but Manager wants to take over the call. Use Redirect to "take" the call from Agent and ring the Manager.
Dial: (in dialplan only, not AMI) Dial the technology/channel specified. Note that you can only Originate from your .NET application, not Dial.
Can you show your event handler code? It looks like that library would say something like manager.NewChannel += new ManagerEventHandler(new_channel);
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.