Awesome Support Documentation

Automatic Keyword Extraction With Google Natural Language

Introduction

Generally, when we search for documents that matches a users query we are using WordPress’s native search functions.  Depending on how the query or opening ticket is phrased, you can get relevant results or nothing at all or, sometimes, you get a list of documents that has nothing to do with the users query.  By using Google’s Natural Language API, you can extract the most relevant keywords from a users query and use that to drive the search functions.  Generally, this will result in more relevant results.

Set Up Your Google Natural Language Account

You can set up your Google Natural Language Account from this page: https://cloud.google.com/natural-language/

Once you have set up your account, you need to create a project and a set of credentials.

There are three types of credentials that you can set up.  You MUST set up a SERVICE ACCOUNT KEY.  And the key type must be JSON.

If you accidentally set up the wrong key, do not panic.  Simply set up a new key with the correct type – Google allows you to set up multiple keys.

The key will be automatically downloaded into a text file for you.  The contents of this file will be needed when configuring Smart Replies to use Google’s Natural Language.

Configure Smart Replies To Use Google Natural Language

Once you have set up your Google Natural Language account and you have your JSON configuration file, it is time to tell Smart Replies all about it.

Go to the TICKETS->SETTINGS->SMART RESPONSES tab.  Scroll down to the Google Natural Language Section.  It should look something like this:

The first thing you should do is click the checkbox to turn on Google Natural Language.

Then, paste the contents of your JSON file into the JSON CONFIG textbox field.

Finally, scroll down to the bottom and click the SAVE CHANGES button.

The Other Stuff

The default settings in the rest of the configuration options are usually adequate to get you started.  However, you can tweak them to try to get better search results based on what you know about how your customers submit queries.  For reference you might want to read this section of the Google documentation as well: https://cloud.google.com/natural-language/docs/analyzing-syntax

Salience Score:  Each keyword is assigned a rating based on the probability of it being relevant.  The higher the score the more probable it is that its a relevant keyword.  The maximum score that can be assigned is 1.  We set the default to 0.03 but you can move it higher if you want a smaller set of search results.

Entity Types:  Google can automatically figure out what certain keywords refers to – for example it can tell if a keyword is a person’s name or the name of a company.  If you want to search on these kinds of keywords you can turn those on. But generally your users are searching on something unique to your company which is probably not something that can be classified into one of the entity types that Google knows about.

Parts of Speech:  Google breaks up sentences into parts of speech.  By default we only want to search on “nouns”.  But you might decide that you want to search on verbs or other parts of speech.

Results Per Keyword:  Since a single query can result in multiple keywords and each keyword can result in multiple search results, we need to limit each keyword search to a fixed number.  By default its 5 but you can move this higher or lower as you see fit.

Modifications To Ticket

If smart replies is enabled on a ticket, the keywords used for the smart reply is going to be added as “tags” at the bottom of the ticket.  They will look similar to this: