How to identified Asterisk Call Direction?

Hi, guys thanks for time and help…

How i can identified Asterisk Call Type using some variables?
i need to create some especial condition in my dial plan using this information
Incoming from PSTN
Outgoing from EXTENSION

if incoming call "do something"
if outgoing call “do this”


Use Asterisk Standard Channel Variables and ExecIf() or GotoIf()

You have to provide the rules for what constitutes EXTENSION or PSTN (typically by enumerating them in the channel technology configuration file (sip.conf, chan_dahdi.conf, etc.). You should then set a context for each. The use of contexts in this way should be considered very basic stuff, so there is no point in detailing it here.