PureConnect

 View Only
Discussion Thread View
Expand all | Collapse all

ICWS API Issues

  • 1.  ICWS API Issues

    Posted 04-16-2019 07:44
    Using ICWS api to create CTI adapter with agent and telephony functionality.

    Trying to use request API to start the user status subscription. But received below error:

    {
    "errorId": "error.request.accessDenied.cookie.invalid",
    "alternateHostList": [],
    "errorCode": 5,
    "message": "A session cookie was provided with the request, but it is invalid or matching the expectations."
    }

    Request details:
    Method type: PUT
    URL: http://192.168.230.50:8018/icws/22113001/messaging/subscriptions/status/user-statuses
    Header contains 'Content-Type', 'ININ-ICWS-CSRF-Token' and 'Cookie' key values.
    Body contains : { "userIds": [ "user1" ] }

    I have created a connection request then from its response updated the CSRF token, Cookie and sessionid in above request but still i get "accessDenied.cookie.invalid" error.
     
    Any help to troubleshoot this is much appreciated..

    #Telephony

    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------


  • 2.  RE: ICWS API Issues

    Posted 04-16-2019 14:02
    I would double check your cookie code.  Here is what works for me:  

    Cookie = response.Headers.FirstOrDefault(h => h.Name == "Set-Cookie")?.Value.ToString()
    ..
    headers = new List<(string, string)> { ("ININ-ICWS-CSRF-Token", _ICWS_ConnectionParams.CsrfToken), ("Cookie", _ICWS_ConnectionParams.Cookie) };

    ------------------------------
    Jason Loucks
    Agon Consulting Services
    ------------------------------



  • 3.  RE: ICWS API Issues

    Posted 04-16-2019 23:34
    I am using Javascript API with Node.js runtime for creating an adapter.

    Here my source code..

    exports.startUserStatusSubscription = function(req,res) {
    
      let server= req.headers.server;
      let sessionId = req.headers.sessionid;
      let icwsCsrfToken = req.headers.icwscsrftoken;
      let method= req.headers.method;
      let requestPath= req.headers.requestpath;
      let timeout= 5000;//req.headers.timeout;
      let setCookie= req.get('set-cookie');
    
      let payload= req.body;//req.body.payload;
      
      let ICWS_URI_SCHEME = 'http://';
      let ICWS_URI_PORT = '8018';
      let ICWS_URI_PATH = '/icws';
    
      let uri = ICWS_URI_SCHEME + server + ':' + ICWS_URI_PORT + ICWS_URI_PATH;
    
      if(sessionId != undefined){
        uri += '/' + sessionId;
      }   
    
      // Add the specific ICWS request to the URI being built.
      if (requestPath.substring(0, 1) !== '/') {
        uri += '/';
      }
      uri += requestPath;
    
      logger.log('info',  "postRequest()> uri= " + uri);
    
      var options = {
        method: method,
        url: uri,
        headers:{ 
          'Content-type': 'application/json',
          'Accept-Language': 'en-us',
          'ININ-ICWS-CSRF-Token': icwsCsrfToken,
          'Cookie': setCookie
        },
        payload: payload
        //'timeout': timeout
        //'json': true
      };
    
      console.log(options);
    
      utils.callIcws(options).then(function(result) {
          console.log("startUserStatusSubscription()> Response received");
          //console.log(result)
          console.log(result.headers)
          console.log(result.body)
    
          // res.status(result.headers.statusCode).json(
          //   {'statusCode': result.headers.statusCode, 'statusMessage:' : result.headers.statusCode,
          //   'responseheaders': result.headers,
          //    'responsebody': result.body});
          
        }, function(err) {
          console.log("inside error")
          console.log(err);
          res.status(404).json(err);
        })
    };

    sample log..

    2019-04-16 16:04:42:650 info: postRequest()> uri= http://192.168.230.50:8018/icws/22013001/messaging/subscriptions/status/user-statuses
    { method: 'PUT',
      url:
       'http://192.168.230.50:8018/icws/22013001/messaging/subscriptions/status/user-statuses',
      headers:
       { 'Content-type': 'application/json',
         'Accept-Language': 'en-us',
         'ININ-ICWS-CSRF-Token':
          'VXVzZXIxWCRJQ1dTIEphdmFTY3JpcHQgRGlyZWN0IFVzYWdlIEV4YW1wbGVYJDliYTJjMTIxLWNkNWMtNDc1ZS04YWJmLTFjMjE3ZGVhOWE5ZlgPMTkyLjE2OC4xMzEuMTgy',
         Cookie:
          [ '[ \'icws_22013001=6d812bb6-a9f2-4cc7-a5e8-a564bbf3fb4b|languageId=en-us; Path=/icws/22013001; HttpOnly\' ]' ] },
      payload: { userIds: [ 'user1' ] } }​

    also attached postman request headers and body snaps..

    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



  • 4.  RE: ICWS API Issues

    Posted 04-17-2019 09:02
    The value of the cookie header should be a string containing only 'icws_22013001=6d812bb6-a9f2-4cc7-a5e8-a564bbf3fb4b|languageId=en-us'

    ------------------------------
    Donald Hamel
    Bell Canada
    ------------------------------



  • 5.  RE: ICWS API Issues

    Posted 04-17-2019 10:11
    Thanks.
    Actually the issue was with 'payload' parameter in request. 
    var options = {
        method: method,
        url: uri,
        headers:{ 
          'Content-type': 'application/json',
          'Accept-Language': 'en-us',
          'ININ-ICWS-CSRF-Token': icwsCsrfToken,
          'Cookie': setCookie
        },
        payload: payload
        //'timeout': timeout
        //'json': true
      };
    it should be 'body' instead of payload.

    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



  • 6.  RE: ICWS API Issues

    Posted 04-18-2019 01:48
    now i am able to call this API how can subscribe to get Agent login, logout, ready, not ready, after call work, answer, disconnect, hold, unhold etc events in my app. (I am using short polling method to get events but unable to get above events)

    I am referring below ICWS API guide. As per guide we can use 'userStatusProperties'  to get updates for. But there is no example on how to format user status properties to received required agent and telephony event.

    ICWS API

    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



  • 7.  RE: ICWS API Issues

    Posted 04-19-2019 08:52
    On my system it appears that supplying the userStatusProperties with the initial PUT request is broken. Supplying just the user ids, though returns every userStatusProperty available.

    [
        {
            "__type": "urn:inin.com:status:userStatusMessage",
            "userStatusList": [
                {
                    "userId": "sw",
                    "statusId": "Available",
                    "statusChanged": "20190419T050509Z",
                    "icServers": [],
                    "stations": [],
                    "loggedIn": false,
                    "onPhone": false,
                    "onPhoneChanged": "20190419T050509Z"
                },
                {
                    "userId": "swalls",
                    "statusId": "After Call Working",
                    "statusChanged": "20190419T123817Z",
                    "icServers": [],
                    "stations": [
                        "spc086"
                    ],
                    "loggedIn": true,
                    "onPhone": false,
                    "onPhoneChanged": "20190419T123740Z"
                }
            ],
            "isDelta": false
        }
    ]


    To subscribe to hold/unhold, connect/disconnect events, you should start a queue subscription for each user you care about. For that subscription you will need to supply the interaction attributes that represent the values you need to watch. At the minimum, you will probably want to watch for Eic_CallState and Eic_AssignedWorkgroup. You can view the queue subscription and a list of attributes available at the link below.

    Queue Subscription

    Interaction Attributes

    ------------------------------
    Sean Walls
    ------------------------------



  • 8.  RE: ICWS API Issues

    Posted 04-21-2019 07:44
    Thanks @Sean Walls

    I am trying to develop server side CTI adapter  which will facilitate client applications to do agent login and receive all the telephony events.

    Q1: I have successfully tested the queue subscription for 'user3'. Request and response is as below. Since i want to listen to all the events for all logged in agents. Do i have to subscribe to each user queue separately or i can create a workgroup and subscribe to workgroup. 

    Request:
    
    let uri= http://192.168.230.50:8018/icws/57513001/messaging/subscriptions/queues/InteractionStates
    
    let payload = {
            "queueIds": [{
                    "queueType": 1,
                    "queueName": "user3"}
            ],
            "attributeNames": [
                "Eic_State"
            ]
        };
    
    var options = {
          method: 'PUT',
          url: uri,
          headers:{ 
            'Content-type': 'application/json',
            'Accept-Language': 'en-us',
            'ININ-ICWS-CSRF-Token': csrfToken,
            'Cookie': cookie
          },
          body: payload ,
          json: true
        };​
    
    Response:
    {
       "__type":"urn:inin.com:queues:queueContentsMessage",
       "isDelta":true,
       "subscriptionId":"InteractionStates",
       "queueResultLimitExceeded":false,
       "interactionsAdded":[
    
       ],
       "interactionsChanged":[
          {
             "interactionId":"1001928487",
             "attributes":{
                "Eic_State":"S"
             }
          }
       ],
       "interactionsRemoved":[
    
       ]
    }

    Q2: Since 'Eic_State ' also give all the telephony events which attribute should I mention. 'Eic_State'  or 'Eic_CallState'.
    Q3: Found very little information about 'Eic_AssignedWorkgroup' what is the use of it?
    Q4: Response dont contain the agent details like agent id or station. Is it possible to enable this information so that it will be easy to map each event with specific agent id
    Q5: Which attribute to use to get 'after call work' event?



    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



  • 9.  RE: ICWS API Issues

    Posted 04-22-2019 09:41
    Q1: Your PUT request should contain every user you want to have a queue subscription for. If, for some reason, the list of users you want a subscription for changes, I believe you must do another PUT request with ALL of the users you want to watch. As an example, if you need to add a user to your watch, you will need to include all of the users you are already watching, and the new user.

    let payload = {
            "queueIds": [
    {
      "queueType": 1,
      "queueName": "user3"
    },
    {
      "queueType" : 1,
      "queueName" : "user2"
    },
    {
      "queueType" : 1,
      "queueName" : "user1"
    }
            ],
            "attributeNames": [
                "Eic_State"
            ]
        };


    Q2: You can use Eic_state if it suits your needs. If you need the displayable state of the interaction though, you may want to use Eic_CallState or Eic_CallStateString. 

    Q3: Eic_AssignedWorkgroup and Eic_WorkgroupName will contain the name of the workgroup queue the interaction is active in. You do not have to watch this attribute if you do not care about workgroup information.

    Q4: You can add EIC_LocalId for station, and Eic_LocalUserId for the user id. There may be other attributes that contain this information as well.

    Q5: I think you will want to subscribe to the status-messages subscription and check the isAfterCallWorkStatus property of the status. Theoretically, these status messages should not have changes made to them frequently, so the subscription will likely not cause any issues. Your application will then manage the list of system available status messages and their properties. If you only care about those where the isAfterCallWorkStatus is true, you can filter the response of the message, populate your own list of After Call Work statuses, discard the rest of them, and check this new list that contains just After Call Work Statuses. If you really wanted to, you could check the configuration of the status message after each status change, but this will be a lot of requests to make and read.

    ------------------------------
    Sean Walls
    ------------------------------



  • 10.  RE: ICWS API Issues

    Posted 04-24-2019 09:15
    thanks for detailed answer. ..
    need more help about Q5> after call work (ACW) is already configured in system but i dont receive the events after call disconnect. is it possible to get ACW event after call disconnect and one more event when ACW windows expires.

    Q: if someone login using existing logged-in users credentials i get below message. Is it possible to get agent id and station to identify the correct agent?
    {"__type":"urn:inin.com:connection:connectionStateChangeMessage","newConnectionState":2,"previousConnectionState":1,"reason":"Your session has been logged out due to a logon at another location or because your administrator revoked a necessary license.","shouldReconnect":false,"isDelta":false}


    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



  • 11.  RE: ICWS API Issues

    Posted 04-24-2019 09:51
    I am sorry, but I am not sure that ACW has any sort of specific event notification besides the status changes. In my experiences I have managed each users' last status information to compare if it was ACW time spent.

    If you have that response, I would think you still have access to the request which should hold the user attempting to login.

    ------------------------------
    Sean Walls
    ------------------------------



  • 12.  RE: ICWS API Issues

    Posted 04-25-2019 01:15
    For forced logout if user using my adapter to login then only i have access to login request. But if user tries to login using Interaction desktop then i dont have access to login request and directly get "Your session has been logged out due..."  Now how to identify which user has been removed..

    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



  • 13.  RE: ICWS API Issues

    Posted 04-25-2019 09:12
    Can you please help me with ICWS api which i can use to dispose the call (update wrap up code when user disconnect the call)

    ------------------------------
    DEEPTI SRIVASTAVA
    AGC networks Australia Pty Ltd
    ------------------------------



Need Help finding something?

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