Decision making and logic

It’s time to take one step further in making our Assistant even more intelligent: let’s create decisions based on what the user said.

To do that in BotTalk you’ll need to use a next section of the step. It does makes sense, if you think about it. Let’s review the process we’ve created so far:

  1. Assistant welcomes the user and asks something (sendText)
  2. Assistant switches to listening mode (getInput)
  3. We’ve configured possible answers

What’s next?

Well, you now you need to connect the possible answer with the next step your Assistant will go to:


    - name: My first step
      actions:
        - sendText: >
            Hello, World!
            Do you want a personal greeting?
        - getInput:
      next:
        # If a user says yes (see Intents for details)
        yes: Personal Greeting
        # If a user says no
        no: General Greeting

    - name: Personal Greeting
      actions:
        - sendText: >
            Great! Now I want to greet you personally with the
            warmest welcome!

    - name: General Greeting
      actions:
        - sendText: >
            As you wish. No personal greeting for you then.

So if a user would say something like “go for it”, or “sure”, or “it would be nice” - basically anything that you defined in the last chapter as a variant (or utterance) of the yes intent - THEN an Assistant will go to the Personal Greeting step and will read this text out loud:

Great! Now I want to greet you personally with the warmest welcome!

If, on the other hand, a user doesn’t want a personal greeting and reacts to the questions with “just leave me alone” or just “no”, the next step an Assistant will jump to will be General Greeting:

As you wish. No personal greeting for you then.

So far so good? Let’s hear this logic in action! Go to the Test tab and hit the Run button:

93AC680A-C895-46D1-8420-AFBA9F6A3BDB

As you can see in the screenshot, BotTalk’s Random Walker Test chose a negative answer to the question. You can rerun the test multiple times to get it to choose another answer:

95FD2D26-1B3E-4F32-A524-33EF179F2C81

Just take a listen, isn’t it exciting? You just taught your assistant to decide!