powered by Jive Software

How to connect with Java to FastPath workgroup and receive responses from Agent

Hi,

OPENFIRE 4.1.1
Smack API 4.2.0

I’m trying to connecto to an Openfire Fastpath workgroup and chat with an agent from Java, i could reach an Agent and he will accept the conversation, then he answers me, but i dont’ receive any response so i cant’ chat with him,

This is my code,

SERVIDOR = “10.1.0.189”

// this is a listener that will answer the message received
org.jivesoftware.smack.chat2.ChatManager chatManager = org.jivesoftware.smack.chat2.ChatManager.getInstanceFor(connection);
chatManager.setXhmtlImEnabled(true);
chatManager.addIncomingListener(new IncomingChatMessageListener() {

			public void newIncomingMessage(EntityBareJid from, Message message, org.jivesoftware.smack.chat2.Chat chat) {
				System.out.println("New message from " + from + ": " + message.getBody());
				System.out.println("Escriba mensaje de respuesta: ");
				Scanner s = new Scanner(System.in);
				String mensaje;
				mensaje = s.nextLine();							
				try {
					chat.send(mensaje + " , hora del mensaje:  " + new Date());
				} catch (NotConnectedException e) {
					e.printStackTrace();
				} catch (InterruptedException e) {
					e.printStackTrace();
				} finally {
					s.close();
				}
			}
		});


		EntityBareJid jidp = JidCreate.entityBareFrom("soporte@workgroup." + SERVIDOR );

presence = new Presence(Presence.Type.available);
jidp = JidCreate.entityBareFrom( “soporte@workgroup.” + SERVIDOR );
presence.setTo(jidp);
presence.setStatus(“Disponible”);
connection.sendStanza(presence);

		String tecla = "soporte@workgroup." + SERVIDOR ;
		EntityBareJid jid2 = JidCreate.entityBareFrom(tecla);
		org.jivesoftware.smack.chat2.Chat chat2 = chatManager.chatWith(jid2);
			
		chat2.send("join"); 
		chat2.send("yes");
		chat2.send("pedro");
		chat2.send("pregunta desde java");

// At this point the Agent recevies a chat request, with user “pedro” and question “pregunta desde java”.
// then i would expect the agent write something and the chatlistener with receive the message, but it won’t happen.

Thanks in advance
Horacio

I’d suggest you read XEP-0142.

I can’t see that you’ve joined the workgroup following the steps described in XEP-0142. This is needed before you can chat with an agent. Depending on the configuration of the Openfire Fastpath plugin you may also need to supply the required/configured meta data.

Some example code and sequence of steps can be found here.

Thanks a lot grutto!

Cheers