1

I use core show channels concise to get from it the 8th field, which is the DID i need to display in real time on a webpage.

But i also need to get the tag from the From SIP INVITE header to get it stored in CDR database. For that, as i work with freepbx that does not allow to edit extensions.conf, i added this in /etc/asterisk/extensions_custom.conf file :

[from-pstn-custom]
exten => _X.,1,NOOP("CDR Entered [from-trunk-custom]")
exten => _X.,n,Set(fromstr=${SIP_HEADER(From)})
exten => _X.,n,Set(longtag=${CUT(fromstr,\;,2)})
exten => _X.,n,Set(tagok=${CUT(longtag,\=,2)})
exten => _X.,n,Set(CDR(tag)=${tagok})

It works well, i do have the tag i need in the CDRs. But now, since i added this from-pstn-custom context, i have a problem with core show channels concise : the 8th field (DID) is now replaced by the extension that is ringing, or by the extension that picked up the call.

It seems to be because of these inclusions, in extensions.conf :

[from-pstn]
include => from-pstn-custom     ; create this context in extensions_custom.conf to include customizations
include => ext-did 
include => ext-did-post-custom 
include => from-did-direct
include => ext-did-catchall     ; THIS MUST COME AFTER ext-did

Maybe everything that is after the inclusion of from-pstn-custom could have not been executed, that would explain that some vars are not set, whereas they should. I tried a Goto from-pstn at the end of from-pstn-custom, to be sure the other lines of from-pstn will be executed, but it causes an infinite loop. Also tried to put the 4 includes following the inclusion of from-pstn-custom, directly at the end of from-pstn-custom, doesnt work.

Would you have any idea of how to get this right ? Or maybe a whole other way to get these two vars (DID in real time, Tag in CDRs), as i can get on or the other but not both. Would be better to avoid AMI as the current project already runs with calls to the CLI.

This is under Asterisk 11.25.1 with FreePBX 13.0.190.19, Debian Linux 3.16.0-4-amd64

Thank you

Tarik Zouine
  • 146
  • 8

2 Answers2

0

Please read how dialplan works

https://wiki.asterisk.org/wiki/display/AST/Dialplan

In your case this context block anything included after it, just becuase it have pattern matching any did starting with digit(_X.). It block only first 5 priorities

Solution is

  1. in sip trunk set contex = custom_rewrite
  2. put all that staff in custom_rewrite context
  3. at end of sequence send to from-pstn.
  4. debug it using asterisk -rvvv
arheops
  • 15,544
  • 1
  • 21
  • 27
-1

You can save the DID to a custom variable with Set(__MYVAR=${EXTEN}).

viktike
  • 717
  • 4
  • 7