ruby - How I create a simples questionnaire with Lita.io? -


i try implementing little questionnaire in lita sample:

for system want open call?

sysinitials

what's problem?

i forgot password

thanks! call opened!

any how can this?

so, i'm try this:

module lita   module handlers     class helpdesk < handler       on :shut_down_complete, :clear_context        route(/^abrir chamado$/i, :abrir_chamado)       route(/^.*$/i, :motivo)       http.get '/info', :web        def motivo(response)         return unless context == 'abrir_chamado'         response.reply('thanks! call opened!')         clear_context       end        def abrir_chamado(response)         redis.set(:context, :abrir_chamado)         user = response.user         response.reply(           %(hello #{user.name}, problem?)         )       end        def context         @contetx ||= redis.get(:context)       end        def clear_context         redis.del(:context)       end        lita.register_handler(helpdesk)     end   end end 

but when register, :informar_motivo route, after passing of :abrir_chamado route, matched :informar_motivo route too.

lita dialog flux

but need:

me: abrir chamado

lita: hello shell user, problem?

me: forgot password

lita: thanks! call opened!

i found ugly solution, works :p

module lita   module handlers     class helpdesk < handler       on :shut_down_complete, :clear_context       on :unhandled_message, :motivo        route(/^abrir chamado$/i, :abrir_chamado)        http.get '/info', :web        def motivo(payload)         response = payload[:message]         return unless context == 'abrir_chamado'         response.reply('thanks! call opened!')         clear_context       end        def abrir_chamado(response)         redis.set(:context, :abrir_chamado)         user = response.user         response.reply(           %(hello #{user.name}, problem?)         )       end        def context         @contetx ||= redis.get(:context)       end        def clear_context         redis.del(:context)       end        lita.register_handler(helpdesk)     end   end end 

enter image description here


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -