# Asterisk ARI application

**URL:** <https://community.asterisk.org/t/asterisk-ari-application/82599>\
**Category:** Asterisk APIs\
**Created:** [February 5, 2020, 2:06pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599 "2020-02-05T14:06:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![amin224](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/amin224/32/4523_2.png) [@amin224](https://community.asterisk.org/u/amin224)\
**Post date:** [February 5, 2020, 2:06pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599/1 "2020-02-05T14:06:05Z")

</div>

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:

```auto
[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

```auto
   -- 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'

```

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [February 5, 2020, 3:45pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599/2 "2020-02-05T15:45:08Z")

</div>

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](https://wiki.asterisk.org/wiki/display/AST/Asterisk+17+Application_Dial)

---

<div class="post-metadata">

**Author:** ![amin224](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/amin224/32/4523_2.png) [@amin224](https://community.asterisk.org/u/amin224)\
**Post date:** [February 6, 2020, 12:40pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599/3 "2020-02-06T12:40:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [February 6, 2020, 12:43pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599/4 "2020-02-06T12:43:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amin224](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/amin224/32/4523_2.png) [@amin224](https://community.asterisk.org/u/amin224)\
**Post date:** [February 6, 2020, 2:15pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599/5 "2020-02-06T14:15:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [March 7, 2020, 2:22pm UTC](https://community.asterisk.org/t/asterisk-ari-application/82599/6 "2020-03-07T14:22:14Z")

</div>

Closed on March 7, 2020, 2:22pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
