Passing Accountcode variable from one system to another

I am trying to pass the accountcode variable from one system to another. I can see the accountcode variable populated in the receiving system SIP invite message
chan_sip.c: Header 16 [ 25]: accountcode: 123456789
but then in the next event the accountcode is gone. Anyone know how to do this? Thanks.

Event: Newchannel
Privilege: call,all
Channel: SIP/
ChannelState: 0
ChannelStateDesc: Down
CallerIDNum: +15141234567
CallerIDName: +15141234567
Language: en

As Asterisk is a B2BUA although you might see the accountcode on LegA, there is no innate method to pass channel variables to LegB unless you do it yourself.

Is there a variable for the accountcode in leg A that I can use to pass the accountcode to leg B if I create a custom inbound dialplan ?

You could do that with your AMI client, but it is not a SIP thing.

It can be done but it would require some modifications.

exten = s,1,Gosub(func-set-sipheaders,s,1(X-Accountcode,${CHANNEL(accountcode)})

Now doing that would create a SIP header called X-Accountcode but you could modify func-apply-sipheaders to do this:

exten = s,n,ExecIf($["${sipkey}" = "X-Accountcode" & "${TECH}" = "PJSIP"]?Set(CHANNEL(accountcode)=${sipheader}):))

Or you can write something like this:

exten = s,1,Set(HASH(__VARHASH,X-Accountcode)=${CHANNEL(accountcode)})
exten = s,n,Dial(${DIALSTRING},,b(pre-dial^s^1()))

exten = s,n,While($["${SET(varkey=${SHIFT(VARHASHKEYS)})}" != ""])
exten = s,n,Set(varval=${HASH(VARHASH,${varkey})})
exten = s,n,ExecIf($["${varkey}" = "X-Accountcode"]?Set(CHANNEL(accountcode)=${varval}):))
exten = s,n,EndWhile
exten = s,n,Return()

With chan_pjsip you can use the b option to call a gosub that will apply variables/headers, etc on the new channel before the call is started. So you can do what you need this way.

Applying variables onto another channel isn’t a SIP thing, it’s a channel thing. Passing the accountcode (or any variable) from channel A to channel B (or other child channels) can be done regardless of tech.

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