Running a shell script after the agent answers the call - Solved

Hello guys! I need to run a shell script just after the agent answers the call, it is possible via dialplan?

Have a look at https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Function_SHELL
If you want to execute this after a remote party picks up the phone check out the “G” option of the Dial application https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_Dial.
With the “U” option you can execute a function prior to answering.

Pay123, Tanks!

I Managed using the G and U options, however I need to pass on to the scipt some variables. However when I run the script vaiablles are not inherited.

See the script:

[pickup1]
exten => s,1,Set(chamado=${SHELL(sh /home/chamado.sh ${sessionid} ${Protocolo} ${VARIAVEL2} “${TELEFONE}” ${EMAIL} “${NOME}” | sed -e ‘s/^.“number”:"([^"])".*$/\1/’ )})

I had success using __$ {variable}.

Hi if using queues then there is an option macro on answer

see a post I wrote when asking the Freepbx team to include this feature… The refused!!

Ian

Sorry for the late reply, but I use a bash shell script as follows
same = n,Set(F=${SHELL(/path/script “${VAR1}” “${VAR2}” “${VAR3}”)})

Sorry for Hijacking this thread, but i have similar problem.

I want to run Eagi() script after the call is answered, inorder to stream the conversation.
My dialplan is as ;

exten => _+91NXXXXXXXXX,1,Set(CALLERID(all)=“Trunk Test” <+919800171547>)
same => n,Dial(SIP/twilio0/${EXTEN}, , g)
same => n,EAGI(pahh.py)

but the Eagi is execute as user hangup the call.

kindly help me.

I believe you have been told that this is not possible already.

The mistake newcomers some times make is to assume that DIal doesn’t supervise the call. Dial runs for the whole duration of the call until one party hangs up, or the the set up fails.

It’s been a while since I have been active in developing an Asterisk application, but I see you use the “g” option instead of “G” (captital letter) that I recommended, that might be the problem.
Please check the link that I posted earlier.

What I come to know about ‘g’ or ‘G’ is that it executes the dialplan when the call is hangup by any one side. (It does not continue just after the Dial is executed).
I tried that, but it is running the Eagi script after the call get hangup.
In my use case I have to dial to a pstn number and stream the conversation.
If it is not possible by this, can you please suggest some other way to do the same.
Thanks.

One way to do that will be to generate auto call via AMI or call file and send it to your desired dialplan.