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 file extensions_custom.conf . Put in different ways.

I could only configure that the script is triggered when an incoming call is received, but so that when the operator picks up the phone there is no.

Tried it through AGI and System and Macros.

Can you show what to do with an example?

I searched Google for everything I could ( http://forums.asterisk.org/viewtopic.php?p=136759 ), but there’s no point. At least indicate where to dig.

Many suggest that you can configure via AMI. Just give at least 1 working example, I'll dig it out myself.

Here is what I got to:

 [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) 

The call is working - everything is OK ( there are moments with the definition of the number (as I understand it depends on the provider and the settings of the asterix ), but this is a second time)

Now the problem is that after calling the script, when the operator switches to the required manager, the script is called again and nothing else works (- I suspect that because of this line Dial (SIP / $ {EXTEN}, 60, U

I do not need another call, I need to work only on lifting the handset on the incoming call for the operator (after the operator switches to the manager, you do not need to call the script)

    1 answer 1

    The link you provided is the right direction. Look in the direction of the parameters of the commands Dial and Queue.

    https://wiki.asterk.org/wiki/display/AST/Asterisk+11+Application_Dial M - Execute the specified macro for the called channel before connecting to the calling channel. Arguments can be specified to the Macro using ^ as a delimiter. U - Execute via Gosub the routine x for the called channel before connecting to the calling channel. Arguments can be specified to the Gosub using ^ as a delimiter. M - Execute the specified macro for the called channel before connecting to the calling channel. Arguments can be specified to the Macro using ^ as a delimiter. U - Execute via Gosub the routine x for the called channel before connecting to the calling channel. Arguments can be specified to the Gosub using ^ as a delimiter.

    Now the problem is that after calling the script, when the operator switches to the required manager, the script is called again and nothing else works (- I suspect that because of this line Dial (SIP / $ {EXTEN}, 60, U

    Try to create a separate context for translations where there is no U option in the Dial and use the variable __TRANSFER_CONTEXT to set it .

    Or it is necessary to determine in the initial context / script that this call is a translation and not substitute U in the Dial.

    • I set everything up, but a new error has arisen - the script also works on the transfer of the operator to any employee ((((( - Koshak01
    • Update the first post and add the code where the changes were made. - StuxForce
    • updated - look please - Koshak01