CAI Challenge Submission: Using sentiment analysis
This blog post is part of the SAP Conversational AI Tutorial Challenge 2021. In this tutorial we will sentiment analysis to give different replies.
In our scenario the bot handles different inquiries related to a package delivery.
The conversation when the user enters that he received a package. In the case of a positive or neutral sentiment we ask the user for feedback. In the case of a negative sentiment we ask if something is wrong with the delivery and give instructions for returning the package is needed.
Building the bot
We start by creating a new bot. From the options we choose Perform Actions.
Since we want to ask the user for feedback we select the Customer Satisfaction from the predefined skills.
In the third step we name the bot.
For the Data Policy we select Personal because this use case could be extended to use a package number.
In the fifth step we set the bot visibility to private and the press create.
Adding the intent
After the creation of the bot you should see two intents in the Train tab: yes and no
We will create one more intent called “package-delivered” by entering the name in the text field and clicking create.
In the next window we keep the default values and press create intent
In the Add an expression field enter expressions such as “The package arrived”, “I got the package” and confirm each entry by pressing Enter.
Now we switch to the Build tab. Here some skills should already be defined. To add a new skill we press on Add skill on the left-hand side.
As the name of the skill enter “package-delivered” and press Add.
Repeat the steps to add a skill called return-package.
Then click on the tile for package-delivered to edit it.
We set the trigger to If @package-delivered is-present.
In the actions tab add a new message group.
Set the condition as shown in the image so that the action is triggered when the sentiment is negative or very negative.
Then click on Update Conversation and select Go To.
Redirect the bot to the return-package skill and click Save.
New a second message group for a neutral sentiment. Then click on Send Message.
Select the Text option.
As text enter “This is great” and press Save.
As a second step redirect the conversation. This time select the customer-satisfaction skill.
To reply to a positive or very positive sentiment add the third message group as shown below.
In the next steps we will set up the return-package skill. For this click on Build at the top of the page and then on the return-package skill.
Under Requirements add @yes as damaged and @no as damaged and connect them with or. The click on New Replies.
In the pop-up select Send Message.
Then choose the Quick Replies option.
Set it up as shown below and press Save.
Navigate to the Actions tab and create a new message group. In the requirement we check if the package is damaged and give instructions on how to return the package.
Add a second message group. Here we handle the case that the package is not damaged.
As the last part of the tutorial we have to modify the customer-satisfaction skill. For that navigate to it and open the Requirements tap. Under the #number as rating requirement we have to edit the reply for If #rating is missing. Click on Edit Replies.
Change the text to “On a scale from 1 to 5, how would you rate the delivery?” and Save.
New you can test the bot and try to trigger the different responses.
I hope this tutorial helped you in understanding how to use sentiment analysis for your chat bots.
If you found this tutorial useful please leave like and share your comments.