Hi chab,
Here is what I have been able to work out with the code you suggested (modified).
Code:
[custom-a2billing-cid-callback-tr]
;### Inbound callback scenario (menu language TR)
;### We normalize the CallerID to the standard form (countrycode-areacode-phonenumber).
;### In case we receive a national call (starting with one zero), we add the country code "90"
exten => _X.,1,Set(CALLERID(num)=${IF($[${CALLERID(num):0:2}=00]?${CALLERID(num):2}:${CALLERID(num)})})
exten => _X.,2,Set(CALLERID(num)=${IF($[${CALLERID(num):0:1}=0]?90${CALLERID(num):1}:${CALLERID(num)})})
exten => _X.,3,Set(CALLERID(num)=${IF($[${LEN(${CALLERID(num)})}=7]?90216${CALLERID(num):1}:${CALLERID(num)})})
;### We test if CID is in the database or not :
exten => _X.,n,MYSQL(Connect connid 127.0.0.1 user pass database)
exten => _X.,n,MYSQL(Query resultid ${connid} SELECT cc_callerid.cid FROM cc_callerid WHERE cc_callerid.cid = ${CALLERID(num)})
exten => _X.,n,MYSQL(Fetch fetchid ${resultid} callernumber)
exten => _X.,n,MYSQL(Clear ${resultid})
exten => _X.,n,MYSQL(Disconnect ${connid})
exten => _X.,n,GotoIf($["${CALLERID(num)}" = "${callernumber}"]?cidcallback:cidregister)
;### CID REGISTER
exten => _X.,n(cidregister),Answer
exten => _X.,n,Wait(1)
exten => _x.,n,DeadAgi(a2billing.php|11)
exten => _x.,n,Hangup
;### CID CALLBACK
exten => _X.,n(cidcallback),DeadAgi(a2billing.php|8|cid-callback|)
exten => _X.,n,Hangup
In this scenario, we have 3 cid callback trigger did's set as inbound routes with 3 different agiconf's with 3 menu languages.
agi-conf8 is a CID-Callback agi, with menu language TR.
agi-conf11 is a Callthrough agi.
Here is what happens:
The trigger DID for CID Callback in menu language TR receives a call,
The call passes to custom destination: custom-a2billing-cid-callback-tr
I choose to normalize all numbers to standard form.
Then I test if CID is in the database or not.
- If the number is there, I start a cid callback by calling DeadAgi(a2billing.php|8|cid-callback|) and exit.
- If the number is not there, I prompt for the card number and store the CID in the database by calling DeadAgi(a2billing.php|11) and exit.
In this way, when our cid callback did's are called, we either
- pass the call to cid registration, let the user dial the card number, register the callerid to the card and hang-up (next time user can start a cid callback without having to re-enter the card number).
- or check that cid exists in the database, skip registration and initiate a cid callback directly.
This saves us a seperate number for cid registration (the trigger did's are used both for registration and callback), but initial registration and then first callback call are two seperate calls.
It would have been lovely to start the callback call immediately after the registration on the first call though. Any suggestions how I can do that? In other words, I'd like to continue with
;### CID CALLBACK
after ;### CID REGISTER without hanging up.
or do something like:
exten => _x.,n,DeadAgi(a2billing.php|11)
exten => _X.,n,DeadAgi(a2billing.php|8|cid-callback|)
exten => _X.,n,Hangup
Would this be possible at all?
By the way, with your code, if CID is in the database, we do a CID callback, but if CID is not there, we do ALL callback, asking for the PIN. However, ALL callback does not support entering the PIN in the database when the user is authenticated, so if the CID is not initially in the database, it will never be there unless entered by an operator manually, right?