In this tutorial we'll continue the Conversation script by using Intent Conditions and Character Actions
After the employee speaks to the user, the user will ask them to come in and have a seat. The employee will respond by walking to the chair in the office and sitting down.
Before you begin this tutorial, make sure your workspace is connected to your AI service.
- Click here for a video on how to connect your Watson Assistant to your StoryFlow workspace (Google coming soon).
- Click here for a video on how to create Intents in Watson Assistant
Step 1: Create an Intent Catalog
- Open the catalog window by clicking on the folder icon on the left:
- Click on "Create or Import New Catalog" at the top of the window.
- Select "watsonIntent" as the catalog type (this is near the bottom of the long list, you can start by typing the title to find it more quickly).
- Give the catalog a name. In this tutorial, the catalog will be called "Watson Intents".
Step 2: Add Intents to the Catalog
This step assumes that you have connected your Watson instance to your StoryFlow workspace. If you have not already done that, please refer to the video links posted at the top of this article to see how. This step also assumes that you have created intents in Watson Assistant.
To create an Intent catalog, you simply need to copy the names of your intents (exactly as you have spelled them in Watson) into a Motive catalog. In this tutorial, we are going to use an intent called "TakeASeat".
- Open the newly created Intent catalog.
- Click "New Item".
- Add the intent name and connect it to the assistant you have set up:
Step 3: Create a New Subframe
- Open the "Conversation" script and navigate to the final frame where the character greets the user.
- Create a subframe below this frame by clicking on the '+' at the end of the frame with "close" selection:
Step 4: Add a Speech Recognition Condition to the Frame
- Drag a "Speech Recognition" condition into the conditions area of the frame:
- Select "Intent" as the Recognizer.
- Choose the intent that you would like to use for opening this frame. In this case, we are using the "TakeASeat" intent. This means that the system will wait for the user to say something that is recognized to mean "Please take a seat" to trigger the character's next action.
- The confidence is how "sure" you need Watson to be that it interpreted the intent correctly. You might need to play around with this value in order to get the accuracy and usability right. We've set it at 0.7:
To quickly test that this intent is working, we will add a notification to this frame. If we see the notification, we will know that the intent condition is working and that the frame is opening.
- Add a notification that says "Character heard you":
- STOP: Save and test in the headset. When you run the scenario, the character will address you. You should speak back to them - invite them to sit down. If you see the notification, you know that the intent condition is working.
Step 5: Add a "Navigate To" Character Action
- Once you have determined that your intent condition is working, remove (or disable with the toggle at the top of the resource) you notification.
- Drag a "Navigate To" character action into the frame:
- Choose your character for the "Character" dropdown. (Note - if your character is not there, go to the Scene Objects frame and add your character as an object.)
You'll see that they also need a target - this is where the character to walk to. In this case, we would like our character to walk to a spot in front of the chair so that they can take a seat. Before you can add the target to the resource, you need to add it to the "Scene Objects" frame.
- Navigate back to the "Scene Objects" frame.
- Drag in the "In Front of Office Chair" scene anchor from the "Character Positions" catalog.
- We will also add the "Employee Chair" from the "Office Scene Objects" catalog because we will need it in the next frame:
- Navigate back to the last frame and add the "In Front of Office Chair" scene anchor as the target for your character.
- Re-name the frame "On Character Action Close" to "Walk to Chair".
- STOP: Save and test in the headset. Now when you say "take a seat" the character should walk to the chair. There may be a bit of a delay so it may take a few seconds before they walk.
Step 6: Add a "Turn To" Character Action
When the employee gets to the chair they should turn to you.
- Add a "Turn To" action to the same resource where you set up navigation.
- For target, leave it blank. It will default to the user if you don't set a target and for offset put 0 as you want her to face you. (Offset is in degrees from the target, so for instance, 180 would have the character turn their back on you):
- STOP: Save and test in the headset.
Challenge! Add a character dialog action to the resource as well to have the character say "Ok" or "sure" as they walk to the chair.
Step 7: Add a Sit-Down Animation
- Create a new subframe when the Character Action is completed using the Event Link Short Cut.
Complete not close
- Re-name the frame "Sit Down".
- Add an "Apply Effect" resource to this new frame.
This is how we apply Unity animations to the objects in our scene. In this case, we will add a sitting animation to the character and an accompanying animation to the chair so that they work in unison.
- Select the character as your "World Object".
- Chose the "SittingDownReg" animation. They are slightly different for female characters and male characters, so choose the one that suits your character.
- Add another "Apply Effect" resource to the frame.
- Choose the Employee Chair as the object and the animation"OfficeChair_SittingDownReg".
- STOP: Save and test in the headset. When you say "Please, take a seat" the employee will walk to the chair, turn to face you and then sit down.
Step 8: Add a New Frame to the Conversation Script with a Timer Condition
- Navigate back to the Conversation script. Add a subframe below the animation frame.
- Re-name the frame "Start conversation":
- We want the conversation to start after the sit-down animation is complete. "Apply Effect" resources don't fire a "close" event because animations don't actually complete.
- In order to have this frame open after the character is sitting down, add a timer condition to this frame:
- Set the "Delay" value. You will need to test this to determine how long you want the delay. In this tutorial, we will start with a 4 second delay:
- Drag a notification into the frame, for testing purposes. Have a notification that says "Conversation will begin" (or similar) so that you can get a sense of whether you have the timing right.
- STOP: Save and test in the headset. See if the timing is right and adjust accordingly.
Step 9: Thank the Employee for Coming In
- Delete or deactivate the notification in this new frame.
- Click the '+' at the end of this frame thumb to add a subframe. Note that this frame with the timer condition has no resources. That's ok - sometimes frames only have conditions and serve to control the flow of a scenario. Not every frame needs resources in it!
- Add a Speech Recognition condition to this new frame. In this tutorial, we will use the intent we created called 'ThanksForComingIn":
- Add a "Dialog" resource to have the employee respond.
- In this case, we will have our character, Stacey" say "No problem, what can I do for you"?
- STOP: Save and test in the headset. After the character sits down, say "Thanks for coming in". They should respond with the line you just added.
In the Headset
This is what your scenario will look like so far: