Not getting "connected" details in ARI StasisStart event

I’m expecting to get the caller number and the connected number in the ARI Stasis Start event but the connected number field is empty.

Is it also possible to add the international code to the caller number that I’m receiving (ideally the E.164 format)?

This is the StasisStart event,

event: {
      "type": "StasisStart",
      "timestamp": "2022-03-28T12:09:17.094+0530",
      "args": [],
      "channel": {
        "id": "1648449557.0",
        "name": "PJSIP/airtel-00000000",
        "state": "Ring",
        "caller": {
          "name": "",
          "number": "894959****"
        },
        "connected": {
          "name": "",
          "number": ""
        },
        "accountcode": "",
        "dialplan": {
          "context": "ari-demo",
          "exten": "s",
          "priority": 2,
          "app_name": "Stasis",
          "app_data": "voice"
        },
        "creationtime": "2022-03-28T12:09:17.094+0530",
        "language": "en"
      },
      "asterisk_id": "b0:7b:25:1d:19:01",
      "application": "voice"
    }

This is the dialplan,

[ari-demo]
exten => s,1,Verbose("Passing context to voice app")
 same =>   n,Stasis(voice)
 same =>   n,Hangup()

Asterisk is a tool kit. It doesn’t transform numbers that it receives; that is for you application to do.

Also what are you expecting for “connected” right there? What is the actual scenario? There may not even be any connected party/information.

I’m not a user of ARI, but I don’t think Asterisk will have a connected line number on a call that hasn’t yet been connected. Ring indicates an incoming, unanswered call. I suspect what you really want is the original extension number.

I am expecting the extension number that has been dialed. For example, if this is the dialplan

exten => 105,1,Goto(ari-demo,s,1)

[ari-demo]
exten => s,1,Verbose("Passing context to voice app")
 same =>   n,Stasis(voice)
 same =>   n,Hangup()

Then I would expect to see 105 in the connected.number value.

What is the actual scenario?

I’ve built an ARI interface that plays different welcome sound file based on the extension that has been dialed by the caller.

I see that the StasisStart event mentions s as the extension.

"dialplan": {
  "context": "ari-demo",
  "exten": "s",
  "priority": 2,
  "app_name": "Stasis",
  "app_data": "voice"
},

Is there a way I can pass on the extension number to the StatisStart event? Or is there any ARI Endpoint I can check that will return me these details?

The easiest way is to call Stasis() directly, rather than Goto. You could also put the Stasis() in its own context, with a wild card extension match and go to the same extension in the new context.

Can you please give an example of this? I understand the other scenario and changing the dialplan to following gives me the extension code,

exten => 111,1,Stasis(voice)

StasisStart Event,

event: {
      "type": "StasisStart",
      "timestamp": "2022-03-28T16:15:13.654+0530",
      "args": [],
      "channel": {
        "id": "1648464313.2",
        "name": "PJSIP/6001-00000002",
        "state": "Ring",
        "caller": {
          "name": "shai",
          "number": "6001"
        },
        "connected": {
          "name": "",
          "number": ""
        },
        "accountcode": "",
        "dialplan": {
          "context": "from-internal",
          "exten": "111",
          "priority": 1,
          "app_name": "Stasis",
          "app_data": "voice"
        },
        "creationtime": "2022-03-28T16:15:13.653+0530",
        "language": "en"
      },
      "asterisk_id": "b0:7b:25:1d:19:01",
      "application": "voice"
    }

In this case I get the extension code, however is there any way to make it work with Goto() as well? Also in which case does Asterisk send me “connected” information? I was under the impression that it would be the dialed number by the caller but that doesn’t seem to be the case

You were under a false impression.

https://wiki.asterisk.org/wiki/display/AST/Manipulating+Party+ID+Information

1 Like

GoTo(stasiscontext,${EXTEN},1)

Hey David, this is how my dialplan looks like with this. I’m not sure how do I use the EXTEN variable in the context so I used pattern matching,

exten => 112,1,Goto(stasiscontext,${EXTEN},1)

[stasiscontext]
exten => _.,1,Stasis(voice)
 same =>    n,Hangup()
event: {
      "type": "StasisStart",
      "timestamp": "2022-03-28T17:01:54.217+0530",
      "args": [],
      "channel": {
        "id": "1648467107.4",
        "name": "PJSIP/6001-00000004",
        "state": "Ring",
        "caller": {
          "name": "shai",
          "number": "6001"
        },
        "connected": {
          "name": "",
          "number": ""
        },
        "accountcode": "",
        "dialplan": {
          "context": "stasiscontext",
          "exten": "h",
          "priority": 1,
          "app_name": "Stasis",
          "app_data": "voice"
        },
        "creationtime": "2022-03-28T17:01:47.170+0530",
        "language": "en"
      },
      "asterisk_id": "b0:7b:25:1d:19:01",
      "application": "voice"
    }

Can you tell me how should I structure the context dialplan to have dialplan.exten say the extension?

Thanks! Interestingly this also mentions,

Use interception macros to make outbound connected number E.164 formatted.

I will look into those as well!

_. also matches the special extensions, like h for hangup.

Typically one uses _X. to require at least one digit.

1 Like

and if you want to be fancy

exten => _[0-9#*+]!,1,Stasis(voice)

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