AsterNET.ARI how to implement a simple call between internal numbers?

72 Views Asked by At

I need to call from number 401 to 402 using AsterNET.ARI Asterisk ARI (401 and 402 are two internal numbers that are connected to softphones)

my extensions.conf

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

c#

using AsterNET.ARI;
using AsterNET.ARI.Helpers;
using AsterNET.ARI.Models;

var AppName = "originate-example";

var actionClient = new AriClient(new StasisEndpoint("127.0.0.1", 8088, "asterisk", "asterisk"), AppName);
actionClient.Connect();

//I subscribe to the application start event
actionClient.OnStasisStartEvent += ActionClientOnOnStasisStartEvent;

void ActionClientOnOnStasisStartEvent(IAriClient sender, StasisStartEvent e)
{
    //answer the call
    actionClient.Channels.Answer(e.Channel.Id);
    
    //sound file is playing
    SyncHelper.Wait(actionClient.Channels.Play(e.Channel.Id, "sound:vm-dialout", "en", 0, 0, Guid.NewGuid().ToString()), actionClient);



     //I'm trying to call from 401 number to 402 but the call doesn't happen
     actionClient.Channels.Originate(
          endpoint:"PJSIP/401", //the number from which I called 1000 to start stasis
          extension:"402", //the number I'm calling
          callerId:"401",  
          timeout:100000 ,
          app:AppName,
          priority: 1
          );


}

Console.ReadLine();

The description of the library says that the bridge is created automatically when Channels.Originate run, but the call is not made. I couldn’t find an example in the library documentation on how to implement a simple call.

1

There are 1 best solutions below

0
On

For simple calls between internal number you have to use dialplan usign Dial command.

Just in case the internet is down or your application is malfunctioning.

If you still want do it via .net - use context instead of application as second param(and very likely you also want use Local/EXTEN@context instead of pjsip for first).

https://docs.asterisk.org/Asterisk_16_Documentation/API_Documentation/Dialplan_Applications/Originate/

ps what are you showing is ANOTHER not related call for call to 1000 exten.