Спасибо заработало вот так:
[from-internal-custom]
exten => _XXXX,1,Dial(SIP/${EXTEN},60,U(answer-script,${PARAM}))
same => n,Hangup
[answer-script]
exten => s,1,AGI(answer.py,${ARG1})
same => n,Return
answer.py:
#!/usr/bin/python
import os,sys
import datetime
ROOT_PATH = os.path.abspath(u'{0}'.format(os.path.dirname(os.path.abspath(__file__))))
file_name = os.path.join(ROOT_PATH, 'answer.txt')
with open(file_name, 'a') as file_to_save:
save_string= u"{0:%Y-%m-%d %H:%M:%S}: {1}\n".format(datetime.datetime.now(), sys.argv)
file_to_save.write(save_string)