EppsNet Labs: VoiceXML RSS Reader


The Big Picture

We’re going to build application that takes RSS data — specifically the EppsNet.com feed — as input, and outputs a VXML file that can be read and spoken by a VoiceXML browser.

The RSS Source Format

The general structure of the EppsNet feed — or any RSS 2.0 feed — looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<rss version="2.0"

    <title>EppsNet: Notes from the Golden Orange</title>
    <description>Online journal based in Orange County, CA. 
        Hilarious anecdotes tempered by the icy chill of certain 
    <pubDate>Fri, 05 Oct 2007 03:51:21 +0000</pubDate>

Each item within the RSS feed has a format that looks (slightly simplified) like this:

      <title>Post Title</title>
      <pubDate>Fri, 05 Oct 2007 03:51:21 +0000</pubDate>



        Item summary
        Full item content

VXML Output

Consult the VoiceXML 2.1 specification for more details, but the output we want will look like this:

<?xml version="1.0" encoding="utf-8" ?>
<vxml version="2.1">
  <form id="MainMenu">
    <field name="select_num" type="digits">
        EppsNet: Notes from the Golden Orange
        <break size="small"/>
      <prompt>Please select a story from the following list.</prompt>
        1: Post Title 1
        <break size="small"/>
        5: Post Title 5
        <break size="small"/>
        Please select a number.
        Please select a valid number.
      <assign name="selection" expr="select_num"/>
      <if cond="selection =='1'">
          Post Title 1. Post summary goes here [...]
          <break size="small"/>
        <elseif cond="selection =='5'"/>
          Post Title 5. Post summary goes here [...]
          <break size="small"/>
      <clear namelist="select_num"/>

What this will do when processed by a VoiceXML browser is:

  1. Say the title of the RSS feed.
  2. Offer the listener a numbered list of post titles to select from.
  3. Parse the user’s selection, by either voice or touch-tone input.
  4. Read out the selected post summary.
  5. Clear the input variable and offer the opportunity to select another item.

Generating VoiceXML from RSS

Because this is a WordPress site, we’re going to use PHP for the task of converting RSS input to VXML output. To simplify the task of parsing the input, we’ll use MagpieRSS, an RSS parser written in PHP.

The main loop in the code below processes up to 5 RSS items and simultaneously builds up two strings, one for the selection prompts and one for the item details.

/* We need this for MagpieRSS */
require_once 'rss_fetch.inc';

/* Read the RSS feed */
$url = 'http://eppsnet.com/feed';
$feed = fetch_rss($url);

$selection = '';
$detail = '';
$counter = 0;

$selection .= '<form id="MainMenu">';
$selection .= '<field name="select_num" type="digits">';
$selection .= '<prompt>';
$selection .= $feed->channel['title'] . '<break size="small"/>';
$selection .= '</prompt>';
$selection .= '<prompt>';
$selection .= 'Please select a story from the following list.';
$selection .= '</prompt>';

foreach ($feed->items as $item ) {
    /* Limit output to 5 items */
    if ($counter++ >= 5)

    if ($counter == 1)
        $detail .= '<filled>';
        $detail .= '<assign name="selection" expr="select_num"/>';
        $detail .= "<if cond=\"selection =='$counter'\">";
        $detail .= "<elseif cond=\"selection =='$counter'\"/>";
    $detail .= sprintf('<prompt>%s. %s<break size="small"/></prompt>',

    $selection .= sprintf('<prompt>%d: %s<break size="small"/></prompt>',

$selection .= '<noinput>Please select a number. 
$selection .= '<nomatch>Please select a valid number. 
$selection .= '</field>';

$detail .= '</if>';
$detail .= '<clear namelist="select_num"/><reprompt/>';
$detail .= '</filled></form>';

/* Output the VXML */
echo '<vxml version="2.1">';
echo $selection;
echo $detail;
echo '</vxml>';

Try It

I put the PHP script at http://eppsnet.com/lab/vxml but the output is not very interesting in a regular browser. Fortunately, Voxeo offers a free service that maps voice applications to phone numbers. You give them the URL of your voice app and they’ll point a phone number to it.

So — if you pick up the phone, call 800-289-5570 and enter PIN 9992002320, the Voxeo application will fetch the VXML output from our PHP script and read selected excerpts from the EppsNet feed to you over the phone.

Try it!


The VXML output doesn’t contain the entire contents of each post, just the truncated version from the RSS <description> field. I tried using the <content:encoded> field instead but some markup constructs choked the Voxeo application. I think I could get it to work if I spent enough time on it, but for now, I’ve decided to leave it as an exercise for the reader.

  1 comment for “EppsNet Labs: VoiceXML RSS Reader

  1. Avatar
    7 Nov 2007 at 4:04 pm

    Now… that’s bitchen!!!
    Good work.

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: