Create and then bridge 2 outgoing channels (calls)

Hello team!

I need an ability to make a call from Asterisk to 2 different directions via SIP trunk (provider) and then bridge the channels to let them talk. Need call each person immediately after command sent, first person after pick the phone should listen ringing beep until another person didn’t answer, when another part pick the phone they both should speak normally.

This call file hello.call:

Channel: PJSIP/+111111111@provider
Application: Dial
Data: +999999999

Dial a +111111111 and ONLY after person pick the phone Asterisk will dial +999999999. But need, as I said, that +999999999 and +111111111 will be calling in parallel and bridged after one of them pick the phone.

Is there a specific application in Asterisk can help with it, if Dial not fit?

Use Local channels and Answer first before dialing out to SIP.

Can you please give me a favor how it should be looks in dialplan approximately?

My guess:

  1. Local channel create
  2. Make a call to 1st party
  3. Make a call to 2nd party

When make a bridge?

Originate command local channel an dial r or R option

Something like this (very basic and untested)

Channel: Local/+111111111@dialout
Context: dialout
Extension: +999999999

[dialout]
Exten => _+X.,1,Answer()
same => n,Dial(PJSIP/${EXTEN}@provider)

For sure not tested, it’s exactly what I am asking for )

Hah! It’s working! Thank you a lot all who help me today here!

But I tested almost the same schema but without Answer() first in context dialout and there second number started calling after first pick up the phone. It’s because Asterisk waiting channel status "Up" to start executing dialplan?

Yes, Originate waits until the initial called party answers before sending it into the dialplan or before executing the application.

Originate waits until the initial called party answers

Am i right that Local channels execute under the hood “Originate” application?

As i read in documentation:

In the case of local channels, you’ll typically have two local channel legs, one that is treated as outbound and the other as inbound. In this case both are really inside Asterisk, but one is executing dialplan and the other is not. The leg executing dialplan is the one treated as inbound.

Meaning that which is treated as “inbound” in my particular case? Because both executing dialplan. Or both treated as outbound?

How it looks like from my point of view, correct me if there is something wrong.

They don’t execute Originate under the hood. The dialed leg is outbound, the other leg is inbound. In Local channel speak the one with “;1” is outbound, the one with “;2” is inbound.

I don’t sure where in my case numbers with ";1" and ";2" if numbers dialing by call file:

Channel: Local/+11111111111@outgoing
Context: outgoing
Extension: +99999999999
Priority: 1

and context outgoing looks like:

[outgoing]
exten => _+XXXXXXXXXXX,1,Answer()
same => n,Dial(PJSIP/${EXTEN}@provider)
same => n,Hangup()

Am i right if +1111111111 calling first he is treated as inbound, and second +99999999999 - outbound?

Thanks in advance.

Asterisk creates an outbound channel and once answered, it’ll be treated as an inbound. Fig. 3 is what you should look into in this link.

Thanks for the link.

Yes, I have seen that article. But little was confused by it.

Asterisk creates an outbound channel and once answered, it’ll be treated as an inbound.

In my case Local channels answered immediately by dialplan Answer():

[outgoing]
exten => _+XXXXXXXXXXX,1,Answer()
same => n,Dial(PJSIP/${EXTEN}@provider)
same => n,Hangup()

So both local channels become “Inbound” immediately?

After Local channels became “Inbound” they will create PJSIP/+11111111111 and PJSIP/+99999999999 and that channels also will be outbound until answered? What if one of them became answered, it will be “inbound”. Will be “inbound” if answered another PJSIP?

Article says that firstly created SIP/Alice and after Local channel. In my case we have a call file:

Channel: Local/+11111111111@outgoing
Context: outgoing
Extension: +99999999999
Priority: 1

what is order of creating channels here? First will be Local?

I try to find in Asterisk CLI how to see direction of channels. But the most verbose found is: core show channels verbose which output do not show direction of channel. Is there a command in Asterisk CLI which show direction of channel?

Whether a call is inbound or outbound doesn’t really matter in practice, does it matter to you in some way? What exactly are you trying to do/understand from this?

Try understand how it works under the hood, in hope this knowledge will help better understand how Asterisk works or helps in troubleshooting. But actually now don’t have a problem where this information need, just my curiosity. Sorry if tired of questions.