Top

How to change a value of next route?

Beantwortet

Kommentare

4 Kommentare

  • Pascal BORSCHNECK

    Hi Erwan,

    I'll forward your question to NodeJS SDK team

    Thanks,
    Pascal

    0
    Aktionen für Kommentare 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
    Aktionen für Kommentare 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
    Aktionen für Kommentare 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
    Aktionen für Kommentare Permalink

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.

  • Fragen Sie die Gemeinschaft

    Brauchen Sie Hilfe? Stellen Sie Ihre Fragen in der Community, um Antworten von anderen Rainbow-Benutzern zu erhalten.

    Nachricht posten