# Get contact data for current user

**URL:** <https://community.asterisk.org/t/get-contact-data-for-current-user/91424>\
**Category:** Asterisk SIP\
**Created:** [January 28, 2022, 12:21am UTC](https://community.asterisk.org/t/get-contact-data-for-current-user/91424 "2022-01-28T00:21:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![adib16](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@adib16](https://community.asterisk.org/u/adib16)\
**Post date:** [January 28, 2022, 12:21am UTC](https://community.asterisk.org/t/get-contact-data-for-current-user/91424/1 "2022-01-28T00:21:26Z")

</div>

I want to get contact value for current user in dial plan. I want get this for every user that income to dialplan  
`User2/sip:fr1crvcm@23.19.74.164:47664;transport=ws`

---

<div class="post-metadata">

**Author:** ![mlast77](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@mlast77](https://community.asterisk.org/u/mlast77)\
**Post date:** [January 28, 2022, 5:31am UTC](https://community.asterisk.org/t/get-contact-data-for-current-user/91424/2 "2022-01-28T05:31:17Z")

</div>

One idea:  
You can get the info from the SIP Contact header by using the PJSIP\_HEADER function. Something like this in your dialplan, for example:

```auto
...
same => n,Set(XYZ=${PJSIP_HEADER(read,Contact)})

```

Then the ${XYZ} variable would become sip:fr1crvcm@23.19.74.164:47664 as passed in the Contact header. This does not get you the “User2” portion but I imagine you could gather that some other way if needed.

---

<div class="post-metadata">

**Author:** ![adib16](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@adib16](https://community.asterisk.org/u/adib16)\
**Post date:** [January 28, 2022, 9:20am UTC](https://community.asterisk.org/t/get-contact-data-for-current-user/91424/3 "2022-01-28T09:20:03Z")

</div>

when I call to dial plan this is and that is work  
`Verbose("PJSIP/User2-0000001c", "<sip:p3ngb3lu@23.19.74.164:47664;transport=ws;ob>") in new stack`  
but in my case I want get contact when dial plan recieve message and that not work  
`res_pjsip_header_funcs.c:622 func_read_header: This function requires a PJSIP channel.`

otherwise when `${CHANNEL(name)}=Message/ast_msg_queue` above error displayed and not work.

---

<div class="post-metadata">

**Author:** ![mlast77](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@mlast77](https://community.asterisk.org/u/mlast77)\
**Post date:** [January 28, 2022, 4:03pm UTC](https://community.asterisk.org/t/get-contact-data-for-current-user/91424/4 "2022-01-28T16:03:20Z")

</div>

Ah, OK. Yes, there is no Contact header in the MESSAGE method, and besides, PJSIP\_HEADER does does not work since it is not a PJSIP channel…

You can get most of this info from the existing ${MESSAGE(from)} variable, however, maybe not the port and transport info that you would get from an INVITE Contact header.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/asterisk/original/2X/4/475d0c889911cfb84ac4881ad6df8b523e3f9105.png) [@system](https://community.asterisk.org/u/system)\
**Post date:** [February 27, 2022, 4:04pm UTC](https://community.asterisk.org/t/get-contact-data-for-current-user/91424/5 "2022-02-27T16:04:04Z")

</div>

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