Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
README.textile
bad_jokes_dialogue.rb
itunes_dialogue.rb
magic_eight_ball_dialogue.rb
time_dialogue.rb
twitter_dialogue.rb
weather_dialogue.rb

README.textile

This is the directory for contributed examples.

They should always be of the form:

  # If using the gem, replace with:
  #
  # require 'rubygems'
  # require 'james'
  require File.expand_path '../../lib/james', __FILE__

  class ItunesDialogue

    include James::Dialogue

    # You dialogue definitions go here.

  end

  # This line is for running it standalone.
  #
  James.listen

One example is the following simple one:

  # If using the gem, replace with:
  #
  # require 'rubygems'
  # require 'james'
  require File.expand_path '../../lib/james', __FILE__

  class ItunesDialogue

    include James::Dialogue

    def initialize
      # Usually though it's a good idea to set it up in the actions:
      # @setup_thing ||= Thing.new
      # @setup_thing.do_something
      #
      @setup_thing = Thing.new
    end

    hear 'My useful initial phrase' => :my_initial_state
    state :my_initial_state do
      hear 'something'                   => :next_state
      hear 'something and stay in state' => ->(){ "I am saying this but staying in this state" }
      into do
        "Say something on entering"
      end
      exit do
        "Say something on exiting"
      end
    end

  end

  # This line is for running it standalone.
  #
  James.listen

Please see the many examples in this folder.

Something went wrong with that request. Please try again.