Get endpoint name

Hello, I could use some help.

Does anybody know function or variable, that will give me sip peer name, I am doing some work with asterisk calling to external server and in extension.conf, this is how i intended to handle calls from external source:

exten => _60xx,1,NoOp(#### [from-trunk] ####)
exten => _60xx,n,Dial(SIP/[here would go variable or function for sip peer name],20)
exten => _60xx,n,Hangup()

Can someone help?

As you are initiating the call -if I undertstand well your question- from where should asterisk know the peer name you want to call ?

One more, SIP is gone, you should switch to PJSIP.

I am sorry, I think I used bad terminiology. I want to know the name of endpoint who s extension number is being called, so I can dial it, as you could see in my example.

And yes I know that i should no use SIP but my company is not sure whether they want to update yet, so they told me I should work with SIP for now

I have found function ${CHANNEL(endpoint)} but this is for PJSIP, is there some alternative for SIP?

There isn’t a variable or a mapping. You write that yourself. The ${CHANNEL(endpoint)} doesn’t do that mapping. It returns the name of the endpoint for the channel it is called on. For example if “alice” calls 6001 and you use ${CHANNEL(endpoint)} then it will be “alice”. Is that REALLY what you want? For alice to call herself?

Yeah, you are right, anyway my work took unexpected turn so i dont need to look for this anymore, thanks for your help. Thank you all, this community is amazing