DID Inbound Routing - Is there a way to route to "last agent"?

Say I have 10 agents here who all make outbound calls using our 800 number as the caller ID.

If a customer misses our call and so makes a call back to our 800 number, is there any way that the FreePBX system can check our call logs to see which of our agents most recently called the customer, and route the call to that agent’s extension, bypassing the default IVR?

Not sure if there is anything as default but with some clever scripting I am sure that you could setup temporary inbound routes to direct the call.
With some failover back to the IVR or to voicemail if the agent is unavailable.
once the call is received then remove the temp inbound route.

It would need some thought but I would have hope that anything can be done with the right effort.

Hv.

If you are comfortable with a little custom context work, and have app-mysql compiled into your asterisk, then with a little googling for “asterisk mysql dialplan” will return things like:-

The SQL statement :-

SELECT SUBSTR(channel,INSTR(channel,'/')+1,(INSTR(channel,'-')-INSTR(channel,'/')-1)) FROM cdr WHERE dst='NXXNXXXXXX' ORDER BY calldate DESC LIMIT 1

should return the extension making the last call to NXXNXXXXXX .

A quick sanity check that produces more output, from bash try:-

mysql -ppassword -uuser -D asteriskcdrdb -Bs -e “SELECT calldate,dst,channel,SUBSTR(channel,INSTR(channel,‘/’)+1,(INSTR(channel,‘-’)-INSTR(channel,‘/’)-1)) FROM cdr WHERE dst=‘NXXNXXXXXX’ ORDER BY calldate DESC”

2 Likes

Thank you, that’s very helpful. I’m using the newest FreePBX Distro. With regards to “app-mysql”, I take it I’m good to go if I run Asterisk CLI command “module show” and get this output?:


Module Description Use Count Status Support Level
app_mysql.so Simple Mysql Interface 0 Running deprecated

I’ll have our coder take a crack at it.

Very nice,
I am more amazed day by day at the functionality of something I have used for years.

Hv.