Passing Parameters through AMI

To make a outgoing call from other Application(JAVA) I have to use Manager AMI right?I can’t use AGi?I am making a dynamic IVR . This(below) is what I am doing.

My java search database,get a "phone number and filelocation of song ".
Now I want to call that phone number and play the song;

How to pass infromation (phone number and address where the song is) to asterisk dynamically?

Like we have in AGI a streamFile(filename) option where I can choose what to play,what option do I have in AMI to set what to play in dialplan?

I can pass a phone number as an extension which matches the pattern as shown below

[outgoing-call] exten=>_XXXXXXXXXX,1,Dial(dahdi/g0/${EXTEN}) same=>n,Playback(filename) //This is the issue.How should I pass filename from managerAMI? same=>n,Hangup();

If my approcah is wrong,please guide me.

You don’t understand how Dial works and which channel Playback acts on. The Playback will only happen after the Dial fails and will be played to the channel running the dialplan, not to the one called. The whole through connection runs within the Dial application.

I think you have a lot more reading to do (e.g. see asteriskdocs.org/) and you need to read up on call files and the Originate manager action.

You may not need to use Dial at all for this application.

If you are using analogue FXO modules, make sure that the service provider provides answer supervision and that dahdi is configured to use it.

Also, make sure that you have performing rights clearance for the “songs” you are going to play.

Hii david,
pardon my ignorance.I am new to asterisk.Actually I am creating a medicine Reminder for patients where I have to call patient and play his medicine information.Medicine information are different for different patient and hence the voicefile.
I modified the question a bit.I am using Asterisk-Java.
Suppose I have to call 01234567 and play a song.
originateAction = new OriginateAction(); originateAction.setChannel("dahdi/g0/01234567"); originateAction.setContext("medicine"); originateAction.setExten("s"); originateAction.setPriority(1); originateAction.setTimeout(30000l); originateAction.setAsync(true);

[medicine] exten => s,1,Answer() exten => s,n,Playback(My voicefile goes here) exten => s,n,Hangup()

Now as “My voicefile goes here” voice file are different for different patient how can I set it from manager AMI.

Guide me how can it be done in other way.Please.

Extension number, or channel variable, or use the application form of Originate (although, in practice, you will want to confirm that you are talking to someone before starting the announcement). (You could even use priority, although that would be strange.)

Note that “song” is the wrong word. It doesn’t mean recording, even if it is now almost used in that sense in relation to recordings of singing.

Also note that neither Answer nor Hangup do anything useful. With Originate, the call is already answered before the dialplan starts and simply dropping off the end of the dialplan will cause a hangup.

Hii,David
If I am using Extension number,is there any limit on size of extension?
Moreover can extension contain symbols like “/”.(/home/desktop/sound/patient-1/voice 1)
I studied http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html/asterisk-book.html#asterisk-DP-Basics-SECT-3.6 but was of no help.

By channel Variable you meant something like this?
http://www.asterisk-java.org/development/apidocs/org/asteriskjava/manager/action/OriginateAction.html#setVariable(java.lang.String,%20java.lang.String),
I tried but its not working.How will I extract the variable in DialPlan?

Actually I don’t have the information of how many voice to play to each patient.It maybe two or three.So going by extension way wont work.

Cant I tranfer the call to agi server after calling from Manager AMI?

[medicine] exten => s,1,Answer() exten => s,AGI(agi://127.0.0.1:4574) exten => s,n,Hangup()

If yes,how can I set variable(filename) from AMI such that I can retreive it in AGI?Is it possible?

Thanks.

I don’t know the exact limits, but I can’t imagine that character set limits will affect your application.

The java object model seems to make adding variables a lot more difficult than it really is, but that is what is probably done.

Ok…what about transferring the call to agi?

I have never used AGI in that comlex a way, but I don’t see why not. Try it.

yes,its working.:smile:.But now how to pass the variable
Can I set variable of the channel using ami and while agi is called can i get it those variables

JAVA CODE:
originateAction = new OriginateAction(); originateAction.setChannel("dahdi/g0/01234567"); originateAction.setContext("medicine"); originateAction.setExten("s"); originateAction.setPriority(1); originateAction.setTimeout(30000l); originateAction.setAsync(true); // Here I want to send some values maybe 3 or 4.

Extensions.conf

[medicine] exten => s,1,Answer() exten => s,n,AGI(agi://127.0.0.1/hello.agi) //How will I send the values to my AGI? exten => s,n,Hangup()

AGI

public void service(AgiRequest request, AgiChannel channel) throws AgiException { // How to obtain the variable value?? }

That’s AGI 101. As it happens, I didn’t use any class librarly and I didn’t use Java, so my experience isn’t generally relevant.

AGI 101?
Maybe you dont have knowledge about asterisk-java but with reference to
only agi and ami can i set a variable in a channel through ami and get it back in agi?

101 is a reference to how American Universities label their course segments. 101 is the very first segment. It means that the question is too easy to justify asking someone who is not being paid to support you.

Hi atul2512,

I don’t see the need to get back to AMI for this. You can just add variables to the OriginateAction:

originateAction = new OriginateAction(); originateAction.setChannel("dahdi/g0/01234567"); originateAction.setContext("medicine"); originateAction.setExten("s"); originateAction.setPriority(1); originateAction.setTimeout(30000l); originateAction.setAsync(true); originateAction.setVariable("announcement",<filename>);
The variable is used in your dialplan like this:

[medicine] exten => s,1,Answer() exten => s,n,Playback(${announcement}) exten => s,n,Hangup()

Regards