Execute agi file after the end of the call

How to execute agi file after the end of the call ?

Context below works, and sends SMS after hangup.
Problem is a queses when skip to next agent, hangler send again and again sms.
Looking to execute agi file after the end of the call (to send only 1 sms after pickup call ends)

Is this a correct code line (?): exten => s,n,AGI(/home/folder/send_sms.php)

[macro-dialout-one-predial-hook]
exten => s,1,Noop(Entering extensions_custom.conf to add sms calls hangup handler)
exten => s,n,Set(CHANNEL(hangup_handler_push)=sms-after-call,s,1)
exten => s,n,MacroExit()


[sms-after-call]
exten => s,1,NoOp(Sending SMS Thank you to ${CALLERID(number)})
exten => s,n,DongleSendSMS(dongle0,${CALLERID(number)},Thanks for calling,,false)
exten => s,n,Return

I think you’ll need DeadAGI for that. Asterisk 11 Application_DeadAGI - Asterisk Project - Asterisk Project Wiki

I thought DeadAGI was dead and you just used normal AGI with SIGHUP blocked.

(It’s been dying since it was deprecated in Asterisk 13, although it still hasn’t completely gone in Asterisk 20.)

@easysip Please don’t open two different threads for pretty much the same exact issue. The dialout macro is for when the system dials out to an endpoint/device. Such as when a queue dials out to the agent, that is the channel you are setting the hangup handler on and that’s why SMS get sent when the agent channel hangs up.

As per Lorne, in the other thread, you need to route incoming calls to a custom destination and set the hangup handler there on the incoming channel so that the SMS is sent once that channel hangs up and not all the agents it gets sent to.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.