Skip to content

VXML Style Voice Form for Adhearsion

March 31, 2009

The Adhearsion developer community continues to create new applications and components. codecoolAnd even more importantly, sharing them. The latest component addition to the line-up is a VoiceXML style Voice Form plugin for Adhearsion, created by @adzap and posted to GitHub.

You may new create your own compenent, include the Voice Form module and create extensive voice menus to your callers. Here is the classic Adhearison Simon example re-factored into a Voice Form:

class SimonGame
  include VoiceForm

  voice_form do
    setup do
      @number = ''
    end

    field(:attempt, :attempts => 1) do
      prompt :play => :current_number, :bargein => false, :timeout => 2

      setup do
        @number << random_number
      end

      validate do
        @attempt == @number
      end

      success do
        call.play 'good'
        form.restart
      end

      failure do
        call.play %W[#{@number.length-1} times wrong-try-again-smarty]
        @number = ''
        form.restart
      end
    end

  end

  def random_number
    rand(10).to_s
  end

  def current_number
    as_digits(@number)
  end
end

The readme and code are all available on GitHub here. Enjoy and many thanks to @adzap!

About these ads
One Comment leave one →
  1. March 31, 2009 1:43 pm

    Thanks for the write up Jason!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: