SQL query for incoming calls

Hi, I seem to have managed to get the Phonebook working, but any incoming calls are simply displaying the extension or ring group rather than the incoming CID.

For example:

DID: 01432765098
Incoming CID: 01234567890
Inbound rules : 01432765098 -> Ring Group 700
Ring Group 700: Ext 500 & Ext 501

The FOP2 screen shows an incoming call, but it appears to come from Ext 700, so nothing is returned from the SQL query.
When I checked the SQL query, it reads:

SELECT concat(firstname,' ',lastname,'<br/>',company) as name,picture FROM visual_phonebook WHERE phone1 LIKE '%500'OR phone2 LIKE '%500' LIMIT 1

For some reason FOP2 seems to be picking up the called ring group as the CID. Any iseas how to correct this to show the actual CID?

Carlos.

Comments

  • Hello Carlos,

    I do not think is FOP not picking the callerid, but Asterisk setting it, at least when it comes to AMI events. I do not know how are you managing ring groups (I do not use ring groups myself), but in your ring group macro/context perhaps you can force the callerid or set it before dialing.

    You can start fop2 in debug mode to catch the manager events ( ./fop2_server -X 3 ) and look for the Callerid on those events.

    Best regards,
  • Thnaks for you quick response Nicolas. I've set up one of the incoming DDIs to go straight to a single extension (500) and I've done as you suggest re: debugging mode, and the line I suspect I should be looking at is:

    127.0.0.1 <- Event: AGIExec
    127.0.0.1 <- Privilege: call,all
    127.0.0.1 <- SubEvent: End
    127.0.0.1 <- Channel: SIP/87.xxx.xxx.242-09e92118
    127.0.0.1 <- CommandId: 1478964973
    127.0.0.1 <- Command: VERBOSE "Caller ID name is 'Main Number - Xxxx Xxxxxxxx Xxxxxxx' number is '017xxxxxx00'" 1
    127.0.0.1 <- ResultCode: 200
    127.0.0.1 <- Result: Success
    127.0.0.1 <- Server: 0

    I've blanked out the personal data with xxxx in the above.

    I assume that Asterisk is passing the info through. I have set up Asterisk to use a different SQL database, hence it recognises the name associated with the caller ID.

    What should I be looking for if not the above section?

    Cheers,
    Carlos.
  • Hi Nicolas,

    Just a thought, but could it be that the problem lies here:

    127.0.0.1 <- Event: NewCallerid
    127.0.0.1 <- Privilege: call,all
    127.0.0.1 <- Channel: SIP/87.xxx.xxx.242-09ea55c0
    127.0.0.1 <- CallerIDNum: 017******00
    127.0.0.1 <- CallerIDName: Main Number - 017******00
    127.0.0.1 <- Uniqueid: 1266074985.21
    127.0.0.1 <- CID-CallingPres: 0 (Presentation Allowed, Not Screened)
    127.0.0.1 <- Server: 0

    This is the output from Asterisk 1.6, and I think that the 1.4 version would output:

    127.0.0.1 <- CallerID: 017******00

    Rather than CallerIDNum:

    Could this be the issue?

    Carlos.
  • Hi Nicolas,

    Just installed Asterisk 1.4 in order to test this. The equivalent output is:

    127.0.0.1 <- Event: Newchannel
    127.0.0.1 <- Privilege: call,all
    127.0.0.1 <- Channel: SIP/87.127.240.98-08595bf8
    127.0.0.1 <- State: Down
    127.0.0.1 <- CallerIDNum: 07*******69
    127.0.0.1 <- CallerIDName: 07*******69
    127.0.0.1 <- Uniqueid: 1266495006.279
    127.0.0.1 <- Server: 0

    127.0.0.1 <- Event: Newstate
    127.0.0.1 <- Privilege: call,all
    127.0.0.1 <- Channel: SIP/87.127.240.98-08595bf8
    127.0.0.1 <- State: Ring
    127.0.0.1 <- CallerID: 07*******69
    127.0.0.1 <- CallerIDName: 07*******69
    127.0.0.1 <- Uniqueid: 1266495006.279
    127.0.0.1 <- Server: 0

    The main difference between this and Asterisk 1.6 appears to be the "CallerIDName:" being presented as the caller ID in v1.4, but presented as the CID Name Prefix + caller ID in v1.6.

    Could this be why it's working in 1.4 and not in 1.6?

    Carlos.
  • Hi Carlos,

    FOP2 knows about the difference in the Callerid names in 1.4 and 1.6. Your problem is not that, but something else in the dialplan. There are other events in AMI that affect callerid, independent of the header names. A full trace with debug level 1 ( -X 1) should be needed for tracking the problem down. Best regards,

    --
    Nicolás
  • Carlos, if you can start fop2_server in debug level 1 mode , then make the call that exhibits that behaviour and send me the capture together with your button config I might be able to track the problem down. You can also try to catch me in the site's live help system to arrange ssh access to your machines. Best regards,
Sign In or Register to comment.