Google Wave Robot and gadget interaction

With the new Robot API version 2 is it possible to interact with the gadgets using robots. This will allow for some interesting integrations and will mean that the gadgets can be used to show the graphical information that needs to be displayed by a user. By using the robot to fetch and populate the data, you are also able to make the requests update other information than is possible using the social API.

I have created a small demo that shows how this can work out. Look at this video.

The code for the robot is the following.

  @Override
  protected String getRobotName() {
    return "DGR1";
  }

 
  @Override
  public void onWaveletSelfAdded(WaveletSelfAddedEvent event) {
    Blip blip = event.getWavelet().reply("\nHi everybody!");
    blip.append(new Gadget("http://dgrjava1.appspot.com/gadget.xml"));
  }  
  @Override
    public void onGadgetStateChanged(GadgetStateChangedEvent event) {
      Blip blip = event.getBlip();
      Gadget gadget = (Gadget) blip.getElements().get(event.getIndex());
     String count =  gadget.getProperty("count");
     
     blip.append("State changed changed " + count);
     gadget.setProperty("count", "56");
  }

Currently it is not possible with the Java api to update the gadget. But there is room for it in the gadget state information.

Bookmark and Share