In this tutorial we will create a simple Google Wave robot which sends email notifications when a blip has been submitted.
Before we start.
This tutorial is an extension onto my tutorial “Create your First Google Wave Robot with Python in 15 Minutes“. Although this is not necessary to read to complete this tutorial, It will be helpful.
Robot Description
Our Robot will, when added, send an email off to the owner saying it was successfully added into the wave. It will then wait for any blips and send an email with the contents of the blip and the author of the blip.
This means we need 2 event handlers. Both “WAVELET_SELF_ADDED” and “BLIP_SUBMITTED”.
Let’s get into it
We will just create a simple Google Wave Robot to work off.
from waveapi import events from waveapi import model from waveapi import robot if __name__ == '__main__': myRobot = robot.Robot('myEmailRobot', image_url='http://corythompson.net/wp-content/uploads/CoryThompson.jpg', version='1', profile_url='http://corythompson.net/') myRobot.Run()
Because we are using the mail feature we need to add an extra import. And We will add some variables. Your from address has to be the email address you signed up to App Engine with. So most the time it will end with @gmail.com.
from google.appengine.api import mail TO_ADDRESS = "cory@corythompson.net" FROM_ADDRESS = "coryjthompson@gmail.com"
Next we will create an event handler for “WAVELET_SELF_ADDED” and “BLIP_SUBMITTED”. This goes just above myRobot.Run()
myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted) #Triggered when BLIP is submitted. myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded) # Triggered when Robot Is Added
Now all that is left is the main logic. We will first create the OnRobotAdded function. This goes just bellow our variables “TO_ADDRESS” and “FROM_ADDRESS” variables.
def OnRobotAdded(properties, context): """Invoked when the robot has been added.""" root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText("Sending email updates to " + TO_ADDRESS) # Notifies Wave Users mail.send_mail(TO_ADDRESS, FROM_ADDRESS, "EmailBot Added", "You have been added to a google wave conversation") #Sends email to bot owner.
Last but definitely not least is adding the “OnBlipSubmitted” event.
def OnBlipSubmitted(properties,context): blip = context.GetBlipById(properties['blipId']) contents = blip.GetDocument().GetText() #Get's contents of blip mail.send_mail(TO_ADDRESS, FROM_ADDRESS, "EmailBot Notification", blip.GetCreator() + " says " + contents) # Sends email
And the whole code all at once
from waveapi import events from waveapi import model from waveapi import robot from google.appengine.api import mail TO_ADDRESS = "cory@corythompson.net" FROM_ADDRESS = "coryjthompson@gmail.com" def OnRobotAdded(properties, context): """Invoked when the robot has been added.""" root_wavelet = context.GetRootWavelet() root_wavelet.CreateBlip().GetDocument().SetText("Sending email updates to " + TO_ADDRESS) # Notifies Wave Users mail.send_mail(TO_ADDRESS, FROM_ADDRESS, "EmailBot Added", "You have been added to a google wave conversation") #Sends email to bot owner. def OnBlipSubmitted(properties,context): blip = context.GetBlipById(properties['blipId']) contents = blip.GetDocument().GetText() #Get's contents of blip mail.send_mail(TO_ADDRESS, FROM_ADDRESS, "EmailBot Notification", blip.GetCreator() + " says " + contents) # Sends email if __name__ == '__main__': myRobot = robot.Robot('myEmailRobot', image_url='http://corythompson.net/wp-content/uploads/CoryThompson.jpg', version='1', profile_url='http://corythompson.net/') myRobot.RegisterHandler(events.BLIP_SUBMITTED, OnBlipSubmitted) myRobot.RegisterHandler(events.WAVELET_SELF_ADDED, OnRobotAdded) myRobot.Run()
That wraps up this tutorial, upload and test it out! If your having and problems just comment and ill help you with anything as quick as possible.

Computer manufacturers are coming out with expensive home media servers which work just as well as an old, dusty computer with some FREE software. In this article we will cover how to build your own home media server with the capabilities of streaming to most devices on your network such as PS3, Xbox 360 and other computers.
