Get data from SIP record

Hi there,

I Have two SIP accounts set up in sip.conf:

[1000]
username=1000
secret=xxxxxxxxxx
accountcode=user1
callerid=“1000”
mailbox=0
context=default
type=friend
host=dynamic
canreinvite=no
callcounter=yes

[1001]
username=1001
secret=xxxxxxxx
accountcode=user2
callerid=“1001”
mailbox=0
context=default
type=friend
host=dynamic
canreinvite=no
callcounter=yes

When I make a call from device 1000 to 1001, I can get the user name of the calling extension I need in the dialplan using ${CDR(ACCOUNTCODE)}. Is there a way I can get the user name of the called extension?

Thanks for any suggestions.

ASTERISK 13
CENTOS 7

I find this usually ‘just works’ if you enable p-asserted-identity on your PBX and phones without any dialplan modification.

I don’t think he is after having the information communicated between the end points. I think he wants some non-protocol data from the device configuration for the (last used) device on a the channel that no longer exists when he requests it!

I think he needs to try and capture this data at the point of answer. I haven’t tried this, but it is possible that variables will get set on the B side channel, based on set variable requests in the peer description, at least for some channel types. Obviously, this will give the first used device, not the last used one, if the B side redirected the call.

Thanks David, It is an AMI request calling from one internal device to another. As I said I can get the CDR Account Code value for the extension I am calling from but not for the recipient. I am going to try the AMI Setvar command and set the username of the recipient to a variable on the channel and see if I can retrieve it from the dialplan then.

Thanks