Send calls on Outgoing Number to an AI application for human voice detection and send the call back to agents when it detects call is answered by the real human

Tags: #<Tag:0x00007f24c0e09160>

(FAK) #1

Hi Guys,

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.

(Tom Ray) #2

This functionality already exists in Asterisk. Answering Machine Detection (AMD). Have you looked at that?

(Dave Burgess) #3

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.

(Itzik) #6

As mentioned, AMD, or other Asterisk applications like BackgroundDetect, Talk_Detect might be very useful.

Anyway, to answer your question, I’d probably use ARI.

(FAK) #7

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( your/recording.wav) ,anything you `print(". . .",end="’) in a Set() dialplan.

(FAK) #9

ok what about If we manually dial the call and send the audio stream to a url in parallel to the call.

how is that possible ?

Ho can I send the live call stream to another url ?


I pm’d you


that would be the STDIN file in your eagi is one leg , STDOUT is the other, whatever you play on STDERR will be heard by both legs

(FAK) #12

any example of how to do it cause I am not a developer.

really missing this Development part :frowning:


I PM’d you

(FAK) #14

I have to send the live call stream to the below url:

how can I do that.

(David55) #15

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.

(FAK) #16

Is there any other way you think which will work like we give audio to that application.


If you google res_speech asterisk you will find several ‘apps’ that are based on our own @jcolp 's work

perhaps he can put you in touch with the right Sangoma resource for your own solution.

(Joshua C. Colp) #18

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].