How to get asterisk pri number in a variable

I want asterisk to use the pri number from which outbound call comes to a customer phone.How to get PRI number?

Extension is ${EXTEN} (in a context set for PRI)
and Callerid number in ${CALLERID(num)}

If you mean by PRI number as PRI port then you can get it from the Channel itself, middle part of the channel is port number, and if you want to know the number which initiated the call then you can use the approach mentioned by @satich4asterisk.

I checked with ${EXTEN} which is giving phone number of customer like 99XXXXXXXXXX and ${CALLERID(num)} is giving agentID to which call lands like ET00100. None of variable giving number from which call is coming like 0124XXXXXX.

I think you are talking about outbound calls from your system.
PRI provider would have given you a list of Numbers which you can set as Callerid on your outgoing calls. There won’t be any inbuilt mapping for PRI channel and Numbers and you need to specify (using CALLERID function) which number to use on outbound call.

You should have provided CLI call logs to help you in a better way

I am talking about outbound calls from the system.Can we get the the agent number before setting the callerid(num).Is there any way?

Use a local channel as the agent.

I think You are not understanding my question, I said I want to get the actual PRI number of the caller which displays on callee phone when call lands on phone.Callerid(num) is giving me albhabetical agent id rather than number of agent.

You can’t get it as you need to set it before dialing out through PRI line. If you don’t set it, your provider may send default callerid on those calls.

1 Like

Yes, Can we get the default callerid print on asterisk cli?

No unless you set it somewhere.