PureConnect

Discussion Thread View
Expand all | Collapse all

Interaction Connect add-in : Retrieving attribute, Queue Object and Session

  • 1.  Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 21 days ago
    Hi there,

    Need help please.

    We are trying to get the attributes from a custom handler and we are using  ININ.Addins.IC.

    Prior to using the queue object we are validating the connection to the session and it shows as application not connected.

    We are assuming that prior to using the queue object the session must be connected first.
    Please help us and provide guidance please if our assumption is correct.

    We have provided our script below

    $(document).ready(function(){
    if (!ININ.Addins.IC.sessionInfo.connected) {
    console.log("Application is not connected");
    }

    // Observe when the application is connected
    ININ.Addins.IC.sessionInfo.on("connected", function(sessionInfo) {
    console.log(sessionInfo.userId + " is connected to " + sessionInfo.icServer);
    });

    var baseUrl = ININ.Addins.IC.getIcwsBaseUrl();
    console.log(baseUrl);
    var queue = new ININ.Addins.IC.Queues.Queue();
    console.log("this is a queue instance created", queue);
    queue.on("interactionAdded", function(interaction) {
    console.log(
    interaction.getAttribute(ININ.Addins.IC.Interaction.attributeNames.interactionType),
    "Interaction", interaction.interactionId, "was added to queue. State is:",
    ININ.Addins.IC.Interaction.attributeNames.stateDisplay
    );
    });
    });

    Kind regards,

    Jerome
    #Unsure/Other

    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------


  • 2.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    GENESYS
    Posted 20 days ago
    Hey, Jerome!

    Please can you clarify? You are saying you are using a Handler, but the code you post looks like C#, which would imply ICELib (or more specifically, an Interaction Desktop Add-In.)


    ------------------------------
    Paul Simpson
    Senior Technical Instructor
    ------------------------------



  • 3.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 18 days ago
    Hi Paul,

    Thank you so much for your reply.

    The code is JavaScript

    We are applying code found from this documentation

    https://help.genesys.com/developer/cic/docs/connectaddin/inin.addins.ic.queues.queue.html

    https://help.genesys.com/developer/cic/docs/connectaddin/ININ.Addins.IC.html

    Kind regards,

    Jerome.


    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------



  • 4.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 18 days ago

    Hi Jerome,

    your code looks right, but there are two things to mention:
    1. Please have a look at https://help.genesys.com/developer/cic/docs/connectaddin/tutorial-createcustview.html You should check, whether theAPI is already loaded.

    2. There may be a timing problem when you check the connection state and then subscribe session info. I think better do it vice versa.

    ​Best regards

    ------------------------------
    ---------------------------------------------
    Hans-Gerd Sandhagen
    Software Developer
    Fiebig GmbH
    ---------------------------------------------
    ------------------------------



  • 5.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 18 days ago
    Hi Hans,

    Confirmed that the api is loaded and sessionInfo is also saying connected.

    Upon debugging I do not see any interactions caught during the queue even during a call.


    Kind regards,

    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------



  • 6.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 18 days ago
    Hi Jerome,

    did you also subscribe to the queue (see example in the link you sent):

    queue.subscribe({
      queueIds
    : [{ type: ININ.Addins.IC.Queues.queueTypes.system, name: ININ.Addins.IC.sessionInfo.userId }],
      attributeNames
    : [ "CUSTOM_ATTRIBUTE", ININ.Addins.IC.Interactions.attributeNames.interactionType ] });


    Best regards,

    ------------------------------
    ---------------------------------------------
    Hans-Gerd Sandhagen
    Software Developer
    Fiebig GmbH
    ---------------------------------------------
    ------------------------------



  • 7.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 17 days ago
    Hi Hans,

    We managed to get the queue running.

    We are trying to get the value of a custom attribute from a handler.

    Can we get this using getattribute function?

    this is the line of code we try to call and get the value - customAttribute = interaction.getAttribute("Attr_Shandle");

    $(document).ready(function(){
    var queue = new ININ.Addins.IC.Queues.Queue();
    queue.on("interactionAdded", function(interaction) {
    // console.log(
    // interaction.getAttribute(ININ.Addins.IC.Interaction.attributeNames.interactionType),
    // "Interaction", interaction.interactionId, "was added to queue. State is:",
    // ININ.Addins.IC.Interaction.attributeNames.stateDisplay);
    var interactionState = interaction.getAttribute(ININ.Addins.IC.Interactions.attributeNames.state),
    customAttribute = interaction.getAttribute("Attr_Shandle");
    });
    queue.on("interactionChanged", function(interaction) {
    console.log(
    interaction.getAttribute(ININ.Addins.IC.Interaction.attributeNames.interactionType),
    "Interaction", interaction.interactionId, "has changed. State is:",
    ININ.Addins.IC.Interaction.attributeNames.stateDisplay
    );
    });
    queue.on("interactionRemoved", function(interaction) {
    console.log("Interaction", interaction.interactionId, "has been removed from queue.");
    });
    queue.subscribe({
    queueIds: [{
    type: ININ.Addins.IC.Queues.queueTypes.system,
    name: ININ.Addins.IC.sessionInfo.userId
    }],
    attributeNames: [
    "CUSTOM_ATTRIBUTE",
    ININ.Addins.IC.Interactions.attributeNames.interactionType
    ]
    });
    });


    https://help.genesys.com/developer/cic/docs/connectaddin/ININ.Addins.IC.Interactions.html#.getAttributes

    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------



  • 8.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 17 days ago
    Hi Jerome,

    > Can we get this using getattribute function?
    yes, this should work, but I am not sure, wether you have to subscribe for this attribute before or not.

    Example:
    ....
    attributeNames: [
    "Attr_Shandle",
    ININ.Addins.IC.Interactions.attributeNames.interactionType
    ]
    .....

    Best regards,

    ------------------------------
    ---------------------------------------------
    Hans-Gerd Sandhagen
    Software Developer
    Fiebig GmbH
    ---------------------------------------------
    ------------------------------



  • 9.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 16 days ago
    Hi Hans,

    We managed to get it working by adding the custom attribute at the queue.subscribe.

    We are having issues on getting the new interaction with the same code, we need to reload the add-in to be able to get the new interaction.

    We are assuming that queue.on("interactionChanged", function(interaction) should trigger at this change event.

    Kind regards,

    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------



  • 10.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 16 days ago
    Hi Jerome,

    normally this should work. I could not test this at the moment but when I remember right there are some scenario to mention:

    1. Interaction is already in queue, queue is subscribed by Addin -> queue send "interactionAdded" for all interactions in queue.
    2. queue is subscribed by Addin, new interaction enters the queue -> queue send "interactionAdded" for this interactions.
    3. Subscribed attribute is changed when interaction is in queue and queue is subscribed -> "interactionChanged" event is send.

    Best regards,


    ------------------------------
    ---------------------------------------------
    Hans-Gerd Sandhagen
    Software Developer
    Fiebig GmbH
    ---------------------------------------------
    ------------------------------



  • 11.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 14 days ago
    Hi Hans,

    We managed to get the attribute successfully using the existing code.

    How do we get the new interaction if the previous call has already finished?

    Existing code does not trigger without reloading the page add-in

    Kind regards,

    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------



  • 12.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 14 days ago
    Hi Jerome,

    I did a test.
    I used the following code, more or less copied from documentation, but with one correction: Namespace of interaction is

    ININ.Addins.IC.Interactions
    not
    ININ.Addins.IC.Interaction

    Notice the missing "s"

    <script>
    var queue;
    function apiLoaded() {
    var versionString = "I am running version " + ININ.Addins.version + " of the add-in API.";
    document.getElementById("version").innerText = versionString;
    // Observe when the application is connected
    ININ.Addins.IC.sessionInfo.on("connected", function(sessionInfo) {
    console.log(sessionInfo.userId + " is connected to " + sessionInfo.icServer);
    subscribeQueue();
    });
    // Determine whether the application is connected
    if (ININ.Addins.IC.sessionInfo.connected) {
    console.log("Application is connected");
    subscribeQueue();
    }
    }
    function subscribeQueue() {
    queue = new ININ.Addins.IC.Queues.Queue();
    queue.on("interactionAdded", function(interaction) {
    console.log(
    interaction.getAttribute(ININ.Addins.IC.Interactions.attributeNames.interactionType),
    "Interaction", interaction.interactionId, "was added to queue. State is:",
    interaction.getAttribute(ININ.Addins.IC.Interactions.attributeNames.stateDisplay)
    );
    });
    queue.on("interactionChanged", function(interaction) {
    console.log(
    interaction.getAttribute(ININ.Addins.IC.Interactions.attributeNames.interactionType),
    "Interaction", interaction.interactionId, "has changed. State is:",
    interaction.getAttribute(ININ.Addins.IC.Interactions.attributeNames.stateDisplay)
    );
    });
    queue.on("interactionRemoved", function(interaction) {
    console.log("Interaction", interaction.interactionId, "has been removed from queue.");
    });
    queue.subscribe({
    attributeNames: [
    ININ.Addins.IC.Interactions.attributeNames.interactionType,
    ININ.Addins.IC.Interactions.attributeNames.stateDisplay
    ],
    queueIds: [
    { type: ININ.Addins.IC.Queues.queueTypes.system, name: ININ.Addins.IC.sessionInfo.userId }
    ]
    });
    </script>

    This code gives the following console output for two calls without any reload or refresh of the addin or the client
    (Sorry, state values are in German because we have a german system)

    Call Interaction 2001580215 was added to queue. State is: Initialisierung wird durchgeführt
    Call Interaction 2001580215 has changed. State is: Wählen
    Call Interaction 2001580215 has changed. State is: Fortgesetzt
    Call Interaction 2001580215 has changed. State is: Verbunden
    Call Interaction 2001580215 has changed. State is: Getrennt [Fern getrennt]
    Interaction 2001580215 has been removed from queue.
    Call Interaction 2001580218 was added to queue. State is: Initialisierung wird durchgeführt
    Call Interaction 2001580218 has changed. State is: Wählen
    Call Interaction 2001580218 has changed. State is: Fortgesetzt
    Call Interaction 2001580218 has changed. State is: Verbunden
    Call Interaction 2001580218 has changed. State is: Getrennt [Fern getrennt]
    Interaction 2001580218 has been removed from queue.

    I hope this will help.

    Best regards,

    ------------------------------
    ---------------------------------------------
    Hans-Gerd Sandhagen
    Software Developer
    Fiebig GmbH
    ---------------------------------------------
    ------------------------------



  • 13.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 13 days ago
    Hi Hans,

    We managed to get the changed in interactions successfully.

    Is there a way to open a browser using by just javascript without a DOM? window.Open() is not working without a DOM.

    https://help.genesys.com/developer/cic/docs/connectaddin/tutorial-basicrequirements.html

    ------------------------------
    Franz Jerome De Guzman
    Nexus Technologies, Inc.
    ------------------------------



  • 14.  RE: Interaction Connect add-in : Retrieving attribute, Queue Object and Session

    Posted 11 days ago
    Hi Jerome,

    I think we are now far away from the original question and I am not sure, what you mean with "a way to open a browser".

    If you mean, running an addin without a view, it is possible as described in the link you sent. Just create a "manifest.json" and write your code in "main.js". But be aware, that the addin has no view, no visual appearence and is automatically excecuted when the client is started.

    Best regards,

    ------------------------------
    ---------------------------------------------
    Hans-Gerd Sandhagen
    Software Developer
    Fiebig GmbH
    ---------------------------------------------
    ------------------------------