How to use include statement the right way?

Hi guys, I’m new to asterisk, and I have an issue about using include statement.

I have a context named “app-calltrace-perform” from FreePBX, used when people press *69 to trace their call.

[app-calltrace-perform]
include => app-calltrace-perform-custom
exten => s,1,Answer
...
exten => t,n,Macro(hangupcall,)

The “app-calltrace-perform” written in extensions_additional.conf
which will be overwritten when users submit something about dialplan on the Web gui. So I have to write my own context
"app-calltrace-perform-custom" on another file called extensions_custom.conf

[app-calltrace-perform-custom]
exten => s,1,Answer()
same => n,VERBOSE("Something here")
same => n,Playback(hello-world)
same => n,Hangup()

Note that extensions_additional.conf and extensions_custom.conf was already included from extensions.conf as the convention of FreePBX

Then I do dialplan reload and try again, but dialplan do not play my context at all (no verbose, no play hello-world).

I’ve found something useful in https ://wiki.asterisk.org/wiki/display/AST/Include+Statements+Basics

Asterisk will always try to find a matching extension in the
current context first, and only follow the include statement to a new
context if there isn’t anything that matches in the current context.

So now I dont know how to use my custom context for stuffs like this.
Sorry if this a dumb question, but if you have any idea, pleas guide me
through.

Thanks in advance

Loi Dang

I’d like to know the answer to this also. I’m having a similar issue in that I want to make some tweaks to the [app-blacklist-check] context in extensions_additional.conf. The first line of that context is:

include => app-blacklist-check-custom

But if I create an [app-blacklist-check-custom] context in extensions_custom.conf, and copy all the lines from the original [app-blacklist-check] context that are below the include line to the custom context, and then make my changes, it still uses the original [app-blacklist-check] context and not the custom one.

BUT, if I copy the copy the original [app-blacklist-check] context to extensions_override_freepbx.conf and make my changes there, then it works great. So why doesn’t it work when I try to use the include? Either I don’t understand how an include works, or there is no good reason for that include to be there because Asterisk will never recognize it.

To the OP, you could do as I did, and copy the entire [app-calltrace-perform] context (minus the include line, which seems to be useless) to extensions_override_freepbx.conf and then make your modifications there, but the only issue with that is that if the original [app-calltrace-perform] context is changed by a FreePBX update, you’d have to manually make those changes in extensions_override_freepbx.conf. I don’t think that is the “right” way to do things; I think that using the include(d) custom context is SUPPOSED to be the right way, but like you I just have never been able to get it to work.