cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
10591
Views
14
Helpful
28
Replies

How to subscribe to pub sub nodes in Finesse

yogeshkumarlog
Level 1
Level 1

I am trying to subscribe an agent to Team and Queue notification.

I have used(edited) code from non gadget sample.

The request captured from fiddler looks something similar to:

For Team Subscription:

POST /finesse/api/Team/8945/Users HTTP/1.1

Where 8945 is the agent ID

Response :

                HTTP/1.1 404 Not Found

                To test it I also tried User notification:

                                POST /finesse/api/User/8945 HTTP/1.1

                Response

                                HTTP/1.1 405 Method Not Allowed

                                Allow: GET,OPTIONS,HEAD,PUT

The added code to non gadget sample for team subscription:

  this.subscribeToTeam = function (agentId, resource, handler, errHandler) {

        var method = "POST",

        url = _webappPath + "/api/Team/" + agentId + "/Users",

        params = { "resource": resource };

        _sendReq(url, method, null, params, handler, errHandler);

};

Can someone please help me to subscribe to the new nodes for notification in Finesse?

1 Accepted Solution

Accepted Solutions

dlender
Level 6
Level 6

You do not subscribe via a POST message.  You have to send an iq message over the XMPP session to subscribe to a node.

 

For example:

 

<iq type='set' from='1001001@finessedevsup1.finesse.bxb'

to='pubsub.finessedevsup1.finesse.bxb'

id='sub9'>

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<subscribe node='/finesse/api/Team/5001/Users'

jid='1001001@finessedevsup1.finesse.bxb'/>

</pubsub>

</iq>

 

 

See chapter 7 Cisco Finesse Notifications section on Subscription Management in the Finesse WebServices Developer Guide: https://developer.cisco.com/docs/finesse/#!subscription-management 

View solution in original post

28 Replies 28

dlender
Level 6
Level 6

You do not subscribe via a POST message.  You have to send an iq message over the XMPP session to subscribe to a node.

 

For example:

 

<iq type='set' from='1001001@finessedevsup1.finesse.bxb'

to='pubsub.finessedevsup1.finesse.bxb'

id='sub9'>

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<subscribe node='/finesse/api/Team/5001/Users'

jid='1001001@finessedevsup1.finesse.bxb'/>

</pubsub>

</iq>

 

 

See chapter 7 Cisco Finesse Notifications section on Subscription Management in the Finesse WebServices Developer Guide: https://developer.cisco.com/docs/finesse/#!subscription-management 

Hi Lender,

Can you give sample to subscribe queue notification using  jabberwerx.js.

Thanks,
Arul

The only Finesse sample that uses jabberwerx.js is the nongadgetsample which does not include subscribing to nodes.

There is a  sample of using jabberwerx.js to send a message  in the Jabber tech center on DevNet

https://developer.cisco.com/site/collaboration/jabber/websdk/learn/im-and-presence-how-to/use-jabber-im-core-apis/

You would send an iq message using client.sendMessage(jid, message);  where message is in the form:

<iq type='set' from='1001001@finessedevsup1.finesse.bxb'

to='pubsub.finessedevsup1.finesse.bxb'

id='sub9'>

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<subscribe node='/finesse/api/Team/5001/Users'

jid='1001001@finessedevsup1.finesse.bxb'/>

</pubsub>

</iq>

Hello Lender,

I am using the same message format to subscribe queue notification,it is accepted without any error but i didn't get any events for this subscription message, please see my below logic. is it anything require apart from this?

JS Code:

successCallback: function () {

                //Get the server generated resource ID to be used for subscriptions.

                //alert(_jwClient.resourceName);

   

                 _finesse.setResource(_jwClient.resourceName);

                 try{

  

                 //alert("inside");

                 messageItem="<iq type='set' from='1003@techfinesse91.srvprcce.com' to='pubsub.techfinesse91.srvprcce.com'                     id='sub8'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscribe node='/finesse/api/Queue/1'                     jid='1003@techfinesse91.srvprcce.com'/> </pubsub> </iq>";

                 _jwClient.sendMessage("pubsub.techfinesse91.srvprcce.com",messageItem);

                 }

                 catch(ex)

                 {

                           console.log("error:"+ JSON.stringify (ex));

                     }

}

Post Message Format:

PostMessage.jpg

Response Message:

MessageResponse.jpg

Also clarify queue notification will work only with individual queue subscription(http://172.16.6.186/finesse/api/Queue/1)  or we can get entire user queue changes(http://172.16.6.186/finesse/api/User/1003/Queues).

Thanks,
Arul

Did you try it with a Supervisor agent? The User is not allowed to subscribe to Queues only a supervisor can do this using the javascript library.

Lender,

We are trying only supervisor agent with non-gadget application, as per this thread we sending iq message over the XMPP session.

For the same supervisor, we getting queue update events in default Cisco supervisor desktop queue statistics gadget.

Why we are not able to subscribe over the XMPP?


Thanks,

Arul Selvan B

It seems your subscription is successful and that you just arent getting Queue any notifications:  Did you try just doing a GET on the Queue to see if it is a valid Queue ID?

Also, I dont think the response message you posted  is the right message to be looking at.  I suggest you try the subscription with Poster and Pidgin first to make sure your subscription iq message is correct.

You also asked:

Also clarify queue notification will work only with individual queue subscription(http://172.16.6.186/finesse/api/Queue/1)  or we can get entire user queue changes(http://172.16.6.186/finesse/api/User/1003/Queues).

You need to get the list of queues using GET on  /finesse/api/User/1003/Queues and then subscribe to each queue using /finesse/api/Queue/<queueid>

I tried this using Poster and Pidgin and this iq worked for me

<iq type='result' id='purplecea37863' to='42070@ucc9finese10.ccpucc9a.local/cisco'/>

<iq type='set' from='42070@ucc9finese10.ccpucc9a.local' to='pubsub.ucc9finese10.ccpucc9a.local' id='sub9'>

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<subscribe node='/finesse/api/Queue/1007' jid='42070@ucc9finese10.ccpucc9a.local'/>

</pubsub>

</iq>

I got the following response: 

<iq type='result' id='sub9' from='pubsub.ucc9finese10.ccpucc9a.local' to='42070@ucc9finese10.ccpucc9a.local/cisco'>

<pubsub xmlns='http://jabber.org/protocol/pubsub'>

<subscription node='/finesse/api/Queue/1007' jid='42070@ucc9finese10.ccpucc9a.local' subscription='subscribed'>

<subscribe-options/>

</subscription>

</pubsub>

</iq>

I then changed the user's state to Not Ready.  I then got a notification when the User changed state.  I got the User notification and I got a Queue notification on 1007

<message from='pubsub.ucc9finese10.ccpucc9a.local' to='42070@ucc9finese10.ccpucc9a.local' id='/finesse/api/Queue/1007__42070@ucc9finese10.ccpucc9a.local__vB1rH'>

<event xmlns='http://jabber.org/protocol/pubsub#event'>

<items node='/finesse/api/Queue/1007'>

<item id='6BYBULjMhU9lMr7'>

<notification xmlns='http://jabber.org/protocol/pubsub'><Update>

  <data>

    <queue>

      <name>Lender_SG</name>

      <statistics>

        <agentsNotReady>1</agentsNotReady>

        <agentsReady>0</agentsReady>

        <agentsTalkingInbound>0</agentsTalkingInbound>

        <agentsTalkingInternal>0</agentsTalkingInternal>

        <agentsTalkingOutbound>0</agentsTalkingOutbound>

        <agentsWrapUpNotReady>0</agentsWrapUpNotReady>

        <agentsWrapUpReady>0</agentsWrapUpReady>

        <callsInQueue>0</callsInQueue>

        <startTimeOfLongestCallInQueue></startTimeOfLongestCallInQueue>

      </statistics>

      <uri>/finesse/api/Queue/1007</uri>

    </queue>

  </data>

  <event>PUT</event>

  <requestId></requestId>

  <source>/finesse/api/Queue/1007</source>

</Update></notification>

</item>

</items>

</event>

</message>

Thanks Lender, It's working good, only thing we have to call sendIQ method while using  jabberwerx.js.

JS Code:

_jwClient.sendIq("set","pubsub.techfinesse91.srvprcce.com","<pubsub xmlns='http://jabber.org/protocol/pubsub'><subscribe node='/finesse/api/Queue/3' jid='1003@techfinesse91.srvprcce.com'/></pubsub>",function(data){

  alert("success");

  });

Request Format:

<body xmlns="http://jabber.org/protocol/httpbind" sid="a070f2a4" rid="3042555085">

<iq id="iq13922824635680" xmlns="jabber:client" type="get" to="techfinesse91.srvprcce.com">

</iq>

<iq id="iq13922824635871" xmlns="jabber:client" type="get" to="techfinesse91.srvprcce.com">

</iq>

<iq id="iq13922824704102" xmlns="jabber:client" type="set" to="pubsub.techfinesse91.srvprcce.com">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<subscribe node="/finesse/api/Queue/3" jid="1003@techfinesse91.srvprcce.com"></subscribe>

</pubsub>

</iq>


<presence xmlns="jabber:client">
<c xmlns="http://jabber.org/protocol/caps" hash="sha-1" node="http://jabber.cisco.com/caxl" ver="VNC6fNwvCxe6FJfDJIpLryVJRwM="></c>

</presence>

</body>

Thanks,

Arul

Hi,

  I want to ask that is gadget to java app communication possible ? Foe example in gadget I am publishing data on a particular node and I want get this data after subscription through java app ?

Publishing Data in Gadgets: gadgets.Hub.publish("a.b.c.d.e.f", address);

Subscribing Data in Java App:

        final String publisherNodeID = "a.b.c.d.e.f";

        PubSubManager mgr = new PubSubManager(connection);

        //creating node which subcribes to finesse events

        LeafNode node;

        try {

            node = (LeafNode) mgr.getNode(publisherNodeID);

            System.out.println("Node Fetched!!!!");

        } catch (Exception ex) {

            System.out.println("Node Created!!!!");

            node = (LeafNode) mgr.createNode(publisherNodeID);

        }

        //an Item that has been, or will be published to a pubsub node.

        //An Item has several properties that are dependent on the configuration of the node to which it has been or will be published.

        //Defines the listener for items being published to a node.

        node.addItemEventListener(new ItemEventCoordinator<Item>());

        node.subscribe(myJID);

       

        System.out.println("Successfully Subscribed to node: " + publisherNodeID);

        //packet filter

        //Listener for Finese Notification

        PacketFilter filter = new MessageTypeFilter(Message.Type.normal);

        connection.addPacketListener(new PacketListener() {

            @Override

            public void processPacket(Packet packet) {

               

                System.out.println("Packet Received!!!");

             }

But Whenever I publish data through gadgets, data is not fetched in java app.

Gadget to java app communication is not possible.

A gadget can subscribe to a hub topic in the Finesse desktop. See the HubTopic sample gadget. This does not provide support for a Java app.

I think we can do this by using Managed

Hub<http://www.openajax.org/member/wiki/OpenAjax_Hub_2.0_Specification_Managed_Hub_Overview>.

I never worked with managed hub and I even don't have idea of this. I think

Gadget publish data on particular node on finesse server and in Java App we

first login agent in finesse environment and It tries to fetch(subscribe)

data on that node and I think there should be no issue in fetching that

because in java app we are in finesse environment when we connect and

login.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: