This code might not be that useful for everyone, it has a limited need, but it was more of the code around the function that I thought might be more useful for dailplan writers.
Create an announcement, but leave all the values default (no sound file, no changes to any of the parameters) and point the destination to your IVR.
Create an announcement, but leave all the values default (no sound file, no changes to any of the parameters) and point the destination to your IVR.
We are using the announcement system to perform all the pre-work. Callers that don’t match up to any of the criteria will instantly be sent to the IVR.
Callers that DO meet criteria will be sent to their last destination.
Callers that DO meet criteria will be sent to their last destination.
So Create an announcement, save your changes then find it in _additional.conf and copy. paste the section into _override_freepbx.conf
My demo used announcement-5.
Copy and paste the section I’ve marked with custom code into announcement.
[app-announcement-5]
include => app-announcement-5-custom
exten => s,1,GotoIf($["${CHANNEL(state)}" = "Up"]?begin)
exten => s,n,Answer
exten => s,n,Wait(1)
exten => s,n(begin),Noop(Playing announcement testannoucement)
;####start custom code####
exten => s,n,ExecIf($["${REALCALLERIDNUM}" = ""]?goto(nomatch)) ;don't count people with no number
exten => s,n,ExecIf($[${LEN(${REALCALLERIDNUM})} != 10]?goto(match)) ;if their CLID isn't 10 digits, ignore.
exten => s,n,Set(dblogin=root) ;database user
exten => s,n,Set(dbpass=) ;database password
exten => s,n,Set(DateCheck=${STRFTIME(${EPOCH},,%Y-%m-%d)}) ;get current date YYYY-MM-DD
exten => s,n,MYSQL(Connect connid localhost ${dblogin} ${dbpass} asteriskcdrdb) ;connect to asterisk CDR
exten => s,n,MYSQL(Query resultid ${connid} select * from cdr where clid like "%${REALCALLERIDNUM}%" and calldate like "%${DateCheck}%" order by calldate desc limit 1)
exten => s,n,MYSQL(Fetch fetchid ${resultid} calldate clid src dst dcontext ) ;get the sql results (if any)
exten => s,n,NoOp(&&&&&&&&&&&&&&&&&&&&&&& ${calldate} ${clid} ${src} ${dst} ${dcontext} &&&&&&&&&&&&);echo the values in the log
exten => s,n,MYSQL(Disconnect ${connid}) ;close database connection
exten => s,n,MYSQL(Clear ${resultid}) ;clear the sql connection.
exten => s,n,GotoIf($["${calldate}" = "" ]?nomatch) ;no previous call detected, go to IVR
;custom matches
exten => s,n,GotoIf($["${dst}" = "" ]?nomatch) ;check to see if there is data in the last know DST column. If empty, goto ivr
;call a dialplan destination
exten => s,n,ExecIf($["${dst}" = "macro-pincollection"]?goto(${dst},s,1)
;call an extension
exten => s,n,ExecIf($["${dst}" = "6475580588"]?Dial(Local/${dst}@from-internal/n,)
;call an annoucement
exten => s,n,ExecIf($["${dst}" = "app-annoucement-1"]?goto(${dst},s,1)
;if no parameters match, then we continue onto the IVR
exten => s,n(nomatch),NoOp(No previous caller match)
;original code, change this IVR-13 to be the IVR-1 (likely) of your IVR as it would be in extensions_additional.conf
;##### end custom code######
exten => s,n,Goto(ivr-13,s,1)
Now the key to this is the last bit here.
For custom macros, look at your CDR table and match up the names.
exten => s,n,ExecIf($["${dst}" = “6475580588”]?Dial(Local/${dst}@from-internal/n,)
For this above example, when callers pressed a selection in the IVR, it dials a dumber. (this example is a zoom room meeting). Just replace the 6475580588 to match the number your ivr might dial if it were calling a number directly. This is also a RingGroup so it could be a 4 digit number etc.
Basically just insert this code, add/remove pieces that dont pertain to you and give it a test!
Feel free to message me if you have any questions.
EDIT: don’t forget to change REALCALLERIDNUM to FROMEXTEN for your system requirements.
No comments:
Post a Comment
Feel free to leave a comment! If you have any information that you think should be included, please do so here and I'll get it added in.