Coder Social home page Coder Social logo

Example of CatchAll use about stealth HOT 2 CLOSED

hellostealth avatar hellostealth commented on June 4, 2024
Example of CatchAll use

from stealth.

Comments (2)

mgomes avatar mgomes commented on June 4, 2024

Hi @luizcarvalho!

Here's what a typical catch_alls_controller.rb looks like for us:

class CatchAllsController < BotController

  def level1
    send_replies

    if previous_session_specifies_fails_to?
      step_to flow: previous_session.flow_string, state: previous_state.to_s
    else
      step_to session: previous_session - 2.states
    end
  end

  def level2
    send_replies

    if previous_session_specifies_fails_to?
      step_to flow: previous_session.flow_string, state: previous_state.to_s
    else
      step_to session: previous_session - 2.states
    end
  end

  def level3
    send_replies
  end

private

   def previous_session_specifies_fails_to?
     previous_state.present?
   end

   def previous_state
     previous_session.flow.current_state.fails_to
   end

end

As you can see it is pretty generic. Once we get to the last level (level3 here), we don't redirect the user back anymore. Here we would typically hand off to a human or ask the user to contact support because something has really gone wrong.

With respect to getting access to error messages, I am not sure this is something we will support. If you want to catch errors in order to return a message to the user, you should do that in your controller action. The CatchAll is designed for unexpected failures. You can think of the CatchAll like a 500 error page and not a form error. Does that make sense?

from stealth.

luizcarvalho avatar luizcarvalho commented on June 4, 2024

@mgomes Nice approach in the catch all levels, I understand now what is the objective. Made sense to me. Very thanks for the explanation.

from stealth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.