Hit or Miss

Blogger, VoiceXML, and TellMe Studio

If you’re looking for info on how to code Voice-XML applications using TellMe Studio, check out their tutorials.

The Basics

This document will show you how to use Blogger, VoiceXML, and TellMe Studio to syndicate your weblog over the telephone.

Why would I want to do this?

“What could you possibly be thinking?” you may say. “That sounds complex!” The benefit of syndicating your blog in VoiceXML is that anyone will be able to listen to the content over a 1-800 telephone number.

Requirements:

This script given below assumes that you have already read the Blogger, PHP, XML tutorial and set up those files so that Blogger outputs a specific type of XML file.

But there are other ways of creating the necessary VoiceXML file that TellMe uses. The telephone version of my weblog gets it data from my SQL server. To create your own VoiceXML file, take a look at TellMe’s Code Library (that’s how I figured out how to do this).

Word of Caution:

I am far from being a professional programmer. The following bits of code seem to work for me with my server (running Red Hat 7.0), but I can’t predict how they will work on your system.

Creating the VoiceXML file

After setting up all the files in the Blogger, PHP, XML tutorial, copy the following code into a file name phone_weblog.php.

<?php

	header("Content-Type: text/xml");
	header("Pragma: no-cache");
?>
<!DOCTYPE vxml
PUBLIC "-//Tellme Networks//Voice Markup Language 1.0//EN"
"http://resources.tellme.com/toolbox/vxml-tellme.dtd">
<vxml application="http://resources.tellme.com/lib/universals.vxml">
<form>
<block>
<pause>500</pause>
<audio src="http://www.hit-or-miss.org/xml/phone.wav">Welcome to the audio version
of this weblog.  Here are the last 5 entries.</audio>
<pause>1000</pause>
<?
	# Include the RAX library
	include( "prax.php" );
	# Create new RAX objectS
	$rax = new RAX();
	$rec = new RAX();
	# Open the XML document
	$rax->openfile("current.xml");
	# Select the individual record delimiter
	$rax->record_delim = 'entry';
	# Start parsing the XML document
	$rax->parse();
	# Read the first record
	$rec = $rax->readRecord();
	for ($count = 0; $count < 5; $count++)
	{
		$row = $rec->getRow();
		$body = $row["body"];
		$time = $row["time"];
		$author = $row["author"];
		#you can uncomment these lines if you'd like to use these variables.
		#$author_email = $row["author_email"];
		#$author_url = $row["author_url"];
		#$id_num = $row["id"];
		#$permalink = $row["permalink"];
		# this gets rid of any html tags in your body of the entry
		$body = strip_tags($body);
		print	"<audio>Posted on $time by $author.</audio>n<pause>500</pause>nn";
		print	"<audio><![CDATA[$body]]></audio>n<pause>1000</pause>nn";
		$rec = $rax->readRecord();
	}
?>
<audio>Goodbye and thank you for calling.</audio>
<pause>500</pause>
<goto next="_home"/>
</block>
</form>
</vxml>

This will output a file that looks like this (If you’re not running IE 4+, you’ll need to save this file to your hard drive and open it in an editor to see it).

Note that we’re storing the post bodies in a CDATA section. This will allow you to store “bad” HTML in there. We’ll be transforming it with PHP on the server-side, so you won’t need to worry about this part being parsable.

Basically, what we are doing is putting text to be spoken in between <audio></audio> tags. We can also use <audio src=”http://www.your-server.com/file.wav”> to specify the location of .wav files we would like to play over the phone. Also, you can use <pause></pause> to insert pauses. Thus, you can alter the file above to include a welcome and goodbye message.

Registering with TellMe

The next step is to register for an account on TellMe Studio at studio.tellme.com.

When you have an account and are logged in, go to “My Extensions” and enter the URL of your phone_weblog.php file (and make sure that “Enable my Extension” is checked).

And now you should be in business! Call 1-800-555-Tell, say “Extensions,” enter your extension number, and then you should hear your weblog read to you.

Conclusion and Ackowledgments

Thanks to all the wonderful people at Blogger and TellMe for making such cool tools.