DIY CRM Integration using 3CX Integration Template

Discussion in '3CX Phone System - General' started by MarcosAG, Mar 22, 2017.

Thread Status:
Not open for further replies.
  1. MarcosAG

    Joined:
    Nov 28, 2016
    Messages:
    6
    Likes Received:
    0
    Hello guys,

    Just need a bit more clarification regarding the DIY CRM integration.

    We have followed all the steps in the 3CX CRM Integration ( https://www.3cx.com/docs/crm-integration/ ) as follows:
    1 - Selected Basic authentication (for API)
    2 - REST
    3 - Added all required URLs
    4 - Generated project skeleton in Visual Studio 2015

    Now we need to change the authentication form to use our API information instead of username and password as per instructions on this page https://www.3cx.com/docs/basic-authentication/ .

    Can someone be kind enough to explain what code to change or provide a sample with dummy API credentials?

    This would be super helpful!

    Many thanks to all.
     
  2. XanthiZ

    3CX Support

    Joined:
    Dec 18, 2015
    Messages:
    46
    Likes Received:
    7
    Hello MarcosAG,

    If you want to use your API Key instead of the username and password then you can modify the form to contain only one field.
    Go to the BasicConfigurationControl.cs file . Remove one TextBox and one Label . Change the property name of your TextBox (For example "txtAPI")
    See screenshot.

    Then select the Form and press F7.
    For the method loadInitialValues() set your TextBox to get the initialized value :
    Code:
     txtAPI.Text = _configurationManager.GetValue(ConfigurationParameters.Domain, String.Empty);
    For the method Save() set your TextBox to save the given value :
    Code:
    _configurationManager.SetValue(ConfigurationParameters.API, txtAPI.Text);
    Then you need to add a new Configuration Parameter. Go to ConfigurationParameters.cs . Add the following line :
    Code:
    public const string API= "API";
    Now you need to change the Authorization Header for the HTTP Requests to accept only API key.
    Go to ContactFinder class > findContact(string contactNumber) method . For the webRequest.Headers["Authorization"] add the following line :
    Code:
    webRequest.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(apikey + ":X"));
    Do the same for :
    • MySession class > createNewContactRecord(string contactNumber) Method
    • MySession class > StoreCallInformation(CallInformation callInformation) Method

    If you need any further help please let me know.
     

    Attached Files:

  3. MarcosAG

    Joined:
    Nov 28, 2016
    Messages:
    6
    Likes Received:
    0
    Awesome thanks XanthiZ!

    I will give this a shot and let you know how I go.

    Thanks again!
     
  4. MarcosAG

    Joined:
    Nov 28, 2016
    Messages:
    6
    Likes Received:
    0
    Hello XanthiZ,

    Thank you for your help, but after trying as per your instructions I was not able to get the plugin to show up in the settings > advanced settings > integration. I tried it a few times, but with no success.

    Just for clarification, to connect to our API we use 3 headers - please see attached image for your reference.

    Maybe a YouTube instruction video on this would be nice!

    Also, for plan B: what changes would we need to do on the 3CX Integration Template, if we integrated 3CX with our CRM SQL DB?

    Regards,
    Marcos
     

    Attached Files:

  5. XanthiZ

    3CX Support

    Joined:
    Dec 18, 2015
    Messages:
    46
    Likes Received:
    7
    Hello MarcosAG,

    If you are not able to see the dialog of your plugin from "Settings" > "Advanced Settings" > "Integration" you can check the log files from
    %appdata%\3CXPhone for Windows\Logs .
    Check the DotNetScriptConfig.log ,the DotNetScriptPlugin.log and MyPlugin.log

    Now if you want to add more Headers for your HTTP Request you can do the following:
    Code:
    webRequest.Headers["Authorization"] = "Basic " + myauthcodehere 
    webRequest.Headers["x-mysiteapi-crmtoken"] = myapitokenhere
    webRequest.Headers["x-mysitebapi-key"] = myapikeyhere
    
    Add these headers To ContactFinder class > findContact(string contactNumber) method , MySession class > createNewContactRecord(string contactNumber) method and MySession class > ShowContactRecord(string contactNumber, bool createIfNotFound).

    Please check the log files to investigate what error prevents you from showing the Plugin Dialog.
    If you need something else please let me know.

    Regards,
    Xanthi Zachariou
     
Thread Status:
Not open for further replies.