Answer the question
In order to leave comments, you need to log in
Calling a script when you pick up the phone (asterisk)?
Good evening everyone!
The situation is this:
There is Asterisk Now (Version 6.12.65-26) - os: Linux
Task: after the operator picked up the phone, there was a call to an external script
, I tried to do something in the extensions_custom.conf file
, set it differently
, I could only configure the script is triggered by an incoming call, but not when the operator picks up the phone (I also tried
it through AGI and System and Macros (
Can you show with an example what needs to be done?
I searched everything I could in Google ( forums.asterisk.org/viewtopic.php?p =136759)
but there’s no
point at least indicate where to dig ((((
many people suggest that you can configure via AMI,
just give at least 1 working example, I’ll dig it out myself
Answer the question
In order to leave comments, you need to log in
Thanks, it worked like this:
[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
#!/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)
Optional Asterisk Management Interface (AMI)
AMI is a powerful and convenient Asterisk API for managing the system from external programs. In addition to AMI, AGI is often used - this is an interface for launching external applications that control the Asterisk channel within a specific call.
Thanks to AMI, external programs can connect to Asterisk via the TCP protocol, initiate the execution of commands, read the result of their execution, and also receive real-time notifications of ongoing events. These mechanisms can be used, for example, in the following cases:
Need to know the system status
Number of active subscribers
Execute CLI commands remotely
Improve CDR storage
... etc. etc. etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question