Copy one of the other robots to a new directory. Start with the weather example if the robot interacts with the web, or use the word example if it accesses a database.
It seems like a good idea to isolate the email/jms aspect of the robot from the worker bee part of it so I recommend two or more classes:
Start with the worker bean (WeatherBean or DictionaryBean) and chop out everything but the methods setText(), getText(), help(), toString() and main(). Adjust this class until:
OK, so now work on the robot class (copied from either WeatherMan or Dictionary, they are pretty much the same). They are fairly simple so not much can go wrong. In the onMessage() method, invoke the worker bean and call replyMessage () with the subject and response text. Override the ejbCreate() and ejbRemove() methods to set up and tear down anything necessary.
You can't really test this without deploying it so that's the next step. Call up DeployTool and create a topic. This is used below. The naming scheme I used was jms/xxxx where xxxx is usually the same as the bean. Open the Email Answering Service .ear file and say you want a new Enterprise Bean. Choose 'create a new jar' and give it a display name (unfortunately there's no way to name the jar when you do this). In the contents section add your classes plus supporting ones like WebBean and Robot. You can give a description too if you want.
Next choose Message-Driven bean type and for the 'Enterprise Bean class' choose the class that extends Robot. You can give a description too if you want.
Next choose 'Bean Managed' transactions, (that means none since we ignore them).
Next choose a 'Topic' destination type and choose the topic created above as the 'destination'.
Skip to the 'Resource Factories' page and create an entry here for the jms/QueueConnectionFactory with that as the jndi name, type javax.jms.QueueConnectionFactory, container authentication and shareable. I don't think it uses the user name and password.
Next add jmsOutbox as a resource environment reference with a coded and jndi name of jms/Outbox and type javax.jms.Queue.
Next you need to create a role to run as, and select it.
Adjust the EmailDispatcherBean Environment entry for "Subject Topic Map" to add the mapping between the email subject and the topic created above. Also add the topic as a Resource Environment Reference with the type Topic.
Redeploy the Email Answering Service and test it.