N
N
nicolaa2020-09-30 07:23:03
Asterisk
nicolaa, 2020-09-30 07:23:03

How to get information about an incoming Asterisk ARI call?

Connect to Asterisk using websocket

var connection = new WebSocket("ws://ip:port/ari/events?app=qwer&subscribeAll=true&api_key=user:password")


get all events

connection.onmessage = function(evt) {
          var msg = JSON.parse(evt.data);
          console.log(msg);
    }


And I parse the result into JSON

I can't figure out the documentation for ARI
What is a channel and a bridge?

How to catch the event of an incoming call and picking up the operator's handset (to get the extension number of the operator)?

I read a lot of information on AIR, but it was not possible to draw conclusions.

For example, there is an article , but apparently it is outdated

In the article, when new messages are received, it looks for `event` with the value `incoming`

switch (msg.event) {
                    case 'incoming':


When I receive new messages, there is no `event` in them

Example of what messages are coming

{
      "type": "ChannelCreated",
      "timestamp": "2020-09-30T09:13:28.451+0500",
      "channel": {
        "id": "id",
        "name": "SIP/",
        "state": "Down",
        "caller": {
          "name": "",
          "number": ""
        },
        "connected": {
          "name": "",
          "number": ""
        },
        "accountcode": "",
        "dialplan": {
          "context": "incoming",
          "exten": "s",
          "priority": 1
        },
        "creationtime": "2020-09-30T09:13:28.451+0500",
        "language": "en"
      },
      "application": "qwer"
    }
    {
      "variable": "QUEUENAME",
      "value": "operators",
      "type": "ChannelVarset",
      "timestamp": "2020-09-30T09:14:01.628+0500",
      "channel": {
        "id": "id",
        "name": "SIP/",
        "state": "Up",
        "caller": {
          "name": "78008888888",
          "number": "+79099999999"
        },
        "connected": {
          "name": "",
          "number": ""
        },
        "accountcode": "",
        "dialplan": {
          "context": "incoming",
          "exten": "incom",
          "priority": 15
        },
        "creationtime": "2020-09-30T09:12:38.097+0500",
        "language": "ru"
      },
      "application": "qwer"
    }
    {
      "variable": "QUEUESRVLEVELPERF",
      "value": "0.0",
      "type": "ChannelVarset",
      "timestamp": "2020-09-30T09:14:01.629+0500",
      "channel": {
        "id": "id",
        "name": "SIP/",
        "state": "Up",
        "caller": {
          "name": "78008888888",
          "number": "+79099999999"
        },
        "connected": {
          "name": "",
          "number": ""
        },
        "accountcode": "",
        "dialplan": {
          "context": "incoming",
          "exten": "incom",
          "priority": 15
        },
        "creationtime": "2020-09-30T09:12:38.097+0500",
        "language": "ru"
      },
      "application": "qwer"
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2020-10-01
@Rsa97

What is a canal and a bridge?
A channel is a connection between Asterisk and an endpoint (phone). A bridge is an internal connection between multiple channels in Asterisk.
For example, there is an article, but apparently it is outdated
This article uses AMI, not ARI.
According to ARI, the simplest conversation looks like this:
spoiler
ChannelCreated - создан канал с вызывающим абонентом
DeviceStateChanged, INUSE - вызывающее устройство сменило статус
ChannelVarset, SIPURI - установка значения переменной
ChannelVarset, SIPDOMAIN
ChannelVarset, SIPCALLID
ChannelStateChange, Ring - изменение статуса канала
ChannelDialplan, Dial - сработала команда Dial в диалплане
ChannelVarset, DIALSTATUS
ChannelVarset, DIALEDPEERNUMBER
ChannelVarset, DIALEDPEERNAME
ChannelVarset, ANSWEREDTIME
ChannelVarset, DIALEDTIME
DeviceStateChanged, RINGING - звонок у вызываемого абонента
ChannelCreated - создан канал до вызываемого абонента
ChannelVarset, SIPCALLID
ChannelVarset, DIALEDPEERNUMBER
ChannelDialplan, AppDial - команда Dial в канале вызываемого абонента
ChannelConnectedLine - изменилась информация о каналах
Dial - производится вызов абонента
ChannelConnectedLine
ChannelStateChange, Ringing - изменение статуса канала
Dial, RINGING - звонок на вызываемой линии
DeviceStateChanged, BUSY - поднята трубка у вызываемого абонента
ChannelStateChange, Up - изменение статуса канала вызываемого абонента
ChannelVarset, DIALSTATUS
ChannelVarset, DIALEDPEERNAME
ChannelVarset, DIALEDPEERNUMBER
Dial, ANSWER - ответ на вызываемой линии
ChannelStateChange, Up - изменение статуса канала вызывающего абонента
BridgeCreated - создан мост
ChannelDialplan, AppDial - команда Dial в канале вызываемого абонента
DeviceStateChanged, INUSE - у вызывающего абонента
ChannelEnteredBridge - вызываемый канал подключился к мосту
ChannelEnteredBridge - вызывающий канал подключился к мосту
ChannelVarset, BRIDGEPEER
ChannelVarset, BRIDGEPVTCALLID
ChannelVarset, BRIDGEPEER
ChannelVarset, BRIDGEPVTCALLID
ChannelVarset, RTPAUDIOQOS
ChannelVarset, RTPAUDIOQOSBRIDGED
ChannelVarset, RTPAUDIOQOSJITTER
ChannelVarset, RTPAUDIOQOSJITTERBRIDGED
ChannelVarset, RTPAUDIOQOSLOSS
ChannelVarset, RTPAUDIOQOSLOSSBRIDGED
ChannelVarset, RTPAUDIOQOSRTT
ChannelVarset, RTPAUDIOQOSRTTBRIDGED
ChannelVarset, RTPAUDIOQOSBRIDGED
ChannelVarset, RTPAUDIOQOS
ChannelVarset, RTPAUDIOQOSBRIDGED
ChannelVarset, RTPAUDIOQOSJITTER
ChannelVarset, RTPAUDIOQOSJITTERBRIDGED
ChannelVarset, RTPAUDIOQOSLOSS
ChannelVarset, RTPAUDIOQOSLOSSBRIDGED
ChannelVarset, RTPAUDIOQOSRTT
ChannelVarset, RTPAUDIOQOSRTTBRIDGED
ChannelVarset, RTPTEXTQOS
DeviceStateChanged, NOT_INUSE - вызываемый абонент положил трубку
ChannelHangupRequest - завершение канала вызывающего абонента
ChannelVarset, BRIDGEPEER
ChannelVarset, BRIDGEPVTCALLID
ChannelVarset, BRIDGEPEER
ChannelVarset, BRIDGEPVTCALLID
ChannelLeftBridge - вызывающий канал вышел из моста
ChannelLeftBridge - вызываемый канал вышел из моста
ChannelVarset, ANSWEREDTIME
ChannelVarset, DIALEDTIME
ChannelVarset, DIALSTATUS
ChannelHangupRequest - завершение канала вызывающего абонента
ChannelVarset, RTPAUDIOQOS
ChannelVarset, RTPAUDIOQOSJITTER
ChannelVarset, RTPAUDIOQOSLOSS
ChannelVarset, RTPAUDIOQOSRTT
ChannelDestroyed - вызывающий канал уничтожен
ChannelDestroyed - вызываемый канал уничтожен
DeviceStateChanged, NOT_INUSE - вызывающий абонент положил трубку

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question