Jajah.com-clone using asterisk

I’d like to have an application send two numbers to my asterisk-server. The server would then call one number, wait until the user picks up, then call the other number and connect the call to the first user so they can have a chat.

Is there allready such a module for asterisk? if not: where would you begin? which api shall i use?

thanks a lot for some usefull hints!

saludos
javier

According one of projects with my participation, I made something simmilar:
Sending SMS to GSM modem, then application read it and:

  1. starts modified version of wakeup.php, which make call file and put it in spool/asterisk/outgoing - this way we make call back (or one of calls)
  2. On connection, modified version of astcc (calling card) is started, and second number is dialed - it is transfered as additional variable.
    Issues:
    I have no idea how I could control parameters of first call - which is done by wakeup.php.

Codes are mix of php and perl and there aren’t many comments.
Anyway - if you want I can send them to you - under GPL of cource - they are primarilly GPL sources.
I haven’t put in public becouse they are ugly - I will some day make them better, and post them.

use Ring action of Manager API
it works exactly as you want

Ring action of Manager API? Do you mean Originate?

yes, of course Originate
Stefan, thanks for correcting me :smile:
btw, link to your site in your footer is incorrect

Ooops thanks! I actually never tried it :wink:

thanks a lot for your help! i ckecked out the originate command of the manager api and saw, that it’s pretty easy to place calls originating from the asterisk pbx by using it.

but there’s still the point of how conntecting two calls together. i’m not new to java, but pretty new to asterisk. :smile:

am i missing the obvious or is it true, that there isn’t an easy way to connect to calls that originate from the asterisk server to one call (using the asterisk as a “router” to each other), so that the two users can communicate together?

thanks again for your help!

…maybe i should explain what that’s all about: i’m trying to build an j2me-client-application that would send the two numbers over a webservice to the asterisk pbx. the pbx would then first call back one number (my own mobile phone), then call the second number (the one i’d like to talk with) and finally connect them together so i can have a conversation with the other user.

now…everything is pretty obvious to me as far as it doesn’t concern the part of connecting the two calls to one call on the pbx.

[quote=“sc0000b”]…maybe i should explain what that’s all about: i’m trying to build an j2me-client-application that would send the two numbers over a webservice to the asterisk pbx. the pbx would then first call back one number (my own mobile phone), then call the second number (the one i’d like to talk with) and finally connect them together so i can have a conversation with the other user.

now…everything is pretty obvious to me as far as it doesn’t concern the part of connecting the two calls to one call on the pbx.[/quote]

have you actually tried that Originate action?
i think you not, otherwise you’d not have such questions any more.
this actions sends 2 numbers to asterisk, then first number rings. after you pickup first, then second starts to ring. when second is picked up you can talk.
isn’t this what you need?

Suppose you have the following in extensions.conf:

[outgoing] exten => _X.,1,Dial(Zap/g1/${EXTEN}, 30)

and you use Zap/g1 for outbound calls (of course this works with SIP trunks or whatever you want, too).

The Java code (asuming Asterisk-Java 0.3) to connect 03012345 (called first) to 03098765 then looks like this:

managerConnection = new DefaultManagerConnection("your-asterisk-box.example.com", "username", "password"); server = new DefaultAsteriskServer(managerConnection); server.initialize(); server.originateToExtension("Zap/g1/03012345", "outgoing", "03098765", 1, 30000);

0.3 is at asterisk-java.org/0.3-SNAPSHOT

Since asterisk-java-0.3-20060714.214952-73 you can even use

server = new DefaultAsteriskServer("your-asterisk-box.example.com", "username", "password"); server.originateToExtension("Zap/g1/03012345", "outgoing", "03098765", 1, 30000);

Shouldn’t be possible to get it easier :wink:

well, looks like i really had my asterisk-noob-coming-out. :wink:

thanks a lot for your posts. i didn’t even dreamed it could be that easy. time to sit down and code now. :wink:

but i still have a question left and i’m not sure how lame it is. :wink:

where is the originateToExtension-method documented? i checked originate and originateAction in the asterisk-java api-docs and couldn’t find it…

It is documented here: asterisk-java.org/0.3-SNAPSHOT/a … erver.html in the live package.

But note that you need the 0.3-SNAPSHOT for the live package to be available.

With the stable 0.2 you can use OriginateAction, an example is in the tutorial at asterisk-java.org/0.2/tutorial.html

thanks a lot for your kind help!

if got this in my extensions_additional.conf (i’m working with trixbox(.org)):

[outrt-002-default_outside]
include => outrt-002-default_outside-custom
exten => _9X.,1,Macro(dialout-trunk,2,${EXTEN:1},,)
exten => _9X.,n,Macro(outisbusy,)
; end of [outrt-002-default_outside]

how do i fill the ??? in my code?

server.originateToExtension("???", "outrt-002-default_outside", "123456", 1, 30000); 
or (depending on your trunk definition) 
[code]server.originateToExtension("Zap/g0/234567", "outrt-002-default_outside", "123456", 1, 30000); [/code]

or (depending on your trunk definition)

The Trunk is a SIP-Trunk pointing to my VoIP-Provider.

server.originateToExtension("Local/234567@outrt-002-default_outside", "outrt-002-default_outside", "123456", 1, 30000);

Does that mean, that it would do a call from the local-extension 234567 to the outside-number 123456? What if I don’t know in advance if the caller and/or callee are local extensions on my pbx?

My plan is to have a j2me-application on a mobilephone send the caller and callee number to a server-software (based on asterisk-java) which would then tell the pbx which numbers to call. Do I have to know wheter caller and/or callee are local extensions on my pbx in advance?

No, you only need a context that is able to process local and remote numbers (extensions).

ermm…the question might be quite lame, but: how do i know if my context is able to do that? afaik, i only configured my voip-provider into that context.

…and by the way: is there an url you could point me to, where i can learn a little more about dialplans? i’d love to not have to ask so many dumb questions. :wink: