is it possible to fire an event on incoming call?

Discussion in '3CX Phone System - General' started by PyeDubois, Nov 11, 2007.

  1. PyeDubois

    Joined:
    Nov 10, 2007
    Messages:
    2
    Likes Received:
    0
    is it possiblbe to fire an event on incoming call?

    I have a small application that I would like to run on an incoming call.
    I have a server running the main app, and acouple of client/terminals.
    Is there a way do this? I would also like to grab the clid and use it to open a database record containing the clid's account info. Opening the record is, of course, not the problem, but Running the little app and grabbing the clid is. Ideally Iwould like to open the app on the clients, but if Ican get it to happen anywhere I'd be happy!

    Any ideas?
     
  2. BendyMetal

    Joined:
    Oct 8, 2007
    Messages:
    36
    Likes Received:
    0
    yes...

    I think you would need an application watching for incoming calls to a specific extension. I have done something very similar - i have an application querying the 3cx database at regular intervals looking for incoming calls to the extension i say i am registered to. This then grabs the clid and could obviously do whatever thereafter. What programming language are you using? I'm programming in C# (.net)
     
  3. PyeDubois

    Joined:
    Nov 10, 2007
    Messages:
    2
    Likes Received:
    0
    I am using vb.net. I actually got it working by monitoring the 3cxPhoneSystem.log for a change, and when a change occurs, I read the lines in the 3cxPhoneSystem.trace.log file looking for the last line containing "INVITE: sipreq:" and parsing it for the extension and clid. My concern here is multiple calls to multiple clients, and file lock problems, ect. My app needs to run on each client. It would be much better to watch the db. Can I do this from multiple clients? I read about accessing the PostgreSQL3cxdb by using MS Access to link tables, but didn't think that would work well on the clients.

    Could you elaborate a little? It sounds like we are doing very similar things,

    Thanks,

    Mark
     
  4. BendyMetal

    Joined:
    Oct 8, 2007
    Messages:
    36
    Likes Received:
    0
    Mark,

    Happily.

    I am using a connection to the database from the clients - do you have pgAdmin tool? Have you changed the postgre conf files to allow connections from multiple clients? (you'll need to!)

    ODBC connection string for the program:
    (needs corresponding entry in control panel)

    Code:
            OdbcConnection odbc = new OdbcConnection("Dsn=Phones;database=phonesystem;
    server={serverip};port=5480;uid=phonesystem;
    sslmode=disable;readonly=0;protocol=7.4;
    fakeoidindex=0;showoidcolumn=0;rowversioning=0;
    showsystemtables=0;fetch=100;socket=4096;
    unknownsizes=0;maxvarcharsize=255;
    maxlongvarcharsize=8190;debug=0;commlog=0;
    optimizer=1;ksqo=1;usedeclarefetch=0;textaslongvarchar=1;
    unknownsaslongvarchar=0;boolsaschar=1;parse=0;
    cancelasfreestmt=0;extrasystableprefixes=dd_;lfconversion=1;
    updatablecursors=1;disallowpremature=0;trueisminus1=0;bi=0;
    byteaaslongvarbinary=0;useserversideprepare=0;
    lowercaseidentifier=0;xaopt=1");
    
    (Stupid long connection string for postgre....but it works!)

    This snippet gets the most recent unanswered, uncompleted call for the specified extension:

    Code:
    minimalselect = "SELECT CASE WHEN from_no isnull then 'zzzzz' ELSE from_no END FROM \"public\".callhistory  WHERE (id = (SELECT MAX(id) AS Expr1 FROM \"public\".callhistory callhistory_1 WHERE (to_no = '" + {extensionnumber} + "') and is_answ=false and is_compl=false))";
    
                odbc.Open();    
                
                OdbcCommand cmd = new OdbcCommand(minimalselect, odbc);
                object returnvalue = cmd.ExecuteScalar();
                
                odbc.Close();
    
    Obviously, the above will need translating to VB.net but at least you'll have access to the same libraries!! Bear in mind that the SQL select queries have to be grammatically correct for Postgre (& not MS SQL or Access!)

    Hope this helps - if not, PM me.

    Thanks
     

Share This Page