This is a question for any FreePBX/Asterisk dialplan experts in the crowd.
Let’s suppose you want to add some code at the very start of the “from-internal” context. I realize you can create your own “from-internal” context in extensions_override_freepbx.conf but the pitfall there is that if the original from-internal ever changes, your “override” from-internal won’t track it.
The original from-internal is as follows (comments removed):
[from-internal]
include => from-internal-noxfer
include => from-internal-xfer
include => bad-number ; auto-generated
The two contexts mentioned in the includes are as follows:
[from-internal-noxfer]
include => from-internal-noxfer-custom
include => from-internal-noxfer-additional ; auto-generated
[from-internal-xfer]
include => from-internal-custom
include => from-internal-additional ; auto-generated
exten => s,1,Macro(hangupcall)
exten => h,1,Macro(hangupcall)
Now if a call gets transferred, it calls from-internal-xfer rather than from-internal. So if I want to do something (set a variable, perhaps) regardless of whether a call is directly dialed from an extension or transferred, I assume I could do this in extensions_custom.conf:
[from-internal-noxfer-custom]
exten => s,1,Macro(setmyvariable)
(… what goes here, if anything? …)
[from-internal-custom]
exten => s,1,Macro(setmyvariable)
(… what goes here, if anything? …)
Basically what I want to do in the -custom contexts is return to the normal from-internal call flow after the call to the macro returns. But since this was called using an include, I’m not sure what I’m supposed to do - since is not a macro or subroutine call, it doesn’t “return”, correct? So on the next line after the macro call, would it be more correct to:
- Just end the context with no additional statement, and the original from-internal-whichever context will continue to the next include?
- Insert the next line from the original context (“include => from-internal-whichever-additional”)
- Insert a goto that jumps to whatever would have been the next thing included in the original context ("exten _.,1,Goto(from-internal-whichever-additional,${exten},1)
Or something else entirely?
I just get a little confused on the differences between includes, macros, and gosubs, and even the Asterisk: TFOT book doesn’t offer a lot of clarity on the subject (other than to note that generally speaking, you can only use the s extension in a macro).
Also, would it make any difference if, instead of calling a macro in my -custom contexts, I did something specific if a specific extension were called? For example, something like:
[from-internal-noxfer-custom]
exten -> 234,1,Set(__ALERT_INFO=Bellcore-r3)
Would the fact that it had found a match for extension 234 basically stop the processing there if I simply ended my -custom context at that point? I suspect it would, which is part of why this is a bit murky to me.