Adding to an existing dialplan in extensions_custom.conf

A question for the gurus:

I have an existing outbound route in FreePBX. When I dial 811, it gets routed to a standard 10-digit phone number. FreePBX has built a plan for that in extensions_additional.conf.

exten => 811,1,…
exten => 811,n,…
exten => 811,n,…

I would like to add an extra command that gets executed when I dial 811. If I put the command in extensions_custom.conf under [from-internal-custom], and have asterisk reload the dialplan, it always seems to replace one of the existing commands in extensions_additional.conf.

So, for example, if the command that I add to extensions_custom.conf is:

exten => 811,1,System(…)

Then the number 1 entry in in extensions_additional.conf will be replaced with the new entry when I dial 811.

If I change my new entry in extensions_custom.conf so that it uses an “n” instead of 1, I get the same result, except the 7th entry in extensions_additional.conf is omitted (in this case Set(_NODEST=).

Can anyone tell me what I need to do to simply add an additional command in extensions_custom.conf without causing Asterisk to omit anything that’s in the existing dialplan in extension_additional.conf?

Can you explain what you did?

Probably intercepting the call in the predial hook. But that’s just an assumption.

Can you tell us what you are trying to accomplish?

If your goal is to define the extension 811 twice in two different locations then I feel like you’re doing something wrong. Choose what you want to do when you dial 811, and define it once.

To answer the question as asked, this is the simplest way:

[from-internal-custom]
exten => 811,1,…
exten => 811,n,…
exten => 811,n,…

Intermediate level:

[from-internal-adhominem]
; define custom destination with dial string 
;      from-internal-adhominem,s,1
; and Misc Application of 811 pointing to custom dest
exten => s,1,…
exten => s,n,…
exten => s,n,…

The intermediate level, while slightly more complex, is preferred as the GUI will prevent you from creating an extension of 811 if it’s already in use for something else.

1 Like

I wouldn’t describe this as my goal. Rather, I’m merely asking a question.

Is it possible to have FreePBX define a dialplan for “811” in extensions_additional.conf, and to add (without replacing) an additional line to that dialplan in extensions_custom.conf?

Or is that an Asterisk “no no?”

Easier to do in

extensions_ override_freepbx.conf

it is #included before

extensions_additional.conf

In extensions.conf, but read the warnings and understand the intended use just before the #Include statement.

dialplan show 811@

will reveal all the context in which 811 is matched

dialplan show 811@from-internal

Probably close to what you are looking for

Thanks for responding, Dicko!

I’m still wondering though, can you mix parts of a dialplan in two different places, or will they always end up overwriting one another?

Asterisk starts with the base config , in this case

/etc/asterisk/extensions.conf

and includes in place any “#include” 'd file accepting the last , the end result is a sum of all “last setting wins” , so if an extension is defined but later redifined, the last one wiins

As @dicko said, you can modify FreePBX generated contexts by editing the custom/override file(s) but it’s easier said than done. In cases where it’s possible I still don’t recommend it, as your changes may turn out to have unintended consequences when the generated contexts change with module updates, or just normal config changes. If you need to inject your own dialplan in normal call flow, the supported method is to use a hook: Hooking for fun and income

3 Likes

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