2
votes

I am trying to write my first bot using Node.js and MS Bot Framework. From the examples provided by Microsoft, I can't figure out how to achieve this scenario:

  1. Bot sends a message to the user.
  2. Bot waits for the user's answer.
  3. Bot runs another function to process this answer.

The examples have this code:

        if (!item.size) {
            // Prompt for size
            builder.Prompts.choice(session, "What size would you like?", "Small|Medium|Large|Extra Large");
        } else {
            //Skip to next waterfall step
            next();
        }

The first method (builder.Prompts.choice()) achieves what I want, but I don't want to use the ugly built-in prompts. I'd rather just do it manually (send message to user, offer options, wait for response).

The second method (next()) just skips to the next step without waiting for the user's input.

I have a dialog created like this:

bot.dialog('name', [function 1() {}, function 2() {}]);

So I just want to find a way so that function 1 outputs a message and waits for the user input, then moves on to function 2.

1
In c# sdk this is : context.Wait(nextMethod);. You should find something similar for node.js. Maybe you can get user input and send it to another function where you can control your Dialog ? - Bob Swager
I know that, and there's nothing similar in Node because the dialog logic is not in any way similar to C#. - user6269864
Why don't you use another function to handle user input ? - Bob Swager
Which one? @BobSwager - user6269864
Create Dialog, expect user input, handle user input in a function, when you're done just end that DIalog. - Bob Swager

1 Answers

2
votes

Is the builder.Prompts.text() a solution for your scenario?

You can just give a question (string text) with it, and the user can reply with whatever he wants.

https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-dialog-prompt