ARI and making a call between 2 extensions through ari-client

Hi there!

I am fairly new to Asterisk and was lately focused on ARI. In particular I am trying to make sens of pieces required to gain some call control functionality through web interface. Naturally, I was quickly directed to ARI. I am able to run examples offered as part of ‘node-ari-client’. I am trying to wrap my head around few things though:

  1. My goal is to have javascript along with node.js and node-ari-client to initiate call between extensions 7000 and 7001. Initiate call to 7000, once it answers the call, call 7001 and then once it answers connect 7000 and 7001 to have a speech path.

  2. At the moment I am using FreePBX. It generates a set of configuration files which I can’t edit directly. All node-ari-client examples refer to changing ‘extensions.conf’ file. Instead I achieved what required through changing ‘extensions_custom.conf’, in particular ‘[from-internal-custom]’ section. Now, examples say to add something like this in extensions.conf for Stasis application to get activated:

exten => 7000,1,NoOp()
same => n,Stasis(originate-example)
same => n,Hangup()

Once I do introduce such change in a dialplan, I am no longer able to call extension 7000 any more. Rather, when I call 7000 Stasis application is invoked. So, lets say if I would like to use node-ari-client how would I make a call between extensions 7000 and 7001? How should I change a dialplan so that I can initiate call between any 2 extensions on the PBX? Would I have to create Stasis dialplan action for each and every extension? Ideally, what I want is to have 7000 and 7001 behave as normal extensions (can call out, can be called), but I should be able to activate Stasis and through ARI make connections to these extensions. From what I have seen, Statis application only gets activated when SIP call is made for extension for which there is a dialplan with Stasis application defined.

  1. Since I am using FreePBX how to change configuration files and dialplans to achieve goal defined in step #1?

  2. Let’s say I have my javascript nice and fine and does exactly what I want explained in step #1, how do I apply this javascript on a web server? What happens to the Node.js in that case?

Regards,
Zarko

ARI allows you to write telephony applications outside of Asterisk, using it for handling the harder parts. There is no built-in way using ARI to call from one extension to another. You have to use the primitives of ARI to write that logic. As well ARI requires a persistent connection which is why a node.js application is used and not a script on a webserver. A more complete overview (along with tutorials) is on the wiki[1]. As for your questions in relation to FreePBX, I do not use it and am unfamiliar with their generated dialplan and the potential interactions.

[1] https://wiki.asterisk.org/wiki/pages/viewpage.action?pageId=29395573

First, thanks for responding. I guess, my question was an aggregate of several questions. Before demanding clarity, maybe I should clarify my question first :slight_smile:

My current config already has dialplan actions which are executed when INVITE is received for extension 7000. To kick off Stasis app for that extension I have to somehow append/insert

exten => 7000,1,NoOp()
same => n,Stasis(originate-example)
same => n,Hangup()

section into dialplan. I do not know how to do that :frowning: For the moment, let’s forget the fact I am using Freepbx . If I know how that’s done in regular dialplan definition, I’ll find a way how to do it in Freepbx files. At least I hope I will. In Asterisk without FreePbx beside Stasis part is there not more meat regarding dialplan for extension 7000?

But, even then how to fix this: stasis kicks in when INVITE to 7000 is received. But how would I tell Asterisk to initiate an INVITE to extension 7000 in the first place? It appears I can’t use Stasis app before channel for 7000 created. Which ARI primitive in particular I have to use to tell Asterisk to make a call (send INVITE out to extension 7000)?

Zarko

You would insert it into the context where the incoming call is. Dialplan contexts and extensions are a basic concept in Asterisk, FreePBX takes care of all of that and so you don’t need to understand them. Further details are online[1].

As for ARI primitive… there’s one to initiate an outgoing channel. Once answered you would then have to use another to create a bridge and add the two channels so they can exchange media.

ARI is not something you can jump into without a basic understanding of Asterisk and without some programming experience. If you are unable to follow the tutorials[2][3] you are likely to run into further problems as you continue.

[1] http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/asterisk-DP-Basics.html
[2] https://wiki.asterisk.org/wiki/display/AST/Introduction+to+ARI+and+Channels
[3] https://wiki.asterisk.org/wiki/display/AST/Introduction+to+ARI+and+Bridges

Cool. I think I got the idea where to start and search for additional information. Thanks