Assuming the 456 is the ATA number and the outside number is always 10 digits. exten => _456.,1,Dial(SIP/${EXTEN:0:3}/${EXTEN:-10},tT) but then it might as well be exten => _456.,1,Dial(SIP/456/${EXTEN:-10},tT) > ; to dial outside thru GSM gateway > exten => _456.,1,Dial(SIP/${EXTEN},30,tTD(${EXTEN:3})) > exten => _456.,n,Hangup > M