You can technically create the following dialplan:
[email-notify]
exten=> _.,1,Noop(checking the callerid ${CALLERID(num)})
same=>n,TrySystem(echo “Incoming Call - From: ${CALLERID(name)} ${CALLERID(number)} received at ${STRFTIME(${EPOCH},%l:%M:%S %p %Z on %A %B %e)}” | mail -s “Phone - Incoming Call to ${EXTEN}” -r ${mailg} [email protected], ${SHELL(mysql -s customerinfo -u admin -pPASSWORD -h IPADDRESS --skip-column-names -e ‘select email from account where phone="${CALLERID(num)}"’):0:-1})
same=>n,Goto(${ARG1},${ARG2},${ARG3})
And then you can create a custom context for each ring group as shown below:
For sales -
For Customer Service -
You can technically also split the EXTEN variable based on the hyphen, ${CUT(EXTEN,-,1)} to get the name, and ${CUT(EXTEN,-,2)} to get the number.
Also, I assume you only use the ring group so you can call the custom context with the queue simultaneously. If so, then with this solution, in the custom context you can point the destination directly to the queue. This will definitely make your CDR more cleaner.
Important note: You cannot enter any spaces in the custom context’s extension field. I filed a feature request to allow passing arguments, where then you will be able to pass an argument that contains a space.

