; try this macro [macro-SipPhone] exten => s,1,GotoIf($[foo${CALLERIDNUM} = foo]?5:2) exten => s,2,GotoIf($[${CALLERIDNUM} = ${ARG2}]?3:5) ; do this if the extension matches the callerid exten => s,3,VoicemailMain(${ARG2}) exten => s,4,Hangup() ;do this otherwize exten => s,5,Dial(${ARG1},20,m) exten => s,6,Voicemail(u${ARG2}) exten => s,7,Hangup() exten => s,106,Voicemail(b${ARG2}) exten => s,107,Hangup() ;and call to it from extensions.conf like this... exten => 102,1,Macro(SipPhone,${EXTEN},${VoiceMailNumber}) ;where VoiceMailNumber is the number of the vm box for that extension