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:
- Assistant welcomes the user and asks something (
- Assistant switches to listening mode (
- We’ve configured possible answers
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
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:
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:
Just take a listen, isn’t it exciting? You just taught your assistant to decide!