Running an agi script using the H template does not work in the context

Hello everyone, I have a problem, and I don’t even know where to dig it up, please help :slight_smile:

I have a task:

Send data to the AGI script when the conversation started and when it ended. This must be done for both incoming and outgoing calls.

By trial and error, I managed to make the script work when there was an incoming call. But I absolutely do not understand the logic of how contexts work and the order in which scripts are executed in Asterix.

So the question is what needs to be corrected in my configuration for the connection to work, or please tell me what is my mistake

I have a bundle of Twilio - My asterisk - phones connected to my asterisk.

My file extensions_custom.conf

[ext-did]
exten => s,1,Set(EVENT_NAME=incoming_call)
same => n,AGI(crm.php,${EVENT_NAME})

exten => h,1,Set(EVENT_NAME=incoming_end_call)
same => n,AGI(crm.php,${EVENT_NAME})

This dialplan is incomplete. The question would make more sense where it was originally posted: Running an agi script using the H template does not work in the context - Configuration - FreePBX Community Forums I haven’t responded there because I don’t know how ext-did fits into FreePBX and how it is intended to be used.

Making guesses, I would suggest that a hangup handler would have a more predicable behaviour.

Figured it out, maybe it will be useful to someone.

It’s:
exten => s,n,Set(CHANNEL(hangup_handler_push)=handl1,s,1) through the line

Full config:

[ext-did]
exten => s,1,Set(EVENT_NAME=incoming_call)
exten => s,n,Set(CHANNEL(hangup_handler_push)=handl1,s,1)
same => n,AGI(crm.php,${EVENT_NAME})

[handl1]
exten => s,1,Set(EVENT_NAME=incoming_end_call)
exten => s,n,AGI(crm.php,${EVENT_NAME})
exten => s,n,Return();

And I’ll go set up outgoing now, does anyone have any ideas on what context to start with?

For outgoing, I selected only this context [macro-dialout-trunk-predial-hook], I don’t know how correct it all is, but it works as expected)

End finally config:

[ext-did]
exten => s,1,Set(EVENT_NAME=incoming_call)
exten => s,n,Set(CHANNEL(hangup_handler_push)=handl1,s,1)
same => n,AGI(crm.php,${EVENT_NAME})

[handl1]
exten => s,1,Set(EVENT_NAME=incoming_end_call)
exten => s,n,AGI(crm.php,${EVENT_NAME})
exten => s,n,Return()

[macro-dialout-trunk-predial-hook]
exten => s,1,Set(EVENT_NAME=outcoming_call)
exten => s,n,Set(CHANNEL(hangup_handler_push)=handlout1,s,1)
same => n,AGI(crm.php,${EVENT_NAME})

[handlout1]
exten => s,1,Set(EVENT_NAME=outcoming_end_call)
exten => s,n,AGI(crm.php,${EVENT_NAME})
exten => s,n,Return()

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