Currently I am using Python to connect to AMI and everything is working fine. I can see live calls, hangup calls as well
But I have a task to accomplish, with every calls made I can see the duration of these calls. Now I have to deduct the duration from the balance added in the MySQL table column for the user.
So when (balance - current_duration) < 60seconds then an IVR should tell the user that he or she has 1 minute left.
Do you think this can be achieved using the Python script. Also the script will have to run asynchronously not needing to go to a page before the function can be activated.
L(x[:y][:z]): Limit the call to ‘x’ ms, warning when ‘y’ ms are left, repeated every ‘z’ ms) Only ‘x’ is required, ‘y’ and ‘z’ are optional. Numbers must be integers- beware of AGI scripts that may return long integers in scientific notation (esp PHP 5.2.5&6) The following special variables are optional for limit calls: (pasted from app_dial.c)
LIMIT_PLAYAUDIO_CALLER - yes|no (default yes) - Play sounds to the caller.
LIMIT_PLAYAUDIO_CALLEE - yes|no - Play sounds to the callee.
LIMIT_TIMEOUT_FILE - File to play when time is up.
LIMIT_CONNECT_FILE - File to play when call begins.
LIMIT_WARNING_FILE - File to play as warning if 'y' is defined. If LIMIT_WARNING_FILE is not defined, then the default behaviour is to announce ("You have [XX minutes] YY seconds").
I am trying to test it now. Also I have this channel to update balance for ${CDR(billsec)} is just an empty string. I want to get the duration of the call at the point of answer
exten => h,1,NoOp(Now call is hangup for user ${user_id} now update balance ${balance} from ${CDR(billsec)})
same => n,Set(billmin = $[${CDR(billsec)} / 60 ])
same => n,NoOp(The billsec in minute is ${billmin})
same => n,Set(new_balance = $[${balance} - ${billmin}])
same => n,Set(BALANCE_UPDATE(${new_balance}, ${user_id}))
Now I monitored the CLI and I got to find out it is omitting the first argument which is the limit. So it just put a space instead of the variable followed by the colon.
L(:60000:10000)
But when I hard coded it this way
L(120000:60000:10000)
Maybe I have to see what is happening with the variable
– Executing [h@forward:1] NoOp(“SIP/46.19.209.14-00090cc3”, “Now call is hangup for user 174 now update balance 10 from 52”) in new stack
– Executing [h@forward:2] Set(“SIP/46.19.209.14-00090cc3”, “billmin = 0.866666666666666667”) in new stack
– Executing [h@forward:3] NoOp(“SIP/46.19.209.14-00090cc3”, "The billsec in minute is ") in new stack
– Executing [h@forward:4] Set(“SIP/46.19.209.14-00090cc3”, “BALANCE_STATUS(9.13333333333333333, 174)”) in new stack
Also the column in the MySQL storing the value is an INT(30) so I would be expecting 9 to be saved in this scenario.