Top

How to change a value of next route?

Respondida

Comentarios

4 comentarios

  • Pascal BORSCHNECK

    Hi Erwan,

    I'll forward your question to NodeJS SDK team

    Thanks,
    Pascal

    0
    Acciones de comentarios Permalink
  • Pascal BORSCHNECK

    Hmm, looking at the docs in GitHub: https://github.com/Rainbow-CPaaS/Rainbow-Chatbot

    Will this resolve your question:

    Rerouting

    When you call the done() function, you can pass a parameter corresponding to the name of the next action to execute. You scenario will be rerouted to this step and will continue.

    chatbot.onMessage((tag, step, content, from, done) => {
    
        if(step === "aStep" && content==="yes" && from.jid==="ajid@adomain.com") {
            done('special_step');
        } else {
            done();
        }
        
    }, this);
    

    In that sample, depending on the step, the user and the answer received, a rerouting is done to the step special_step. For other cases, the normal next step is executed.

    ?

    0
    Acciones de comentarios Permalink
  • Erwan GEREEC

    Thanks for your answer pascal,

    What I'm looking for is not only rerouting to another step, but also changing the text of next step. (Passing an additional parameter to the done() function to override the text of next step in fact)

    0
    Acciones de comentarios Permalink
  • Pascal BORSCHNECK

    Ok

    Problem here is, it uses internaly the Promise "resolve", why may only carry one argument.
    But you can for example patch the code in Rainbow-Chatbot\index.js, line 172 and next to handle this in

    routedStep
    • nothing,(resolve())
    • or a "next step" (resolve("next step"))
    • or an Array of ["next step", args] (resolve(["next step", args]) with args in json format) and store the args somewhere you need in
    work

    Best regards,
    Pascal

    0
    Acciones de comentarios Permalink

Iniciar sesión para dejar un comentario.

  • Pregunte a la Comunidad

    ¿Necesitas ayuda? Haz tus preguntas en la Comunidad para obtener respuestas de otros usuarios de Rainbow.

    Enviar un mensaje.