How to perform dial call from Stasis application to PJSIP?

My Stasis application should perform a dial without continue to dialplan between to PJSIP extensions.
I tried to send a POST request to https://hostname/ari/channels/{channel.id}/dial where channel.id is a current channel
Got: message: “Channel is not in the ‘Down’ state”

You can originate[1] and send it to the dialplan OR the Stasis application, or you can create[2] and then dial[3]. If this isn’t what you want, then you’re going to need to explain in more detail what you are trying to achieve.

It’s up to you once channels are in your Stasis application to do the rest of the work of connecting them together, through creating a bridge and adding the channels.

[1] Channels - Asterisk Documentation
[2] Channels - Asterisk Documentation
[3] Channels - Asterisk Documentation

I"ll try to explain detailly.
I have some Stasis application (initiated on the beginning of the context) that on StasisStart event have to dial between 2 PJSIP extensions (without continue to the dialplan) in other words Stasis app should manage the call

Then you would use either the originate functionality I linked, or create/dial.

I try the second way:
On StasisStart event I receive originalChannel

  1. Create a new channel: /channels/create → newChannel
  2. Dial : /channels/{newChannel.id}/dial
    {
    caller: originalChannel.id
    }

But in this case I have no a “brige” between two extensions. Caller extension is connected to Stasis with originalChannel and Stasis is connected to the destination with a newChannel. So I have no call ((

It’s up to you to create a bridge in ARI, and add the channels.

ARI gives you the primitives and fundamentals to create telephony applications, it’s up to you to use them and put them together.

I have an example of ARI bridge setup in the track_call_ari_bridged_async script in this repo.

Thanks for your help. I want to create a bridge only after the call has been answered and then to add both channels. Is it possible?
I use POST /channels to create a new channel with params:

{
        endpoint: `PJSIP/${channel.dialplan.exten}`,
        app: applicationName,
        originator: channel.id
    }

The problem is: on Dial event I receive only the channel ID created and don’t have the first one:

{
  type: 'Dial',
  timestamp: '2024-01-29T12:49:15.565+0000',
  dialstatus: 'ANSWER',
  forward: '',
  dialstring: '',
  peer: {
    id: '1706532553.23',
    name: 'PJSIP/601-00000014',
    state: 'Up',
    protocol_id: 'ed10849c-6b28-4231-aafc-8bbdb7f98265',
    caller: { name: 'Eli 601', number: '601' },
    connected: { name: 'Eli 600', number: '600' },
    accountcode: '',
    dialplan: {
      context: 'from-internal',
      exten: 's',
      priority: 1,
      app_name: 'Stasis',
      app_data: 'stasis-local-app'
    },
    creationtime: '2024-01-29T12:49:13.307+0000',
    language: 'en'
  },
  asterisk_id: '06:ae:5e:a8:a5:81',
  application: 'stasis-local-app'
}

If you code it, it is certainly possible. It’s all up to the ARI application implementation - that includes knowing state, knowing who should be connected to who, at what time. Some details are in events but that may not mean that they provide all of the state information to do what you want to do.

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