Start a python agi script in Asyncagi

I am using AGI script and another function in Dial plan,
I want to run AGI asynchronously, how can I do that?

exten => _70.,1,NoOp(Calling ${EXTEN})
 same => n,AGI(/home/server/AGI.py)
 same => n,Dial(PJSIP/${EXTEN}@internal)
 same => n,Hangup()

This is my dial plan, how can I run the AGI script in async?
Is there any other option I can use for this?

Your Help will be much appreciated.
Thank You

On Sunday 05 January 2025 at 14:36:25, PraveenChordia via Asterisk Community
wrote:

I am using AGI script and another function in Dial plan,
I want to run AGI asynchronously, how can I do that?

https://docs.asterisk.org/Asterisk_20_Documentation/API_Documentation/Dialplan_Applications/AGI/

However, I recommend that you tell us what you are actually trying to achieve
(without presuming that AGI is the best way to do it), so that we can perhaps
suggest better alternatives.

AGI generally means interaction (input / output) between the dialplan and a
script; asynchronous means that is no longer possible, so what do you really
want to happen?

Antony.

–
“The future is already here. It’s just not evenly distributed yet.”

  • William Gibson

                                                Please reply to the list;
                                                      please *don't* CC me.
    

You can spawn off another process, but you can’t have an AGI running on a channel asynchronously at the same time as something else. That’s essentially asking for two things to control a channel at once.

I want to capture the DTMF on the call without redirecting it to an AGI script to handle the DTMF.
May be we can create a callback whenever a digit is pressed, I am not sure as I am new to asterisk and still exploring the possibilities.

Thank you.

If you want to asynchronously/passively just see when DTMF digits occur while the channel is doing other things, AGI would not be that. AMI has an event[1] for it.

[1] DTMFEnd - Asterisk Documentation

“AsyncAGI” is just Asterisk’s term for AGI-within-AMI. Your external script opens an AMI connection to listen for events as usual, and when a channel executes the application

AGI(agi:async)

then it enters the AsyncAGI state, and your program can use the AGI command to execute AGI commands via AMI.

1 Like