Coder Social home page Coder Social logo

Stealth route system about stealth HOT 4 CLOSED

hellostealth avatar hellostealth commented on May 24, 2024
Stealth route system

from stealth.

Comments (4)

mgomes avatar mgomes commented on May 24, 2024 1

Hi @luizcarvalho,

Can you elaborate a little on your use-case? We've built a few bots now and haven't needed a full blown routes system. For the most part, all of our route methods in BotController look like this:

def route
    if current_message.payload.present?
      handle_payloads
      current_message.payload = nil
      return
    end

    if current_session.present?
      step_to session: current_session
    else
      step_to flow: 'hello', state: 'say_hello'
    end
  end

handle_payloads is a method with a case statement to handle Facebook button payloads.

from stealth.

luizcarvalho avatar luizcarvalho commented on May 24, 2024 1

I understood. I'll wait for a demonstration of use to be more clear how your use this.

Thank very much my friend. :D

from stealth.

luizcarvalho avatar luizcarvalho commented on May 24, 2024

Nicee, this is works to most of my problems haha, thanks. I not found this in docs.
But, when user send a random text message? I'll need use NLP?

from stealth.

mgomes avatar mgomes commented on May 24, 2024

I should add an example of handle_payloads to the stealth-facebook gem. It's pretty Facebook specific though as other message platforms often don't have the same concept of a "payload". I think it'll be helpful for everyone, though.

Basically that route method comes with BotController and is required to be there. By default, users are sent to hello->say_hello. If a user has progressed beyond the hello flow, then they get sent to the last position in their session. It could be any other flow and state you have specified.

So when a user types a random string into your bot, it wouldn't be the responsibility of the route method to determine what to do with it, it would be whatever state the user is in that may be expecting a response. In most cases you should try to design the response to be simple. So for a Facebook bot, we recommend utilizing quick replies and buttons. But certainly you may have open ended user input that needs validation or NLP. For NLP, we currently have integrated AWS Comprehend (https://github.com/hellostealth/stealth-aws-comprehend) but you could also add in support for others.

I recommend checking our docs on sessions: https://hellostealth.org/docs/#sessions. Hopefully we'll have screencasts available soon that will make this all more clear. 👍

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.