Skip to content

Instantly share code, notes, and snippets.

@seansu4you87
Created April 16, 2017 20:40
Show Gist options
  • Save seansu4you87/818c596444c9c717ca4e0792d72e1040 to your computer and use it in GitHub Desktop.
Save seansu4you87/818c596444c9c717ca4e0792d72e1040 to your computer and use it in GitHub Desktop.
Interface for blackbox chatbot
class Parser
end
class ChatEngine
# Jordan's Black Box
class State
attr_reader :raw
def initialize(raw)
@raw = raw
end
end
class Message
attr_reader :text,
:date,
def initialize(text, date)
@text = text
@date = date
end
end
def process(message, state)
# blah dee blah blah
end
end
facebook_stuff # from webhook
parser = Parser.new(facebook_stuff)
message = parser.fetch_message()
state = parser.fetch_state()
engine = ChatEngine.new
responses, new_state = engine.process(message, state)
responses.each do |response|
FacebookMessengerResponder.send(response)
end
Persister.save(new_state)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment