Dynamic Routes - Extension Check

Cleaner way is to use the Asterisk variable in dynroutes with this expression:

${DIALPLAN_EXISTS(ext-local,${dnid-var},1)}

The ext-local context exists for local extensions and their associated mailboxes. If the incoming DNID is only numeric, then it will only match on local extension numbers. No SQL necessary.

If you use virtual or custom extensions then you’ll want to do dialplan show ext-local to see if there are extensions in that context that you don’t want to match.

1 Like