Unlocking the power of Open AI: how to automate information extraction

February 06, 2023 11:29 pm | Updated 11:29 pm IST

ChatGPT, developed by OpenAI, has gained wide popularity for its innovative language model. From streamlining business operations to simplifying research, Open AI has limitless possibilities. However, not many are aware that the technology behind ChatGPT is open-source, making it accessible for anyone to use and create their own applications. One such application is the Da Vinci model, which can be integrated into user-friendly tools to make everyday tasks more efficient. The objective of this article is to uncover the potential of Open AI and to show how it can be combined with Google Sheets to revolutionise the way one works and lives.

What is Open AI?

Artificial Intelligence (AI) is a field of computer science that focuses on creating machines and computer programs that can perform tasks that typically require human intelligence, such as understanding natural language, recognising images, or making decisions. These machines are designed to learn from data, which allow them to improve their performance over time.

Various use-cases of OpenAI

The OpenAI API is a tool that allows people to use a powerful language model called GPT-3 through a simple and easy-to-use interface. With the help of AI, computers can now perform tasks that were once thought to be exclusive to humans, such as recognising speech, translating languages, and even driving cars. AI is being integrated into various industries, making our lives more convenient, efficient and smarter. One can start using it without having to know the technology behind it. It also supports multiple languages like English, Spanish, French, and German. By using OpenAI, businesses and individuals can save a lot of time and effort by automating tedious and time-consuming tasks.

Here we will explore how OpenAI can be integrated into Google Sheets, a tool that many of us use on a daily basis, through a step-by-step approach. This article will show us how to generate our own API Key, set up a Google Sheet, and integrate OpenAI into it so that one can start reaping the benefits of this revolutionary technology.

How to integrate Google sheets with Open AI

We are constantly bombarded with information. From emails to social media posts, it can be overwhelming to keep up with it all. Therefore, there needs to be a more efficient and effective way to sift through large amounts of information. By using Google App script and OpenAI, one can easily summarise any article or text, saving time and effort.

Step 1: Navigate to Open AI and generate your API Key through this link.

Step 2: Set up a Google Sheet with the content that needs to be summarised.

Step 3: Create a new App Script project by going to “Extensions” and then “Apps Script”.

Step 4: Add the code provided below into the Script Editor.

The code reads text from a sheet named ‘Sheet1’, and passes it to OpenAI to generate bullet points. This process can save a lot of time and effort for businesses and individuals who need to summarise large amounts of text. The code can also be copied by scanning the QR code given below.

function summarizeText() {

const spreadSheet = SpreadsheetApp.getActiveSpreadsheet()

const sheetName = spreadSheet.getSheetByName(‘Sheet1’);

const numberOfContents = sheetName.getLastRow();

const completionsLink = “https://api.openai.com/v1/completions”;

let paramsToSummarise = {

model: “text-davinci-003”,

prompt: ““,

temperature: 0,

max_tokens: 204,

top_p: 1.0,

frequency_penalty: 0.0,

presence_penalty: 0.0,


let options = {

method : ‘get’,

contentType: ‘application/json’,

muteHttpExceptions: true,

payload: {},

headers: {Authorization: “Bearer <open ai api token>”},


for (let content = 2; content <= numberOfContents ; content++ ) {

let promptContent = sheetName.getRange(content,1).getValue();

paramsToSummarise.prompt = promptContent + “\n\nBullet points”

options.payload = JSON.stringify(paramsToSummarise)

let text = UrlFetchApp.fetch(completionsLink, options).getContentText()

let obj = JSON.parse(text)




Step 5: Replace <open ai api token> with the respective API token generated in Step 1.]

Step 6: Run the code by clicking the “play” button or by pressing “Ctrl+Enter”.

Step 7: The code will now extract the text in Column 1 to Open AI API, and generate the summary as bullet points

Step 8: The bullet points will now be updated to Column 2 of Sheet 1

This code is just the beginning of what can be achieved using OpenAI. OpenAI’s capabilities go far beyond just generating bullet points. Using the same code one can summarise an article from a given link, translate a text into another language, summarise user feedback, generate responses to customer queries and so much more.


The possibilities of OpenAI are endless, and the technology is constantly evolving. OpenAI is also designed to be user-friendly, and the code above is an example of this. By using Google Sheets which is simple to set up, even non-technical users can quickly see the benefits of OpenAI for themselves.

However, it is important to remember that when using OpenAI or any AI technology, one must be mindful of the data we feed into it. One must ensure that sensitive information is not included in the data, as it can be used to train the model and therefore, lead to potential security and privacy concerns. One can fully unlock the power of OpenAI and reap the benefits it has to offer while maintaining the security and privacy of our personal information.

Premnisha Balakumar is lead developer and the Head of Communities for Thoughtworks Coimbatore

Top News Today


Comments have to be in English, and in full sentences. They cannot be abusive or personal. Please abide by our community guidelines for posting your comments.

We have migrated to a new commenting platform. If you are already a registered user of The Hindu and logged in, you may continue to engage with our articles. If you do not have an account please register and login to post comments. Users can access their older comments by logging into their accounts on Vuukle.