How to embed custom fields for recording file name into sip header


(CJ) #1

Hi guys i am currently looking for a way to embed a file name for recordings to be tracked via a external application, it requires some custom fields into the sip header to track the calls live as well and save the recordings and meta data. Anyone that knows if this is possible or not using free-PBX ?


(Dave Burgess) #2

Of course it is, but you need to be more specific.

Call recordings are identified by type (internal, external, etc), extension, destination number, date, time, and a unique ID that differentiates calls within a single server. If you have any two of those, you should be able to get pretty close.

The easiest way I’ve ever found was to post-process the CDR records for called number and time, but there are LOTS of other ways to handle that.


(CJ) #3

Hi Dave thanks for your reply what i am trying to do is to add X-Info2:[FileName] which will be the location of the recordings into the sip header for the external app to be able to retrieve this data.Any idea as to where to input this data or if it is possable as my understanding is that freePBX overwrites some files.


(David55) #4

That’s a custom header, not a custom field, which is possible, but only at the start of the call.

There are many forum topics on this, but this is one:


(CJ) #5

Hi, Thanks for this info.
Just to add some clarity on what we are trying to achieve. The users register to the the FreePBX using WebRTC through a CMS application. The developers of the CMS are wanting us to have the PBX send the additional header to the extension. We have made some progress however the header is being send to the provider and not to the extension. Below is our current code in the extension_custom.conf file.

[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(Entering user defined context macro-dialout-trunk-predial-hook in extensions_custom.conf)
exten => s,n,SIPAddHeader(X-Info2:${CALLFILENAME}.${MON_FMT})
exten => s,n,MacroExit


(Itzik) #6

The correct way of doing it:


(CJ) #7

Hi PitzKey,
Thanks for the reply, I’m not sure if I am missing something but I believe this is essentially what we are already doing and it works in the context of adding the header to the trunk, i.e. the header gets sent to the provider.
We are needing the header sent to the extension that placed the call. NOTE, the trunk and extensions register via CHANSIP.


(David55) #8

SipAddHeader only adds to the initial INVITE, according to the wiki documentation. I’m not sure if the PJSIP equivalent has the same restriction, but I suspect it does, in which case Asterisk does not support what you want to do.

To the extent that PJSIP_HEADER might work after the initial INVITE, it would need to be executed directly in the main dialplan.


(Joshua C. Colp) #9

PJSIP works the same way. Noone has worked on or contributed a change for doing header manipulation at other times.


(Lorne Gaetz) #10

To send headers to the extension, you need to use the correct dialplan hook. See this thread: Hooking for fun and income

You don’t want to use SipAddHeader, use the native FreePBX subroutines.


(CJ) #11

Hi Lorne,
Thanks for your reply. It was actually your linked thread I was using to try work out what to do but cant seem to find more details on sending modified sip headers to extensions. Please excuse all the silly questions, I am very new at the deeper inner workings of FreeBPX. I have found a post listing the subroutines but have no idea now where to start.


(David55) #12

Your requirement appears to need SIP responses to be customised, and I believe that Joshua has confirmed that that simply is not supported by Asterisk.


(Lorne Gaetz) #13

It’s in the hooking link above in the section “How do I do X on every local call?” That is the hook you want for adding a sip header. Roughly:

[macro-dialout-one-predial-hook]
exten => s,1,Noop(Entering user defined context macro-dialout-one-predial-hook in extensions_custom.conf)
exten => s,n,GoSub(func-set-sipheader,s,1(header_name,header_string))
exten => s,n,MacroExit

There are other internal hook contexts, which are used depending on how the local extension is dialed.


(David55) #14

The OP doesn’t want to send this in the request, on the outgoing channel; he wants to send it in a SIP response on the incoming channel. Your predial hook sets the header on the request and on the wrong channel. Asterisk doesn’t support the sending of customised headers on responses, so doesn’t support the OP’s requirement.


(CJ) #15

Hi, that’s correct, we are wanting it sent to the extension that is making the outgoing call.


(CJ) #16

Hi, Any suggestions? We know it to be possible as a previous supplier to our client was doing this however they are obviously unwilling to help.


(Joshua C. Colp) #17

Without code changes to Asterisk, you can’t add custom SIP headers to responses.


(system) closed #18

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