Sha256: ffddf65144c10da4b16e198a4cedf783112b01dfbf6b20c57a8fce9f77dd118e

Contents?: true

Size: 1.01 KB

Versions: 7

Compression:

Stored size: 1.01 KB

Contents

class PushupBot
  include Sinbotra::Messenger::Handler

  enable_get_started!

  get_started do
    start_conversation(:onboarding)
  end

  hear(/hi|hello|yo/i) do |bot, _msg|
    bot.say "Hello there!"
    bot.start_conversation(:onboarding, msg)
  end

  hear do |bot, msg|
    intent = get_intent(msg.text)
    if conversations.include?(intent)
      bot.start_conversation(intent, msg)
    else
      bot.say next_dont_understand_phrase
    end
  end

  conversation :onboarding do |convo|
    convo.step :ask_name do |_msg|
      convo.say "Hi there!"
      convo.say "What's your name?"
      convo.next_step!
    end

    convo.step :ask_height do |msg|
      convo.store!(:name, msg.text)
      convo.say "Great #{convo.recall[:name]}. How tall are you?"
      convo.next_step!
    end

    convo.step :done do |msg|
      convo.store!(:height, msg.text)
      convo.say "Thank you for the info"
      typing 1
      convo.say "See you around!"
      convo.done!
    end
  end
end

Sinbotra::Bot.add_handler(:facebook, PushupBot)

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sinbotra-0.1.6 examples/pushup_bot.rb
sinbotra-0.1.5 examples/pushup_bot.rb
sinbotra-0.1.4 examples/pushup_bot.rb
sinbotra-0.1.3 examples/pushup_bot.rb
sinbotra-0.1.2 examples/pushup_bot.rb
sinbotra-0.1.1 examples/pushup_bot.rb
sinbotra-0.1.0 examples/pushup_bot.rb