Asterisk ARI application

Hello,
Sorry i am a newbie when it comes to asterisk and i am trying to learn as much as i can, my scenario is that i registered two extension phones to asterisk PBX server using SIP registration. My question is how can i make the call transfer to my ARI application after one of the phones is dial-ed or answered. In other words i want to use the ARI application in order to execute a function to the bridge to the two channels of the phones when they are answered.

My extensions.conf file:

[from-internal]
exten => _XX.,1,NoOp(Call from ${CALLERID(num)} to ${EXTEN})
 same =>      n,Dial(PJSIP/${EXTEN},60)
 same =>      n,Stasis(Intro-IVR)
 same =>      n,Hangup()

Asterisk is not executing stasis after the phones answer the dial

   -- Executing [6001@from-internal:1] NoOp("PJSIP/6002-00000005", "Call from 6002 to 6001") in new stack
    -- Executing [6001@from-internal:2] Dial("PJSIP/6002-00000005", "PJSIP/6001,60") in new stack
    -- Called PJSIP/6001
    -- PJSIP/6001-00000006 is ringing
    -- PJSIP/6001-00000006 is ringing
    -- PJSIP/6001-00000006 answered PJSIP/6002-00000005
       > 0x7f3d38026d80 -- Strict RTP learning after remote address set to: 10.0.10.246:5042
       > 0x7f3d38015200 -- Strict RTP learning after remote address set to: 10.0.10.44:5004
    -- Channel PJSIP/6001-00000006 joined 'simple_bridge' basic-bridge <9f6efcc1-3ea2-4ab6-815a-0c05c6d67f27>
    -- Channel PJSIP/6002-00000005 joined 'simple_bridge' basic-bridge <9f6efcc1-3ea2-4ab6-815a-0c05c6d67f27>
       > Bridge 9f6efcc1-3ea2-4ab6-815a-0c05c6d67f27: switching from simple_bridge technology to native_rtp
       > Remotely bridged 'PJSIP/6002-00000005' and 'PJSIP/6001-00000006' - media will flow directly between them
       > 0x7f3d38015200 -- Strict RTP learning after remote address set to: 10.0.10.44:5004
       > 0x7f3d38026d80 -- Strict RTP switching to RTP target address 10.0.10.246:5042 as source
       > 0x7f3d38015200 -- Strict RTP switching to RTP target address 10.0.10.44:5004 as source
    -- Channel PJSIP/6001-00000006 left 'native_rtp' basic-bridge <9f6efcc1-3ea2-4ab6-815a-0c05c6d67f27>
    -- Channel PJSIP/6002-00000005 left 'native_rtp' basic-bridge <9f6efcc1-3ea2-4ab6-815a-0c05c6d67f27>
  == Spawn extension (from-internal, 6001, 2) exited non-zero on 'PJSIP/6002-00000005'

Generally you don’t and instead do the dialing within your ARI application so you have complete control. That being said the Dial application does provide the G option[1] which can be used to direct each party to another place in the dialplan upon answer. This location could call your ARI application.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+17+Application_Dial

Thank you for clarifying for me jcolp. So i removed the dial from my extensions.conf file so i can dial from the ARI application to have full control. When i want to dial an extension from another extension i am creating a channel for the called extension so that i can bridge the two channels. But my problem is that i cannot hear any voice from the speaker. Do i have to add any additional API?

You haven’t stated precisely what you are doing, so I can’t answer. For example how are you doing the dialing? Are you acting on the events and adding the channels to a bridge? Is there any failure responses to your API calls to this?

My suggestion is to try to isolate the problem and identify where precisely it is going wrong.

Sorry i didnt fully explain myself, after you informed me that i need to dial within my ARI application instead of dialing from the extension.conf file i proceeded to do a basic application that will enable 2 extensions to dial each other using ARI library. I was working on creating the caller channel and then linking the 2 channels to a bridge so that the API works. All is good now thank you so much jcolp.