Dialplan with Cisco Callmanager patch

I’ve applied the “cisco usecallmanager” patch and am trying to get the following to work, which is basically what allows extensions to be called and unanswered calls are sent to voicemail depending on the status of the line:

[call-extension]
exten => _X.,1,Set(PEERNAME=${EXTEN})
; By manually checking for call-forwarding, the call can be forwarded even if the phone is unregistered
same => next,Set(CALLFORWARD=${SIPPEER(${PEERNAME},forward)})
same => next,GotoIf($[${LEN(${CALLFORWARD})} != 0]?forward,1)
; Phones can be made to play a different ring using the Alert-Info header, see Ring Tones for examples
same => next,ExecIf($[${LEN(${ALERT_INFO})} != 0]?SIPAddHeader(Alert-Info: <${ALERT_INFO}>))
same => next,Dial(SIP/${PEERNAME},15)
same => next,Goto(${TOLOWER(${DIALSTATUS})},1)

exten => congestion,1,Goto(noanswer,1)
exten => chanunavail,1,Goto(noanswer,1)

exten => noanswer,1,Set(GREETING=u)
same => next,Goto(leave-voicemail,${EXTEN},1)

exten => busy,1,Set(GREETING=b)
same => next,Goto(leave-voicemail,${EXTEN},1)

exten => forward,SIPAddHeader(Diversion: “${SIPPEER(${PEERNAME},callerid_name)}” sip:${SIPPEER(${PEERNAME},callerid_num)}@localhost;screen=yes;privacy=o$
same => Goto(phones,${CALLFORWARD},1)

[leave-voicemail]
exten => _X.,1,Set(MAILBOX=${SIPPEER(${EXTEN},mailbox)})
same => next,Answer()
same => next,Wait(0.5)
same => next,VoiceMail(${MAILBOX},${GREETING})
same => next,Hangup(normal_clearing)

When attempting to dial extension 100 and leave a voicemail, this error comes up and the voicemail greeting never comes on:

“…sent to invalid extension noanswer in context leave-voicemail, but no invalid handler”

That makes sense because there is no extension “noanswer” in the “leave-voicemail” context.

The only question is, why does it think it is trying to leave a voicemail at extension “noanswer” and not extension 100 like it should?

This seems to be the line causing the problem:

exten => noanswer,1,Set(GREETING=u)
same => next,Goto(leave-voicemail,${EXTEN},1)

This code is straight off of the site for the Cisco Callmanager patch.

Any help is appreciated. Thanks.

It’s that right there, Your in the noanswer extension and when you goto leave-voicemail you are going in at the noanswer extension.

I would recommend changing your same => next,Goto(${TOLOWER(${DIALSTATUS})},1)

To instead be

same => next,Goto(${TOLOWER(${DIALSTATUS}))

and then making your congestion,chanunavail,npanswer, busy,forward, etc extensions labels instead.

1 Like

Can you possibly go into a bit more detail on this? I don’t think I fully understand.
Thanks.

call-extension]
exten => _X.,1,Set(PEERNAME=${EXTEN})
; By manually checking for call-forwarding, the call can be forwarded even if the phone is unregistered
same => n,Set(CALLFORWARD=${SIPPEER(${PEERNAME},forward)})
same => n,GotoIf($[${LEN(${CALLFORWARD})} != 0]?forward,1)
; Phones can be made to play a different ring using the Alert-Info header, see Ring Tones for examples
same => n,ExecIf($[${LEN(${ALERT_INFO})} != 0]?SIPAddHeader(Alert-Info: <${ALERT_INFO}>))
same => n,Dial(SIP/${PEERNAME},15)
same => n,Goto(${TOLOWER(${DIALSTATUS})})

same => n(congestion),Goto(noanswer)
same => n(chanunavail),Goto(noanswer)

same => n(noanswer),Set(GREETING=u)
same => n,Goto(leave-voicemail,${EXTEN},1)

same => n(busy),Set(GREETING=b)
same => n,Goto(leave-voicemail,${EXTEN},1)

same => n(forward),SIPAddHeader(Diversion: "${SIPPEER(${PEERNAME},callerid_name)}" <sip:${SIPPEER(${PEERNAME},callerid_num)}@localhost>\;screen=yes\;privacy=o$
same => n,Goto(phones,${CALLFORWARD},1)
1 Like

Thanks that worked.

I don’t want to just take this and use it without understanding why it works though.

I know that this line:

same => n,Goto(${TOLOWER(${DIALSTATUS})})

is saying to take the current dialstatus and convert it to lower case.
I’m assuming this is so that you can use the names that are used in the next several lines.

Are things like (congestion) and (noanswer) being used as priorities or labels?

I know you had mentioned priorities before so I’m thinking that’s what you meant but I wasn’t sure.

Thanks again for your help.

You are correct, I used the wrong term. That’s what I get for skipping my coffee :wink:

So your Goto is using the TOLOWER function to convert the variable DIALSTATUS to lowercase and then doing a goto to that label.

The congestion,noanswer,busy,etc are lables yes.

1 Like

No worries I understand! :laughing:

Thanks for the explanation, it was extremely helpful.

Take care!