Genesys Engage on-premises

 View Only

Discussion Thread View
  • 1.  Web Sevices API

    Posted 07-21-2022 05:45
    Hi Team,
               We have been working on a project where our application which used to talk to Genesys PSDK now had to upgrade to GWS API. we were able to connect and get few requests and CometD notifications successfully. we need to get CFGApplication from CME we tried giving below request but we got StatusCode 4
    Response we got
    {"statusCode":4,"statusMessage":"Provisioning service is not available at this time"}

    Note we are using GWS version 8.5.2

    Pl let us know what we are missing

    Thanks and Regards,
    Sudhakar Balla
    #ArchitectureandDesign
    #CloudMigration(NEW)
    #GenesysEngageDev

    ------------------------------
    sudhakar Balla
    Voxai Solutions Inc.
    ------------------------------


  • 2.  RE: Web Sevices API

    GENESYS
    Posted 09-02-2022 10:38
    Hi - I would recommend to follow up with Genesys Customer Care if you haven't resolved the connection issue with GWS 8.5.
    Also note that GWS 9 is available as part of Multicloud CX Private Edition. Please reach out to Genesys Product Management if you believe this would be of interest.
    Regards, Bill Mitchell        Genesys Product Management

    ------------------------------
    William Mitchell
    Genesys - Employees
    ------------------------------



  • 3.  RE: Web Sevices API

    Posted 09-04-2022 03:08
    Hi Sudhakar,

    We are also working on similar project to use GWS APIs instead of PSDK to integrate our application with Genesys WDE to perform the agent call control and other functionalities from a web application. However, we are stuck at the cometD handshake stage where we get 403 handshake denied. The genesys documents doesn't throws deep insights into what could be causing the issue.

    If you could share your thoughts on how you got it working, it would be very helpful.

    We even had case opened with customer care and its been under investigation for 2 weeks now and still not much progress.

    Thank you
    Best Regards
    Rashid Yusuf
    Fourth Dimension Systems
    #GenesysEngageDev
    #Architecture
    #Design​​

    ------------------------------
    Rashid Yusuf
    Fourth Dimension Systems LLC
    ------------------------------



  • 4.  RE: Web Sevices API

    Posted 09-06-2022 00:44
    Hello Rashid,

    Check the below code. Create an HTML file and copy the below code and include the required JS files included in the Script tag. Hope you have all the JS files related to Cometd. Update the BaseURL with your GWS server URL. Hope this helps you.

    <html>
    <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Varela+Round">

    <script src="Scripts/cometd/cometd.js"></script>
    <script type="text/javascript" src="Scripts/cometd/AckExtension.js"></script>
    <script type="text/javascript" src="Scripts/cometd/ReloadExtension.js"></script>
    <!-- <script type="text/javascript" src="./org/cometd.js"></script>
    <script type="text/javascript" src="./org/cometd/ReloadExtension.js"></script>

    <script src="./jquery.cometd.js"></script> -->

    <script>

    //////////////////////////////////////////////////////////////////////////////
    // Initialization
    //////////////////////////////////////////////////////////////////////////////
    var baseUri = 'https://YourGWS-workspace.com:8043';
    var username = 'TestAgent';
    var password = '';

    var csrfHeaderName;
    var csrfToken;
    var cometd;

    $.ajaxSetup({
    beforeSend: function (xhr) {
    if (csrfHeaderName && csrfToken) {
    xhr.setRequestHeader(csrfHeaderName, csrfToken);
    }
    }
    });

    $(document).ready(function () {
    $('#getMeButton').click(getMe);
    $('#startCometdButton').click(connectCometD);
    $('#startSessionButton').click(startContactCenterSession);
    $('#readyButton').click(ready);
    $('#stopCometdButton').click(disconnectCometD);
    $('#endSessionButton').click(endContactCenterSession);

    cometd = new org.cometd.CometD()//$.cometd;

    cometd.addListener('/meta/handshake', onHandshake);
    cometd.addListener('/meta/connect', onConnect);
    cometd.addListener('/meta/disconnect', onDisconnect)

    $(window).unload(function () {
    cometd.disconnect();
    });
    });

    //////////////////////////////////////////////////////////////////////////////
    // HTTP Helpers
    //////////////////////////////////////////////////////////////////////////////
    var get = function (params) {
    console.log(params);
    var request = {
    url: baseUri + params.uri,
    type: 'GET',
    crossDomain: true,
    xhrFields: {
    withCredentials: true
    },
    success: function (data, textStatus, response) {
    console.log(response.getAllResponseHeaders());

    if (response.getResponseHeader('X-CSRF-HEADER') && response.getResponseHeader('X-CSRF-TOKEN')) {
    csrfHeaderName = response.getResponseHeader('X-CSRF-HEADER');
    csrfToken = response.getResponseHeader('X-CSRF-TOKEN');

    console.log('csrfHeaderName: ' + csrfHeaderName);
    console.log('csrfToken: ' + csrfToken);
    }

    if (params.callback) {
    params.callback(data);
    }
    },
    error: function (result) {
    console.log(result);

    if (params.error) {
    params.error(result);
    }
    }
    };

    if (params.includeCredentials) {
    request.beforeSend = function (xhr) {
    xhr.setRequestHeader('Authorization', 'Basic ' + window.btoa(username + ':' + password));
    };
    }

    $.ajax(request);
    };

    var post = function (params) {
    var data = JSON.stringify(params.json, undefined, 2);

    var request = {
    url: baseUri + params.uri,
    type: 'POST',
    data: data,
    headers: {
    'Content-Type': 'application/json'
    },
    crossDomain: true,
    xhrFields: {
    withCredentials: true
    },
    handleAs: 'json',
    success: function (data) {
    if (params.callback) {
    params.callback(data);
    }
    },
    error: function (req, err, exception) {
    console.log('Error! (' + req.status + ') : ' + err + ' ' + exception);
    if (params.error) {
    params.error(result);
    }
    }
    };

    $.ajax(request);
    }

    //////////////////////////////////////////////////////////////////////////////
    // API Functions
    //////////////////////////////////////////////////////////////////////////////
    var getMe = function () {
    get({
    uri: '/api/v2/me',
    includeCredentials: true
    });
    };

    var startContactCenterSession = function () {
    post({
    uri: '/api/v2/me',
    json: {
    operationName: 'StartContactCenterSession',
    channels: ['voice'],
    place: "123456"
    }
    });
    };

    var ready = function () {
    post({
    uri: '/api/v2/me',
    json: {
    operationName: 'Ready'
    }
    });
    };

    var endContactCenterSession = function () {
    post({
    uri: '/api/v2/me',
    json: {
    operationName: 'EndContactCenterSession'
    },
    callback: onEndContactCenterSessionComplete
    });
    };

    //////////////////////////////////////////////////////////////////////////////
    // Callbacks
    //////////////////////////////////////////////////////////////////////////////
    var onEndContactCenterSessionComplete = function () {
    csrfHeaderName = null;
    csrfToken = null;
    }

    //////////////////////////////////////////////////////////////////////////////
    // CometD
    //////////////////////////////////////////////////////////////////////////////

    var connected = false;
    var subscription;

    var onConnect = function (message) {
    if (cometd.isDisconnected()) {
    return;
    }

    var wasConnected = connected;
    connected = message.successful;
    if (!wasConnected && connected) {
    console.log('Cometd connected.');
    } else if (wasConnected && !connected) {
    console.log('Cometd disconnected...');
    }
    };

    var onDisconnect = function (message) {
    if (message.successful) {
    connected = false;
    console.log('Cometd disconnected.');
    }
    };

    var onMessage = function (message) {
    console.log('Cmetd message received:\n' + JSON.stringify(message, null, 2));
    };

    var onHandshake = function (handshake) {
    if (handshake.successful === true) {
    if (subscription) {
    console.log('unsubscribing: ' + subscription);
    cometd.unsubscribe(subscription);
    }

    console.log('Subscribing to channels...');
    subscription = cometd.subscribe('/v2/me/*', onMessage);
    }
    };

    var connectCometD = function () {

    var reqHeaders = {};
    reqHeaders[csrfHeaderName] = csrfToken;

    cometd.unregisterTransport('websocket');
    cometd.unregisterTransport('callback-polling');
    cometd.configure({
    url: baseUri + '/api/v2/notifications',
    logLevel: "info",
    requestHeaders: reqHeaders
    });

    cometd.handshake();
    };

    var disconnectCometD = function () {
    cometd.disconnect();
    };

    </script>
    </head>

    <body>
    <button id='getMeButton'>Get Me</button>
    <br/>
    <button id='startCometdButton'>Start CometD</button>
    </br>
    <button id='startSessionButton'>Start Contact Center Session</button>
    <br/>
    <button id='readyButton'>Ready</button>
    <br/>
    <button id='stopCometdButton'>Stop CometD</button>
    </br>
    <button id='endSessionButton'>End Contact Center Session</button>
    </body>
    </html>


    ------------------------------
    sudhakar Balla
    Voxai Solutions Inc.
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources