Top

How to change a value of next route?

Répondu

Commentaires

4 commentaires

  • Pascal BORSCHNECK

    Hi Erwan,

    I'll forward your question to NodeJS SDK team

    Thanks,
    Pascal

    0
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien
  • 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
    Actions pour les commentaires Permalien

Vous devez vous connecter pour laisser un commentaire.

  • Demandez à la Communauté

    Vous avez besoin d'aide? Posez vos questions à la Communauté et obtenez des réponses d'autres utilisateurs Rainbow.

    Poster un message