Invoke ARI inside AGI script

Hi,

I am exploring AI driven IVR software solutions and I have come across one software which uses ARI (stasis) for it.
However, I don’t use Asterisk flat files (apart from calling AGI) and rely on AGI scripts only (wirtten in PHP).

My question is, is there a way to invoke ARI from within my AGI scripts without bypassing any authentication and other necessary checks? Or do I need to write a custom dialplan in the flat file to make use of ARI?

Any degree of guidance will be appreciated :slight_smile:

Hisham

From the dialplan, and AGI, you invoke an ARI application using the Stasis dialplan application. To actually have the ARI application connect to Asterisk, you have to configure a user account in ari.conf

Hi @jcolp

so if my dialplan looks like this, for eg:

[default]
exten =>_XXX.,1,AGI(agi.php)
exten => h,1,AGI(agi.php,CDR)

How can I invoke an ARI like the one below?
Please note that this is a different dialplan as compared to the one above.

**extensions.conf**
[default]
exten => _XXX.,1,NoOp()
same => n, Answer()
same => n, Set(campaign_id=12345)
same => n, Stasis(myApp)
same => n, Hangup ()

**ari.conf**
[myApp]
type = user     
read_only = no     
password = mypassword

You would use the EXEC AGI action[1].

[1] EXEC - Asterisk Documentation

can you please elaborate on how this can be done using the existing dialplan that makes use of the agi.php script only?

No, because this requires modifying your AGI to use the EXEC AGI action to invoke Stasis. I can’t tell you what to do to your AGI or how to modify it, because I didn’t write it.

In a nuthsell, my AGI cript checks for the accountcode, username, ID, authentication, blacklisting before finally dialing the channel.

If I were to include the exec AGI to invoke Stasis, should that be done just before dialing or somewhere earlier in the code?

Also, the primary goal to use AI-driver IVR software solution is to cater to the basic and informatIon-only queries in order to improve live agents’ utilization, efficiency and deliverability.

I can’t answer that because it depends on what exactly it does, how it is used. You can’t do two things at once though - once Stasis is executed the channel is in ARI, until the ARI application sends it back.

is there a way to exit the channel from the Stasis back to the AGI?

Like we can exit from a macro using MacroExit() and continue executing rest of the AGI…

ARI provides a continue route[1] to return the channel to the dialplan and should go back to AGI.

[1] Channels - Asterisk Documentation

Thanks, I think this will work.