DEV Community

Lisa Jung
Lisa Jung

Posted on • Edited on

Beginner's guide to creating an empathetic chatbot

"I am sorry, I didn't catch that. Please try again."

There is nothing more frustrating than talking to a chatbot that does not know how to help you. You find yourself repeating "let me talk to a human" multiple times before you get so frustrated that you leave the conversation.

alt text image

Unfortunately, frustrations caused by chatbots happen too often and it could forever ruin customers' sentiment towards your brand.

If only we could build a chatbot to detect customers' negative emotions so we can take right measures to help the them...

Wait.. we can!

Dialogflow is a natural language processing platform used to build conversational user interface like chatbots.

With Dialogflow, you can give unique personality to your chatbot and analyze emotional tone of customers based on the words that they use.

By end of this blog, you will be able to:

  1. create an agent and intent
  2. perform sentiment analysis

Let's get to it!

STEP 1: Sign into [Dialogflow] with your Google account (https://dialogflow.cloud.google.com/#/login) then choose the standard edition(free).

Alt Text

STEP 2: Create an agent

Agent is a virtual agent that handles conversations with your end-users.

In the upper left corner of your console, click on create new agent.
Alt Text

Follow the red arrows to complete the following steps.

  1. Name your bot to SentimentBot
  2. Choose the default language of your choice
  3. Choose your time zone
  4. Click on create button Alt Text

This process will create a new agent and a new Google project. You will see the following displayed in your browser.

Alt Text

STEP 3: Train the intent with example phrases for what customers will say

Intent is customers' motive for talking to a chatbot. For example, when customers say "I want headphones", their intent is most likely that they want to browse headphone selections.

We can train a chatbot to recognize customer's intent by providing variations of typical phrases a customer will say.

Click on the plus sign (red arrow 1) then click on add training phrase (red arrow 2).
Alt Text

In the image below, there is a section highlighted with a red arrow. Name the intent "refund policy".

Then, provide variations of phrases that a customer will say to learn about the refund policy(highlighted with red line).

Some of the phrases could be:

  • "How much time do I have until I can return an item"?
  • "Can I still get a refund after 30 days?
  • "What is the refund policy?"

Alt Text

STEP 4: Train your chatbot with relevant responses for specific intent

Our chatbot would be useless if it recognized customers' intent but had no idea how to respond!

Let's train the chatbot with some of the responses we want it to say to our customers.

Scroll down to responses and click on ADD RESPONSE.

Alt Text

In the image below, there is a section highlighted with a red box. Add variations of responses that you would like your chatbot to display to the customer.

Some of the responses could be...

  • We have a 30 day return policy. All items returned in its original packaging with approved reasons for return will be given a full refund within 14 days.

  • Thanks for asking! As long as items are returned in its original packaging with approved reasons for return, we will give you a refund within 14 days. Make sure that your request is within 30 days of purchase.

  • Great question! As long as items are returned within 30 days in its original packaging with approved reasons for return, refund will be issued within 14 days.

Once you have added your sample responses, click save.
Alt Text

STEP 4: Test it out!

In the image below, look at the box highlighted in red. In the region highlighted with red arrow, copy and paste one of the customer example phrases you have trained your chatbot with.

You will see that our chatbot is responding exactly the way we trained it to do!
Alt Text

You can create as many intent and responses to fit your use case.
Now, let's move on to sentiment analysis!

STEP 5: Add sentiment analysis to your chatbot

To add sentiment analysis functionality to your chatbot, you need to upgrade to Enterprise Edition Essentials.

Alt Text

At first, I felt weary about upgrading to a paid version. But the cost is very low($0.002 cents/text request) so I thought it was worth trying out!

Once you upgrade, you will see that your plan has been changed to Enterprise Essentials, Pay as You Go plan.

Click on settings button next to SentimentBot
Alt Text

Click on Advanced tab(arrow #1) then enable sentiment analysis(arrow #2) then save(arrow #3)!

Alt Text

STEP 6: Test sentiment analysis

In the image below, you will see a box highlighted with a red arrow. Write something positive such as "Great customer service!"

If you look at the Sentiment section highlighted with a green arrow, it will show a query score of 0.9.

Positive 1 is the highest query score in the happiness scale you can achieve. Our chatbot senses that it is doing a great job and the customer is very happy.

Alt Text

What if we enter a negative comment by a customer?

Alt Text

A query score of -0.9. Ouch! Chatbot senses that the customer is not very happy.

There you have it!Try this out and integrate Dialogflow to your app. You can then determine how you want your app to take care of an unhappy customer based on sentiment query score!

Top comments (5)

Collapse
 
perpetual_education profile image
perpetual . education

The other day, a friend said "You know, I'm a bot - right?" over text message... we were like... uh... oh... that could totally be true. Now we just call them JoeBot.

Collapse
 
veselinastaneva profile image
Vesi Staneva

We also get people on our live chat that think that it is by default a bot and start the convo with "Hello Bot". :D I guess people start getting used to speaking with bots more and more.

Collapse
 
lisahjung profile image
Lisa Jung

@perpetual.education and @Vesi Staneva, your comments made me smile!

While moderating a webinar, I was answering attendees' questions via chat. One of them said "Your chatbot is so friendly!" It made me crack up.

It's so cool to see all the technology we can incorporate to make our chatbots more like us!

Collapse
 
jpeeiclinic profile image
Dmitri José

It will soon be used by many businesses. I like the kindness of the bot

Collapse
 
lisahjung profile image
Lisa Jung

Hey Dmitri! I absolutely agree with you. It's amazing how you can give your bot personalities and completely transform the way your customers interact with your business.

Thank you so much for reading and commenting on my blog. Your message made my day!