Natural Language API & Google Docs
Work from home is the new lifestyle to which we all are getting acclimatized. Wouldn’t it be great if to learn some easy tips and tricks which will help you to get through it? G Suite: Integrations Quest is a quest which is especially designed to help you out while you #WFH. Using the Natural Language API from Google Docs is a lab that will help you in your day to day work operations. Let us look at what are the things which we will be learning in this lab.
Before we begin with this lab let us first understand what does Natural Language API means and how it functions.
Benefits of Natural Language API
Setup and Requirements
The setup and requirements of this lab are very simple. You just need to follow the instructions carefully.
Enable the Natural Language API
Now this lab gets more interesting as you will enable the natural language API. The first step which you need to follow is to create an API key. Follow the instructions as given in the lab and create your own API key.
You will also see the same API key on the API Keys on the dashboard as given in the image
Now that you have your key, it is time to create a google doc.
Set up your Google Doc
Before you start experimenting with the Natural Language API, you need to set up your Google doc. Create a new Google doc by clicking on the link given in the lab instructions. You will be embedding a App Script Code for your Google Doc. Navigate to script editor as given in the instructions.
Add the code which is given in the lab instructions and save the file with the name as given here
Now that we have the code in place, let us add some content to our doc. You can use the text suggested in the lab instructions or any other random text.
Refresh the page to see the updated menu on the Toolbar. You will notice a Natural Language Tools option
Select any text and click on the Natural Language Tools > Mark Sentiment option. It will open a window which would ask for authorization. Click on Continue and select your temporary lab account.
Once the script is authorized, you will see that the script selected by you is highlighted in yellow color which is neutral.
Call the Natural Language API
This is the last step in the lab which is calling the Natural Language API. This can be easily done by changing the code in the script editor. You need to basically add the retrieveSentiment function, in the code.
Remember the API Key which you had created at the start of the lab? Well now, you need to use that now and add it in the code as given in the lab instructions. Once you have your code in place, you need to select the text in your document and click on the Mark Sentiment option. You will see the respective text highlighted in a different color.
You can use this for getting to know the sentiments of your customer feedback and also for other different purposed depending upon your business.
We hope you enjoyed this lab and got to learn something new. Here’s a little something for you to complete the lab. Enter code 1q-api-067 for 3 free credits on your API journey (valid through March 21st).