12.18
You have written a Google Wave Robot, uploaded it on AppEngine, and it does not seem to behave the way you expected? You would not be searching the Internet if it was working, would you?
First, you are not alone. The robot API appears to be changing, and I have observed changes in the amount of information my robots receive, over time. The best way to figure out what is going on with the robot is to look at the raw data sent by the Wave server to the robot. These messages are remote procedure calls encoded in JSON (jsonrpc).
This post assumes that the Google Wave Robot is deployed on AppEngine. At the time of writing this post, this is the only avenue for deploying Wave Robots.
To see the raw data transmitted to a Wave Robot, one must:
- Enable the robot to record FINEST log messages
- Capture the logs from the AppEngine web site
- Decode the JSON message in human readable format
This post deals with 1 and 3.
Enable FINEST logging
In your robot project, there is a properties file used to configure the logger. In general, this file is located in …/WEB-INF/logging.properties This location can change, since it is declared in a file called …/WEB-INF/appengine-web.xml. If you can not find the logging properties files, inspect the appengine-web.xml file. It should look like this:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>myCoolRobotName</application>
<version>0</version>
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
If the system property called “java.util.logging.config.file” is not present, then you should add it and create the “logging.properties” file. If the property already exists, then you have a clue where the file can be found.
The “logging.properties” file should contain something as follows:
# (All App Engine logging is through java.util.logging by default).
#
# To use this configuration, copy it into your application's WEB-INF
# folder and add the following to your appengine-web.xml:
#
# <system-properties>
# <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
# </system-properties>
#
# Set the default logging level for all loggers to WARNING
.level = FINEST
# Set the default logging level for ORM, specifically, to WARNING
DataNucleus.JDO.level=WARNING
DataNucleus.Persistence.level=WARNING
DataNucleus.Cache.level=WARNING
DataNucleus.MetaData.level=WARNING
DataNucleus.General.level=WARNING
DataNucleus.Utility.level=WARNING
DataNucleus.Transaction.level=WARNING
DataNucleus.Datastore.level=WARNING
DataNucleus.ClassLoading.level=WARNING
DataNucleus.Plugin.level=WARNING
DataNucleus.ValueGeneration.level=WARNING
DataNucleus.Enhancer.level=WARNING
DataNucleus.SchemaTool.level=WARNING
The trick is to change the property called “.level” to a value of “FINEST”. By default, most example give a value of “WARNING” to this property.
Once this change is done, upload the robot on AppEngine, again, for the new logging level to take effect.
Capturing the logs
Once the robot is uploaded on AppEngine, interacting with a wave that includes the robot should generate messages sent to it. Using the AppEngine administrative page for the robot, navigate to the “logs” page. Changing the filter to “INFO” should refresh the page with a number of “I” icons. Those are the information entries in the logs. Some of those should display the incoming events and outgoing operations.
Copy the large JSON object from the incoming events into the clip board.
Format JSON for a human
A number of online services will readily translate JSON to a more readable format. One of those is: http://jsonformatter.curiousconcept.com/ Pasting the content obtained in the previous step into the web form and formatting should give you the full picture of the information available to the robot.
[...] When a robot receives a set of events from the Wave server, it has the chance to return a number of operations to be executed. This is the opportunity to modify content of the Wave. Techniques to observe the discussion between a Wave server and a robot are explained in another post. [...]
Today we launched a new version of the Robots API, and are effectively deprecating the old version, since the new one can do everything that the old one can, plus more.
More info on the new API is in the launch blog post:
http://googlewavedev.blogspot.com/2010/03/introducing-robots-api-v2-rise-of.html
We are still linking to your article from the documentation “Articles” page, but we may remove the link soon, to reduce developer confusion and to encourage more use of the new API.
We hope that you will find the time to try out this new API and port your article to utilize it, so that developers can continue learning from you. If you do port your article, please let us know.
We also hope you like this new API.
Thanks!