Answer call using Stasis and AsterNET

Hi everyone.

I’m trying to use ARI event to forward call from one extension to anothe essentialy bypassing the diaplan.
In the code used below event is fired twice but it throws an exception with message 412 Precondition Failed

Anyone know how could I call an extension and answer a call using AsterNET library?

                Console.WriteLine($"Channel {e.Channel.Id} entered Stasis.");
                Console.WriteLine($"Channel state: {e.Channel.State}.");

                if (e.Channel.State != "Up")
                var bridge = await _client.Bridges.CreateAsync(type: "mixing");
                _client.Bridges.AddChannel(bridge.Id, e.Channel.Id);
                var context = "from-internal-custom";
                var endPoint = $"Local/{100}@{context}"; // The extension you want to dial
                // var endPoint = "PJSIP/100"; // The extension you want to dial
                var extension = "101";
                var timeout = 30; // Timeout in seconds for dialing the extension

                var newChannel = _client.Channels.Create(
                    endpoint: endPoint,
                    app: _app,
                    channelId: $"forward-{Guid.NewGuid()}");

                Console.WriteLine($"New channel Id: {newChannel.Id}.");
                Console.WriteLine($"New channel state: {newChannel.State}.");
                if (newChannel.State != "Up")
                _client.Bridges.AddChannel(bridge.Id, newChannel.Id);
            catch (Exception exception)

You may find this discussion helpful

Hi James. Will look into it. Thanks for answering.

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