Every so often I see someone ask whether it’s possible to make internal calls have a distinctive ring from external ones. I thought it would not be that difficult, but I was wrong. Let’s say that you have three-digit extensions, and whenever someone calls extension 234 you want it to ring with the normal pattern if it’s an external call, but with a different pattern if it’s an internal call (and we assume here that the endpoint supports this). This is as far as I got - in extensions_custom.conf, I added the following at the bottom of the [from-internal-custom] context:
exten => 234,1,Goto(checkiflocal,${EXTEN},1)
[checkiflocal]
exten => _XXX,1,GotoIf($["${CALLERID(num)}" > “999”]?notfromext)
exten => _XXX,n,GotoIf($["${CALLERID(num)}" < “100”]?notfromext)
exten => _XXX,n,Set(__ALERT_INFO=Bellcore-r4)
exten => _XXX,n(notfromext),Goto(from-internal,${EXTEN},2)
The above actually works in testing, but it’s not right. The problem here is returning to the from-internal context. What I want it to do is return to from-internal and continue processing without skipping anything that should execute, but an include apparently isn’t designed that way. The first statement that matches extension 234 apparently means that the next statement must be number 2, or something like that (I’m REALLY confused at the moment). Anyway, the difference is that when I make a call without the above added lines, the first two lines of CLI output are these:
-- Executing [234@from-internal:1] GotoIf("SIP/230-b7d17a30", "0?ext-local|234|1") in new stack
-- Executing [234@from-internal:2] Macro("SIP/230-b7d17a30", "user-callerid|") in new stack
BUT, if I use the above added code, the conditional call to ext-local is completely skipped, and after executing my added lines it picks up with the second line. You might say “but of course, because you are specifying line 2 in the Goto” - but if I specify Line 1, it just goes into an endless loop until I hang up.
Is there some way I can accomplish the above without skipping the conditional call to ext-local? So far that doesn’t seem to make a difference, but then I have no idea where that Gosub is in the actual code so I have no idea under what circumstances the call to ext-local is supposed to be invoked. And there may be other includes that are being skipped as well.
Any thoughts?