we have developed an application which will detect if the Call is picked by answering machine or a Human.
I want to integrate this with my Freepbx on outgoing Calls on mostly Insurance Calls and route or shadow whatever is best to my AI Application which can hold the call to itself and when it checks the Agent is started to talk it will route to my Agent.
now the tricky part is how to send the call to Application and get it back from the application to agent.
My application is in python.
Conceptually, I agree, but what the OP is looking for is the āhow toā part, and looking at any one of several system components (like CID Superfecta or AMD) would work to get you there.
Effectively, it works the same basic way any other āreach out to another systemā component would - it passes the information around through return codes and pass-by-reference data structures. You have to get the call into your application, then pass the call back to Asterisk using return codes. AMD is an excellent way to approach this, since it performs a similar set of activities.
I doubt that you can make this work with usable reliability. When the called agent takes the call from his queue, he is trained to give a greeting like āThank your for calling State Farm, this is Jesse.ā Often, itās even longer. So your system decides ~2 seconds later that a human is on the line, about the time that Jesse says āHello?ā About 3 seconds after that, Jesse hangs up, being well aware that his performance is measured by number of issues handled per hour. So, the system needs to get your agent on the line within about 4 seconds, otherwise the call is lost and has to be restarted. Unless you usually have an agent sitting idle, thatās unlikely to happen.
Now our OP is going AI which is a good thing, as such why would one not immediately have an AI agent answer the call which would say exactly the same greeting but further process the ongoing interaction with AI. (AMD is essentially a binary decider, he will need STT here to keep up with the current sophistication of todayss robocallers, if they do use it, and they do, you will need to fight fire with fire.)
The ultimate aim is to discover āreal peopleā and handle them in a timely fashion but send bots wherever you decide they belong.
Actually what we are doing is from python application we are transcribing the media stream and set up few checks on words that will ensure us that now the Agent is speaking.
so this is where we want to route the call back to Asterisk.
But the problem is If we handover the call to python application, how can we do it in the dialplan for outgoing calls and when call hit the url what will happen and how can we take the instructions back from python application.
if your media processing is synchrounous, the good old way is
if you are post-processing a short interaction which is a little simpler, I just ask them their name and then who they want to be connected to, proper names can be hard to get right but offering a limited vocabulary works well.
I āholdā the caller then SHELL(script.py your/recording.wav) ,anything you `print(". . .",end="ā) in a Set() dialplan.
That requirement is underspecified. What scheme? What method? (Probably has to be POST, but might be PUT, or CONNECT.) What Content-Type? What constraints within that content type?
Basically, though, that part of the solution is independent of getting it out of Asterisk. EAGI will given you a linear PCM stream, although Iām not sure if it is locked at 8kHz sampling. You need to find tools that will convert that to meet the interface specification of the recipient.
Thereās nothing inherently built in for such a thing. The module referenced is just an application interface. Otherwise there is external media in ARI[1].