Posts Tagged ‘Google’

Creating dynamic voice apps that use Google’s App Engine, part 2

Friday, April 18th, 2008

googleappengine.jpgJust a brief update on my piece about how to use voice with Google’s App Engine… I now have been invited into the preview of Google’s App Engine, so I’ve created a second application on our Evolution platform with this one pointing to my shiny new GAE app at:

http://voicexmltest2.appspot.com/

For now, it’s the same (lame) python code, but the app does have it’s own phone numbers:

Direct Local # (857) 362-8430
PIN Access (800) 289-5570 then PIN: 9996075378
PIN Access (407) 386-2174 then PIN: 9996075378
Skype VoIP +99000936 9996075378
FWD VoIP **86919996075378
SIP VoIP sip:9996075378@sip.voxeo.net

Why didn’t I simply modify the original Evolution application? Well, I could have, but I figured this way I can also still experiment with the AppDrop.com application as well.

The nice thing with a true Google App Engine account is that I can use “appcfg.py” to automagically update the files up on the App Engine site, which is very slick. (Thanks, Google, for the invite!) Next week, my intent is to work with the python code to get it actually manipulating the XML… stay tuned… (and check my original article if you would like to experiment with voice and Google App Engine, too).

Technorati Tags:
, , , , , , , , , , , ,

Creating dynamic voice apps that use Google’s AppEngine (and Amazon’s EC2 via AppDrop), part 1

Tuesday, April 15th, 2008

Update 2008 Apr 18: I now have an App Engine account and have the app running there as well.


googleappengine.jpgCould Google’s AppEngine, the buzz of the developer world right now, be used to create voice applications? That was the question I asked myself and the answer is something you can test yourself by calling one of these numbers (since we support all these forms of calling):

Assuming I haven’t changed the app since writing this post, you should simply hear some text “Your magic number is (some number)…” and then a pointer to this blog site. If you call the number again, you’ll hear the text with a different number. And again and again.

So what’s going on here? Well, you have:

Got all that? :-) Let’s take a look at how the pieces fit together

Google’s AppEngine

Last week Google announced the release of their AppEngine developer tool that lets you run web applications on Google’s massive infrastructure. Basically, you develop your application (currently only in the python language), upload it to Google’s servers and let Google’s infrastructure take care of all the rest. In addition to their web server and distributed database, you also have access to using Google Accounts for usernames which means you don’t have to create your own usernames and passwords (although you are then obviously tied to Google for authentication).

This announcement was immediately the subject of a huge amount of buzz throughout the blogosphere and the web in general. Unfortunately, only the first 10,000 developers could get in to try it out. While they let 10,000 more developers in yesterday, I’m still not one of them. However, I could download the AppEngine SDK and, dusting off my rusty memory of python (which I used to do a lot with) put together a quick program that would dynamically generate a VoiceXML file.

If your browser will display an XML file as raw XML, you can see the result here:

http://voicexmltest.appdrop.com/

If your browser won’t display raw XML, here’s a screenshot of what it should look like:
voicexmlmagicnumberex1.jpg

Your number should be different because it is being randomly generated. If you refresh your browser you should now see a different number in the <prompt> text. I did all this locally using the AppEngine SDK, saw that it generated valid (and dynamic) VoiceXML, and then needed to figure out where to host this so that I could demonstrate the usage - without a Google AppEngine account.

Amazon’s EC2 and AppDrop.com

While I’ve been patiently waiting for Google to send me an email letting me into the AppEngine preview, I stumbled upon the news that Google’s App Engine had been ported to Amazon’s EC2 service. Developer Chris Anderson announced a new service called AppDrop.com which basically hosts a modified version of Google’s AppEngine code on Amazon’s EC2 service. It obviously doesn’t support all of Google’s services like the distributed database or Google Accounts for authentication, but it allows you to develop an app with the AppEngine SDK and then upload it to the AppDrop service. Philosophically, I found this an interesting demonstration that using the AppEngine SDK did not necessarily lock you in to Google’s platform.

More importantly to me, I could create a hosted AppDrop.com application now without yet having my Google AppEngine account (subject to the caveats that AppDrop.com is entirely a proof-of-concept, it may go away at anytime, etc, etc.). So I did. Here’s the steps:

  1. Download the modified Google AppEngine SDK from AppDrop.com. It’s essentially the same thing as the Google SDK but with modifications for the lack of support for Google’s database, accounts, etc.

  2. Create an app in the local SDK. (I just literally copied my files from the Google AppEngine SDK directory over into the AppDrop SDK directory.)
  3. Register an app on AppDrop.com. This was not entirely intuitive as nowhere on the main page does it tell you how to do this. However, if you go to the list of current applications, there is a “Make a new app” link that takes you through the process of creating a new account on the site and then registering the app.
  4. Create a gzipped tar file of your application to upload. Easiest way is on the command line go into the directory containing your app and type “tar -cvzf <appname>.tar.gz *“. (This is taken care of for you in the actual Google environment with “app_cfg.py”, but no such automated script is available for AppDrop.com yet, although they are working on one.)
  5. Upload the file via the AppDrop.com web interface. If it works you get a simple “Upload successful” page.
  6. Go to http://<appname>.appdrop.com/ to see the resulting app. For instance, http://voicexmltest.appdrop.com

With that, I now had a publicly hosted app developed on the Google AppEngine SDK.

Voxeo’s Evolution platform

The last step was to provide the phone interface to this voice app and for that I obviously used our Evolution platform. Using my free developer account (which anyone can get), I basically followed the steps of our Quick Start Guide:

  1. Once logged into Evolution, I clicked on “Application Manager”.
  2. I clicked on “Add Application”.
  3. For the development platform, I chose “Prophecy 8.0 - VoiceXML 2.1″
  4. On the next screen, I completed the form as follows:
    1. Entered a name of the application.

    2. In the “Start URL 1″ box, I entered the URL to my AppDrop.com application - including the trailing slash (very important!)
    3. Under “Application Phone Number” chose the region in which I wanted a phone number. (If you don’t do this, you can still access your application via SIP or Skype, but not direct-dial from the PSTN. And yes, for the free accounts we only give out US phone numbers.)
  5. I clicked the “Create Application” button and my application was done.

Here’s a screen shot of that part of the screen for my app:
evolutionappdropexp.jpg

Do note again that I included the trailing slash on “http://voicexmltest.appdrop.com/”.

If I click on the “Phone Numbers” tab I can see the various numbers that I can use to call into this application:
evolutionappdropexpnumbers.jpg

That’s it! Assuming you are generating correct VoiceXML code, when you call into those numbers you should hear the voice app you created.

Show Me The Code!

So if you’ve read this far I imagine you probably want to see the actual code I wrote, eh?

Well, there are two files needed in a Google AppEngine SDK directory. First you need a file called “app.yaml” that simply provides the name of your app and the name of the main python file (here brilliantly called “main.py”):

application: voicexmltest
version: 1
runtime: python
api_version: 1

handlers:
- url: .*
  script: main.py

The second file is the “main.py” python file (which could be called anything as long as it matches what is in the app.yaml file). To be honest, my file is embarrassingly lame as a python app goes but as long as you recite “Remember this was a quick lunch-time hack as a proof of concept”, here it is:

#!/user/bin/env/python
import random

def main():
  print '''<?xml version="1.0" encoding="UTF-8"?>
<vxml version = "2.1" >
  <form>
    <block>
    <prompt>
'''
  print "Hello! Your magic number today is %d. " % random.randrange(100)
  print '''
     To learn more about this application, please visit blogs dot voxeo dot
     com. Thank you for calling this app.
    </prompt>
    </block>
  </form>
</vxml>
'''

if __name__ == "__main__":
  main()

Like I said, it’s a very simple app that really doesn’t even remotely begin to demonstrate the power of either python or VoiceXML. (Remember “quick proof-of-concept”.) For those not familiar with python or VoiceXML, here is what the main() function does:

  • prints out the first half of the VoiceXML file

  • prints out the dynamically generated part with a random number
  • prints out the second half of the VoiceXML file

Basically a glorified “Hello, world!” program with a random number thrown in. If you’re not familiar with the python construction I’m using here to print these large blocks of text, what I’m doing is putting three single apostrophes together to mark the beginning of the block of text and then three single apostrophes at the end to close off the block. It’s a great way to do simple hacks like this one. :-)

Next Steps

So with the embarrassment of that python file out of the way and now that I’ve proven to myself that you can develop voice apps using Google’s AppEngine (at least via AppDrop), what’s next? Well, when I next get a chance to work on it, I’m going to do two things. First, I’ll do more with VoiceXML, since there’s so much more it can do. Maybe add in some speech recognition, multiple call paths, maybe even upload some small audio files for prompts. Perhaps I’ll play with some outbound dialling and call transfer. Or wrap the VoiceXML inside of a Call Control XML (CCXML) app.

Second, and perhaps more useful to demonstrate Google’s AppEngine, I want to change the python code to actually manipulate the XML rather than simply printing out the XML code as text. There’s a great amount that can be done with python and XML, and even a book on the subject (which happens to be on my bookshelf), so the resources are out there.

In the meantime, though, I would be curious to see what any of you all can do with these pieces. What do you think about using Google’s App Engine to host applications in this way? If you can easily use a language like python to manipulate data and dynamically generate voice apps (using VoiceXML), what can you think of to do with it? What kind of apps will you write?

Do any of you want to give it a try? The steps are really quite simple:

  1. Download either the Google App Engine SDK, or, if like me you don’t have a Google App Engine account yet, download the AppDrop.com modified SDK.
  2. Write your python app locally (Google has intructions and examples) that generates valid VoiceXML (we have tutorials there).
  3. Upload the app to either Google or AppDrop.com.
  4. Create an Evolution account if you don’t have one and follow the steps above to create the app on our service.
  5. Call it up and see how it works.

If you do anything cool with it, please definitely do leave a comment as I’d love to check out what you do (and hey, maybe even spotlight it here on the blog if you are open to that).

With that, I’m going to turn back to experimenting with python and XML… (oh, and waiting for my App Engine invite… hint, hint, Google!)

Technorati Tags:
, , , , , , , , , , , , , , ,