How to execute custom code at start of macro-user-callerid?

radpeter's picture

To my knowledge, it is considered good practice place your own dialplan code in -custom contexts in _custom.conf files.

In the extensions_additional.conf the [macro-user-callerid] starts with
include => macro-user-callerid-custom

The place of this line seems to indicate that the included code is executed at the start of the macro,

However, the documentation of the include statement, e.g. on www.the-asterisk-book.com, states

=================
Order of execution when using include statements

Asterisk will always look for a match in the current context before referencing any included contexts. If a matching entry is found, that entry is used. If no matching entry is found, Asterisk will look for a match in the first included context, then the next, and so on. It is also possible to have nested includes; that is, includes within includes.
================
Since you can only use the s extension in a macro,it looks like the custom include code is always executed last, if ever.
This seems also to be confirmed by a CLI show dialplan @macro-user-callerid, and also by viewing the dialplan executed,.

How and where can I place dialplan code which is excuted at the start of the [macro-user-callerid]?


__________________


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Quote: Since you can only

maumar's picture
Quote:
Since you can only use the s extension in a macro,it looks like the custom include code is always executed last, if ever.

this is a fatal issue, i had the same issue with callback, i was unable to check callerid numebr before passing to callback using macro-callback-custom (or something similar i did not remember)

imho, until this is not fixed, custom arrangements into dialplan are not feasible

m.


__________________

Maurizio Marini - Italy


every auto-generated context

p_lindheimer's picture

every auto-generated context has an include => contextname-custom

In many cases, this is not usable, as you have learned from reading how Asterisk processes includes. This is just auto-generated everywhere as there is no harm and some places it is useful.

If you want to put your own code in an auto-generated context, you have two options:

You can write a module that spices into the beginning of the context and adds your code. Have a look at modules like blacklist which do that with inbound routes, or languages which splice into the middle of macro-user-callerid.

Your other option is to completely re-define the entire macro by copying it into the override file and then modifying it. Be very careful if you do this. First keep in mind that future updates to that macro, like new functionality or bug fixes, will be overwritten by your change. Secondly, make sure you replace every single priority that is in the original macro or include appropriate 'hangup' or alternative instructions because anything that you don't cover will have ours blended into yours and you can get some really hard to find bugs.


__________________

Philippe Lindheimer - FreePBX Project Leader
FreePBX Training Opportunities - Click Here
Get Official Paid Support - Click Here