Any way to set account code or userfield in CDR during calls? Feature code? Web interface?

Running FreePBX 12.0.13, with FOP2.

I work for a company that has a service department that splits their time supporting customers from three other departments. I don’t need down to the second reporting, but it would be really nice to figure out how much time they spend on each department’s customers.

Ideally, I’d love something that popped up as a web interface (FOP2 can call a URL) that made customer service reps chose between the three options on each incoming and outgoing call.

I would be equally happy with a feature code that could be dialed during the call. I.E. dial *50 during a call, and the CDR would have “50” in a field we could report on (accountcode?). Dial *51=51 in the field, dial *52 and get 52? I only really need 3. There are only 2 or 3 extensions that will need this, if that matters.

You could probably do it via the AMI from a web script (Perl, PHP, python, etc):

Action: Setvar
Channel: <value>
Variable: CDR(accountcode)
Value: 50

The trick of course is figuring out what channel is their call. Perhaps FOP2 can pass that value in the URL? You’d also want to have some way of authenticating the connection to the web script, so you don’t open it up to abuse.

Thanks, I’ll start looking into the AMI.

I don’t think there’s a real worry about locking down the script as all extensions are local, and the whole thing is behind a firewall.