[from-internal-custom] screws outgoing CID

When I add [from-internal-custom] to extensions_custom.conf, only the main number of the trunk is shown to the callee (instead of the extension’s number). This happens even with the simplest Actions:

[from-internal-custom]
exten => _.,1,Noop(Hello World)

Why does this happen and how can I avoid this?

It’s not appropriate to use a broad pattern match like _. in this context. It’s intended to create your own explicit extension numbers which you can dial. If your intent is to add your own dialplan to all dialed numbers, you must use a dialplan hook: Hooking for fun and income

I was trying to get some insights on what is happening during the creation of a call, especially on redirected calls.And I was wondering why some Noops would change anything for the call. But I’ll try the hooks instead.

In your post, you mention a thread about adding custom SIP Headers. Have you found time to create that?

Not in detail, but the basics are in this recent post: SIP Header not added

It has to do with the way Asterisk processes included contexts. Your dialplan example above creates a new priority 1 line for all dialed calls in the from-internal context. So now, your Noop line runs instead of the line generated by FreePBX. You can see at the Asterisk console what dialplan is generated for an outbound call by running:

*CLI> dialplan show 9025554444@from-internal
[ Included context 'from-internal-custom' created by 'pbx_config' ]
  '_.' =>           1. Noop(Hello World)                          [extensions_custom.conf:16]

[ Included context 'outrt-3' created by 'pbx_config' ]
  '_NXXNXXXXXX' =>  1. Macro(user-callerid,LIMIT,EXTERNAL,)       [extensions_additional.conf:3692]
                    2. Gosub(sub-record-check,s,1(out,${EXTEN},dontcare)) [extensions_additional.conf:3693]
                    3. Noop([TRACE](1) Calling Out Route: ${SET(OUTBOUND_ROUTE_NAME=SIPStation-Out)}) [extensions_additional.conf:3694]
                    4. ExecIf($[ "${CALLEE_ACCOUNCODE}" != "" ] ?Set(CDR(accountcode)=${CALLEE_ACCOUNCODE})) [extensions_additional.conf:3695]
                    5. Set(MOHCLASS=${IF($["${MOHCLASS}"=""]?default:${MOHCLASS})}) [extensions_additional.conf:3696]
                    6. Set(_NODEST=)                              [extensions_additional.conf:3697]
                    7. Macro(dialout-trunk,1,${EXTEN},,off)       [extensions_additional.conf:3698]
                    8. Macro(dialout-trunk,2,${EXTEN},,off)       [extensions_additional.conf:3699]
                    9. Noop([TRACE](3) All trunks failed calling ${EXTEN}, playing default congestion) [extensions_additional.conf:3700]
                    10. Macro(outisbusy,)                         [extensions_additional.conf:3701]

Your custom dialplan, priority 1 supersedes the priority 1 from FreePBX, which prevents the very important macro-user-callerid from running.

@lgaetz, I thought the more specific pattern _NXXNXXXXXX should be executed before _. Can you explain this more?

If I recall correctly, the specificity is scoped to within each context itself. Everything isn’t combined but instead the include list is just gone through until a match is found.

1 Like

It would be if they were in the same context, but FreePBX specifically includes from-internal-custom before from-internal-additional where the generated dialplan starts. There is a rabbit hole, but eventually you will find:

*CLI> dialplan show from-internal-xfer
[ Context 'from-internal-xfer' created by 'pbx_config' ]
  'h' =>            1. Macro(hangupcall)                          [extensions.conf:246]
  Include =>        'from-internal-custom'                        [pbx_config]
  Include =>        'from-internal-additional'                    [pbx_config]
1 Like

I see, Include is not like a subroutine call. Is there some document explaining the differences between Include, Macro, Exec and Gosub?

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