The secret of understanding the Originate action is to grasp that it's connecting a device to a context/extension/priority combination in the dialplan.
Typically, you'll see something like this:
Action: Originate
Channel: SIP/Alice
Context: testing
Exten: 200
Priority: 1
This would call Alice's SIP phone, and when she answers, connect her to extension 200 in the [testing] context.
Now, to connect two external numbers, all you need is an extension in your dialplan that knows how to dial an external number. Assuming we set up something like this:
[external]
exten => _NXXNXXXXXX,1,Dial(SIP/some_provider/${EXTEN})
then we could send calls to the [external] context in order to have them dial out to the outside. (I used North American numbering and a SIP trunk to connect to the outside world... your dialplan will obviously be a bit different, but I hope you get the idea.)
Once you have that in place, you can do this via AMI:
Action: Originate
Channel: SIP/some_provider/8005551212
Context: external
Exten: 8885554321
Priority: 1
This will call out to 8005551212, and when that line is answered, start dialing 8885554321.
This is my new extensions.conf which seems to have solved the problem
[default]
exten => s,1,System(asterisk -rx 'sip reload') ; hack to force sip reload
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(vm-extension)
exten => s,n,WaitExten()
exten => 0011,1,Goto(outbound,s,1)
exten => 11,1,Dial(SIP/mysipuser/5555555555,30,g) ;calls 555-555-5555
exten => 11,n,Goto(closechannel,s,1)
exten => 77,1,Dial(SIP/mysipuser/1111111111,30,g) ;calls 111-111-1111
exten => 77,n,Goto(closechannel,s,1)
[outbound]
exten => s,1,Answer
exten => s,n,Wait(1)
exten => s,n,Playback(vm-extension)
exten => s,n,WaitExten()
exten => _NXXNXXNXXX,1,Dial(SIP/mysipuser/${EXTEN})
exten => _NXXNXXNXXX,n,Hangup
[closechannel]
exten => s,1,System(asterisk -rx 'sip reload')
exten => s,n,Hangup()
So the three changes I made were the addition of the exten => s,1,System(asterisk -rx 'sip reload')
statement, [closechannel]
context, and the ,30,g
to the Dial() command. The System command forces a sip reload every time someone tries to call in. The ,g
flag tells asterisk to continue executing code after calling parties disconnect.
This seems to work "most" of the times.
Best Answer
You need to setup an extension that uses matching to match your local telecom rules. I'm only familiar with the US rules so I'll use them as an example.
To dial a local number in the US you would setup an extension that looks like:
What this does is:
_
There is alot of good Asterisk configuration information at http://voip-info.org