1
votes

I am working on a predictive dialer-like application in which I should detect whether the call was picked up by a voicemail or not.

I am using the follwing:

Server: I am using FreeSWITCH v1.6.11. I built and configured AVMD module.

Client: I am using sipml5 connected to Freeswitch via WSS.

The idea is when Freeswitch detects a beep sound, it will fire an event called AVMD_EVENT_BEEP.

In the following log, I am using a telnet client connected to FreeSWITCH socket. I subscribed to the event via socket and here is the result:

    event plain CUSTOM avmd::beep

    Content-Type: command/reply
    Reply-Text: +OK event listener enabled plain
    Content-Length: 737
    Content-Type: text/event-plain

    Event-Subclass: avmd%3A%3Abeep
    Event-Name: CUSTOM
    Core-UUID: 1c8e8e58-8b46-11e6-99c3-238295cb19cb
    FreeSWITCH-Hostname: debian
    FreeSWITCH-Switchname: debian
    FreeSWITCH-IPv4: 176.58.104.114
    FreeSWITCH-IPv6: 2a01%3A7e00%3A%3Af03c%3A91ff%3Afeae%3Ad2d6
    Event-Date-Local: 2016-10-05%2022%3A47%3A21
    Event-Date-GMT: Wed,%2005%20Oct%202016%2022%3A47%3A21%20GMT
    Event-Date-Timestamp: 1475707641468562
    Event-Calling-File: mod_avmd.c
    Event-Calling-Function: avmd_fire_event
    Event-Calling-Line-Number: 437
    Event-Sequence: 2420
    Unique-ID: a894fffc-8b4d-11e6-9aa3-238295cb19cb
    Call-command: avmd
    Beep-Status: DETECTED
    Frequency: 1001.084123
    Frequency-variance: 0.000203
    Amplitude: 12541.343475
    Amplitude-variance: 33583.241944
    Detection-time: 7320038

On FreeSwitch documentation page https://freeswitch.org/confluence/display/FREESWITCH/mod_avmd, they say "The event is delivered to your ESL socket listener, to command prompt and written to logs. Avmd also sets the channel variable (see "Channel variables")."

Ok that's cool. But what is the purpose if there is no way so the client can detect the event.

I want the client to subscribe to this event and get notified via SIP.

I tried with subscribe Header on sipml5 as follows:

var onEvent = function(e){
  if(e.type == 'i_notify'){
    // process incoming NOTIFY request
    console.info('NOTIFY content = ' + e.getContentString());
    console.info('NOTIFY content-type = ' + e.getContentType());
  }
}
var session = this.newSession('subscribe', {
  expires: 200,
  events_listener: { events: '*', listener: onEvent },
  sip_headers: [
    { name: 'Event', value: 'AVMD_EVENT_BEEP' },
    { name: 'Accept', value: 'text/event-plain' }
  ],
  sip_caps: [
    { name: '+g.oma.sip-im', value: null },
    { name: '+audio', value: null },
    { name: 'language', value: '\"en,fr\"' }
  ]
});
session.subscribe('sip:xxxxx@mydomain');

But the problem is, the server is reponding with a BAD EVENT status.

Any idea how I can detect the event on my client? Maybe detecting it on the server and triggering a sip notify to the client?

2

2 Answers

1
votes

Ok I solved it. As there is no a direct way to do it. I had to make an outbound esl daemon to which Freeswitch will post data if the event is triggered. in my dialplan, I tell Freeswitch to open a connection to the daemon.

Now from that daemon I open a new inbound socket to freeswitch and I send a custom notify event using sendEvent() from esl. Finally Freeswitch will deliver the notify packet to the client.

Hope this helps somebody.

1
votes

with predictive dialers, you usually don't signal these events outsde the dialer. The dialer would have a number of destination numbers, and handle the call establishing by itself. Only when the call is established and confirmed that there's a human on the other end, then the agent is bridged with that call.