VXML Style Voice Form for Adhearsion

2009 March 31

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!

One Response leave one →
  1. 2009 March 31

    Thanks for the write up Jason!

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS