Skip to main content
This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.
 
developerWorks
AIX and UNIX
Information Mgmt
Lotus
New to Lotus
Products
How to buy
Downloads
Live demos
Technical library
Training
Support
Forums & community
Events
Rational
Tivoli
WebSphere
Java™ technology
Linux
Open source
SOA and Web services
Web development
XML
My developerWorks
About dW
Submit content
Feedback



developerWorks  >  Lotus  >  Forums & community  >  IBM Sametime Forum

IBM Sametime Forum

developerWorks

  

PreviousPrevious NextNext


Jason S Keith 1.Jul.15 07:18 PM a Web browser
Developer Toolkits 8.5.2 IFR1 Windows


Hi. I'm trying to develop a ST Bot in Java. The bot captures the userid and then uses it to lookup a document in a lotus notes database, and return information from a Notes document.

The bot is currently recognising that a chat window has been opened, and then it executes the Notes doc lookup and returns a response. However after that I get a warning message, and the bot does not listen or accept any other input in the chat window that has been opened:

com.lotus.sametime.im.Im dispatchEvent WARNING: IM contains no listeners. IM event [ImEvent.IM_DATA_RECEIVED] dropped!

I've attached my code for the class (its not efficient but at the moment I'm just trying to get the core function working, and I've removed sensitive info like passwords). I'd be grateful for any help on rectifying this issue.

import com.lotus.sametime.awareness.*;
import com.lotus.sametime.community.*;
import com.lotus.sametime.core.comparch.*;
import com.lotus.sametime.core.constants.*;
import com.lotus.sametime.core.types.*;
import com.lotus.sametime.im.*;

import lotus.domino.*;
import lotus.domino.Session;

import java.util.*;

public class VerseBotResponder implements LoginListener, ImServiceListener, ImListener, Runnable{

CommunityService commService;
InstantMessagingService imService;
STSession stsession;
Thread engine;
Session s;
Session session;
Database db;
View view;


public VerseBotResponder(String serverName, String userId, String password) {
try {

stsession = new STSession("VerseBotSession");


System.out.println("Got a new ST Session");

stsession.loadSemanticComponents();
stsession.start();

System.out.println("Loaded Components and Started the Session");

commService = (CommunityService)stsession.getCompApi(CommunityService.COMP_NAME);

// Set client login type, find login types at:
// https://www-304.ibm.com/support/docview.wss?uid=swg21114318
// 0x130C​ = Sametime Connect 8.5.1
Short LoginType = 0x143b;

commService.setLoginType(LoginType);



} catch (DuplicateObjectException e) {
e.printStackTrace();
return;
} catch (Exception e) {

e.printStackTrace();
return;
}


commService.addLoginListener(this);
System.out.println("added a login listener");
//commService.loginByPassword(serverName, userId, password);
//commService.loginByToken(serverName, userId, password);
commService.loginByPassword(serverName, userId, password);
System.out.println("Called LoginByPassword");


}

@Override
public void dataReceived(ImEvent e) {
// TODO Auto-generated method stub
System.out.println("Data Received");
}

@Override
public void imClosed(ImEvent e) {
// TODO Auto-generated method stub
e.getIm().removeImListener(this);
}

@Override
public void imOpened(ImEvent e) {
// TODO Auto-generated method stub
System.out.println("IM OPENED");

}

@Override
public void openImFailed(ImEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public void textReceived(ImEvent e) {
// TODO Auto-generated method stub

System.out.println("Text Received");
String userID = e.getIm().getPartnerDetails().getId().getId();
System.out.println("userID = " + userID);

e.getIm().sendText(false, "You entered some text, but you are still: " + userID);

}

@Override
public void imReceived(ImEvent e) {
// TODO Auto-generated method stub

String provisionedstatus = "";

System.out.println("IM RECEIVED");
String userID = e.getIm().getPartnerDetails().getId().getId();
System.out.println("userID = " + userID);

//e.getIm().sendText(false, "Your userid is: " + userID);

try {

// Set up the Notes Connection
//Session session = NotesFactory.createSession("localhost", "Jason Keith", "Jasons Dev");
NotesThread.sinitThread();
//Session session = NotesFactory.createSession();
session = NotesFactory.createSessionWithFullAccess("password removed");
System.out.println("Created the Thread and Session");
db = session.getDatabase(null, "vp\\scnmail.nsf");
System.out.println("Got the database");
view = db.getView("ProvisionedByInternetID");

if (view!=null) {

Document doc = view.getDocumentByKey(userID,true);

if (doc!=null) {

System.out.println("I found you");
provisionedstatus = "However, I found that you have been provisioned for Verse, which means your mail should already be migrated to Verse";

} else {

provisionedstatus = "I couldn't find a record for you, which means you are not currently being migrated";

}

} else {

provisionedstatus = "I can't seem to find the Lotus Notes Database that has your information";

}



System.out.println(session.getUserName());
System.out.println(db.getSize());

} catch(Exception ex) {
ex.printStackTrace();
}
e.getIm().sendText(false, "Hi there " + userID + " and thanks for using the VerseBot");
e.getIm().sendText(false, "This is a trial bot designed to lookup your status on the road to migrating to Verse");
e.getIm().sendText(false, "Please don't try to initiate conversation with me, I'm not that talkative [sophisticated]");
e.getIm().sendText(false, provisionedstatus);
e.getIm().sendText(false, "For more help or information on the Verse Migration, or to contact a local support person, please follow this link <provide a url>");

}




@Override
public void loggedIn(LoginEvent arg0) {
// TODO Auto-generated method stub
System.out.println("Logged In");

STUserStatus status = new STUserStatus(STUserStatus.ST_USER_STATUS_ACTIVE, 0, "Verse AP Support Bot - Test Only");
arg0.getLogin().changeMyStatus(status);

imService = (InstantMessagingService)
stsession.getCompApi(InstantMessagingService.COMP_NAME);
imService.registerImType(ImTypes.IM_TYPE_CHAT);
imService.addImServiceListener(this);

}

@Override
public void loggedOut(LoginEvent arg0) {
// TODO Auto-generated method stub

}

public void start() {
if (engine == null) {
engine = new Thread(this, "VerseBotThread");
System.out.println("Created the new thread called engine");
engine.start();
System.out.println("Started the engine");
}
}

@Override
public void run() {
// TODO Auto-generated method stub
System.out.println("Got into the run method of this class");
Thread myThread = Thread.currentThread();
System.out.println("putting the thread to sleep");
while (engine == myThread) {
try {
Thread.sleep(1000);

} catch (InterruptedException e) {
System.out.println("Thread interrupted");
} catch (Exception e) {

System.out.println("Yep it died here");

}
}

}

public static void main(String [] args){

VerseBotResponder vbb = new VerseBotResponder("messaging.ibm.com", "verseap@us.ibm.com", "stbot15v");
System.out.println("Created New VerseBotResponder");
vbb.start();
}

public void finalise () {

stsession.stop();
stsession.unloadSession();
}

}






Error in Java ST BOT: WARNING: IM c... (Jason S Keith 1.Jul.15)
. . RE: Error in Java ST BOT: WARNING: ... (Carl Tyler 1.Jul.15)
. . . . RE: Error in Java ST BOT: WARNING: ... (Jason S Keith 1.Jul.15)
. . . . . . Great eom> (Carl Tyler 2.Jul.15)





  Document options
Print this pagePrint this page

 Search this forum

  Forum views and search
Date (threaded)
Date (flat)
With excerpt
Author
Category
Platform
Release
Advanced search

 RSS feedsRSS
All forum posts RSS
All main topics RSS
More Lotus RSS feeds

Resources

 Resources
Forum use and etiquette
Native Notes Access
Web site Feedback

Lotus Support

 Lotus Support
IBM Support Portal - Lotus software
Lotus Support documents
Lotus support by product
Lotus support downloads
Lotus support RSS feeds

Wikis

 Wikis
IBM Composite Applications
IBM Mashup Center
IBM Connections
IBM Connections Cloud Developers
IBM Docs
IBM Forms
IBM Mobile Connect
IBM Sametime
IBM SmartCloud for Social Business
IBM Web Experience Factory
Lotus Domino
Lotus Domino Designer
Lotus Expeditor
Lotus Foundations
Lotus iNotes
Lotus Instructor Community Courseware
Lotus Notes
Lotus Notes & Domino Application Development
Lotus Notes Traveler
Lotus Protector
Lotus Quickr
Lotus Symphony
IBM Web Content Manager
WebSphere Portal

Lotus Forums


 Lotus Forums
Notes/Domino 9.0
Notes/Domino 8.5 + Traveler
Notes/Domino XPages development forum
Notes/Domino 8
Notes/Domino 6 and 7
IBM Connections
IBM Mobile Connect
IBM Sametime
IBM SmartCloud Notes
Lotus Enterprise Integration
Lotus Protector
Lotus Quickr
Lotus SmartSuite