Dial Plan logging help

Hi Guys

I have a specific need to play audio annoucements to both parties on connection of any calls that states the call will be recorded.

I have acheived this with the Dial() application and the included “Play an announcement” option it has, all good so far.

But futher to this need, for compliance reasons we need to log an entry somewhere (log file, syslog etc) that proves the annoucement was played to the parties.

I have somewhat got this working but its NOT elegant at all and has its flaws.

I have implemented the following in my Dial Plan (just a small snip of the relevant section)

exten => _X.,1,GotoIf($[${DEVICE_STATE(PJSIP/${EXTEN})} != INVALID]?10:15)
exten => _X.,10,Log(compliance,Calling Party: ${CDR(clid)} - Called Party: ${EXTEN} - Play VR annoucement)
exten => _X.,n,Dial(PJSIP/${EXTEN},300,aA(call-recorded:call-recorded))
exten => _X.,n,Congestion(10)
exten => _X.,15,Log(compliance,Calling Party: ${CDR(clid)} - Called Party: ${EXTEN} - Play VR annoucement)
exten => _X.,n,Dial(PJSIP/${EXTEN}@CUCM,300,aA(call-recorded:call-recorded))
exten => _X.,n,Congestion(10)

As you can see I am using the Log() application to generate a specific log entry which states the Calling and Called party and states it has “Play VR annoucement”

I then added this in the logger.conf which is working perfectly and I get an entry into local log file as well as a Syslog sent out to my external Syslog Server that stores these logs.

[general]
custom_levels = compliance
[logfiles]
compliance.log => compliance
syslog.local1 => compliance

The flaw here is that it is logging my entry before the Dial() application is envoked, and if my call is not actually successful, ie it rings and never gets answere or ended before the call was answered etc, then I have an entry that is not realistically true.

The question is do any of you have a better solution as my knowledge on the programatical side of the Dial Plan is limited, in which I can generate this log entry based on certain outcomes of the DIal() application, in other word if the Call Succeeded in that it was answered then I log the entry if the call was rejected or never answered then I dont log an entry?

Why don’t you apply a conditional to the DIALSTATUS variable? If it is ANSWERED, log it; otherwise, don’t log it.

Hi there

Many thanks for the reply.

It would be a great help if you could give a small example of how to achieve that :slight_smile:
I have limited experience with the Dial Plan

I will go read the doc in the meantime to see if I can figure it out, so thanks for steering me in that direction.

Thanks very much for this helpful example, based on this I attempted to retro fit it for my needs, but its not working as my system always stops futher dialplan processing after the Dial() is initiated, as I can see it always exits with a “exited with non-zero on …” (regardless if the calls is answered or not) so no further dial plan entries are processed which is where the log logic is contained?

My updated dial plan based on the example

exten => _X.,1,GotoIf($[${DEVICE_STATE(PJSIP/${EXTEN})} != INVALID]?local-ext:non-local-ext)
exten => _X.,n(local-ext),Dial(PJSIP/${EXTEN},300,aA(calls-recorded-male:calls-recorded-male))
exten => _X.,n,Set(STATUS=${DIALSTATUS})
exten => _X.,n,GotoIf($["${STATUS}" = "ANSWER"]?log:)
exten => _X.,n,Congestion(10)

exten => _X.,n(non-local-ext),Dial(PJSIP/${EXTEN}@sbc-trunk,300,aA(calls-recorded-male:calls-recorded-male))
exten => _X.,n,Set(STATUS=${DIALSTATUS})
exten => _X.,n,GotoIf($["${STATUS}" = "ANSWER"]?log:)
exten => _X.,n,Hangup()

exten => _X.,n(log),Log(compliance,Calling Party: ${CDR(clid)} - Called Party: ${EXTEN} - Play VR announcement)
exten => _X.,n,Hangup()
[Jul 12 02:48:12] NOTICE[654667]: app_queue.c:9607 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
    -- Remote UNIX connection disconnected
    -- Executing [3010@sbc-incoming:1] GotoIf("PJSIP/sbc-trunk-0000005d", "1?local-ext:non-local-ext") in new stack
    -- Goto (sbc-incoming,3010,2)
    -- Executing [3010@sbc-incoming:2] Dial("PJSIP/sbc-trunk-0000005d", "PJSIP/3010,300,aA(calls-recorded-male:calls-recorded-male)") in new stack
    -- Called PJSIP/3010
    -- PJSIP/3010-0000005e is ringing
    -- PJSIP/3010-0000005e answered PJSIP/sbc-trunk-0000005d
    -- <PJSIP/3010-0000005e> Playing 'calls-recorded-male.slin' (language 'en')
    -- <PJSIP/sbc-trunk-0000005d> Playing 'calls-recorded-male.slin' (language 'en')
    -- Channel PJSIP/3010-0000005e joined 'simple_bridge' basic-bridge <b166ffca-180f-48b4-92ae-4940faa51dea>
    -- Channel PJSIP/sbc-trunk-0000005d joined 'simple_bridge' basic-bridge <b166ffca-180f-48b4-92ae-4940faa51dea>
    -- Channel PJSIP/sbc-trunk-0000005d left 'simple_bridge' basic-bridge <b166ffca-180f-48b4-92ae-4940faa51dea>
  == Spawn extension (sbc-incoming, 3010, 2) exited non-zero on 'PJSIP/sbc-trunk-0000005d'
    -- Channel PJSIP/3010-0000005e left 'simple_bridge' basic-bridge <b166ffca-180f-48b4-92ae-4940faa51dea>

Once the call has been answered and then hung up, it will trigger the h extension. Therefore, you should use the h extension or a hangup handler. My apologies for the confusion earlier

Thanks very much for your assistance!!

I have it working perfectly now with your guidance on where to look I was able to figure it out.

Below is the dial plan which got things working for me.
It now only logs the complaince log when the DialStatus = ANSWER and in all other situations it does not.

I had to do some Variable sets at the start to retain the CDR and EXTEN values, as they do not persist when you move to the gosub, so setting them at the start I can call them in the gosub and everything works perfect then.

[sbc-incoming]

exten => _X.,1,Set(CHANNEL(hangup_handler_push)=hdlr1,s,1)
exten => _X.,n,Set(Cdr=${CDR(clid)})
exten => _X.,n,Set(Ext=${EXTEN})

exten => _X.,n,GotoIf($[${DEVICE_STATE(PJSIP/${EXTEN})} != INVALID]?local-ext:non-local-ext)

exten => _X.,n(local-ext),Dial(PJSIP/${EXTEN},300,aA(calls-recorded-male:calls-recorded-male))
exten => _X.,n,Congestion(10)

exten => _X.,n(non-local-ext),Dial(PJSIP/${EXTEN}@sbc-trunk,300,aA(calls-recorded-male:calls-recorded-male))
exten => _X.,n,Hangup()

[hdlr1]

exten => s,1,Set(STATUS=${DIALSTATUS})
exten => s,n,GotoIf($[${STATUS} = ANSWER]?log:done)
exten => s,n(log),Log(compliance,Calling Party: ${Cdr} - Called Party: ${Ext} - Played VR announcement)
exten => s,n(done),Return()
1 Like

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