Conversational Forms
This feature, which includes two methods ask() and answer() allows you to create conversational forms.
ask(answer_route=String)
ask(answer_route=String)Usage
ask("profile/get_email_address")answer(label=String|Symbol, &block)
answer(label=String|Symbol, &block)Usage
class ProfileContext < Conversation
def blocks
answer "get_email_address" do
ask do
@reply.text "What is your email?"
end
regular_expression /([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/ do |emails|
@reply.text("Good, I'll register you under this email: #{emails.first}")
exit_answer()
end
keyword "stop" do
@reply.text "I'm stopping the sign up process now."
exit_answer()
end
everything_else do
@reply.text "I need an email in order to continue. Or write 'stop' if you want to cancel"
end
end
end
endexit_answer()
exit_answer()Full Example
Last updated
Was this helpful?