Skip to content

Using the ChatGPT API to automate tasks


AI Automating TasksRay Poynter, 13 August 2024


 

The web interface for ChatGPT is great, but it does not always deliver what we want. In this post I want to describe how creating a simple call to the ChatGPT API can give a range of benefits. The example I am going to share in this post comes from a course I am running on how to the ChatGPT API, check it out at.

What is the API?
API stands for Application Programming Interface and refers to the ability to access a program through a relatively simple interface. In the case of ChatGPT, you access the API by creating an account, by obtaining an API key, and then writing a routine or function in a programming language.

A simple call to ChatGPT
As an example, I have created a function in Google Sheets called ChatGPT. In this version, the user simply enters a question, and the function returns the answer.

For example, if I type ‘=chatgpt(“What is the capital of Austria?”)’, it returns “The capital of Austria is Vienna.” As you can see in the image below.

The ChatGPT function

At this level the API has no benefits over the web interface, but it is reassuring to see it in action.

The next step in using the API
Instead of typing the question straight into the function call, we can make the spreadsheet more general-purpose by typing the question into an empty cell and asking the ChatGPT function to read that cell.

For example, if I type in Cell A1, “What is the Capital of Australia?” and call the function ChatGPT in cell B1 and ask it to read Cell A1, it will give me the answer, “The capital of Australia is Canberra,” as shown below.

Calling the function

With this approach, I can keep changing the questions in A1 and B1, which will show me the updated answer. For example, in the image below, I changed the question in A1 to ask about grocery retailers in Australia and received a list and description of six brands.

A question about grocery retailers

We now have a general-purpose tool where the user can ask any standard question and get an answer, from the safety and comfort of their own environment.

Expanding the function to a more typical Spreadsheet use
To illustrate how organisations can utilize this approach, let’s consider how we might use a spreadsheet to highlight personally identifiable information (PII). In many situations we do not want the data to have personal information because it raises privacy concerns.

In the example below, I have six hypothetical responses from an online survey, and I want to check if there is any PII in each row.

Responses with PII

Obviously, with only 6 rows I would have no problem checking them manually, but if I had 100, or 1,000, or 10,000 I would not want to do it manually.

In the example below, I have called the ChatGPT function in cell C2, with a question that is written in cell C1: “Does this comment contain personally identifiable information?” and the text in B2. This generates the answer “The comment “Thank you for the survey, I enjoyed it” does not contain any personally identifiable information (PII). It does not reveal the identity of the individual or any specific details that could be used to identify them.”

Using the ChatGPT to find PII

When I look at the answer ins cell C2 I can see that it is too verbose. If there is no PII, I just want a ‘No’, but if there is PII, I want to know what it is. To get what, I want I edit cell C1, which automatically updates the answer in cell C2.

In the image below I have expanded the question in C1 to “Does this comment contain personally identifiable information? If there is no PII, just display No. If there is PII, display the PII.”. I have also filled the call to ChatGPT down for all of the rows. In the cells in column C, we see either No or we see the PII.

Automating looking for PII

How to Create the Function ChatGPT
In this example, I created the function in Google Apps Script, a language provided by Google which is based on JavaScript. To access the ChatGPT API, you need to write some code, but it does not need to be Google Apps Script. Other popular options include Python, Java, C and R.

I have chosen Google Apps Script because it is widely available, free and integrates nicely with Google Sheets.

To get the code for the function ChatGPT, you can either Google it (there are lots of versions out there), or you can book a place on our Introduction to using the ChatGPT API course on 28 August, 2024 – see below.

An Introduction to using the ChatGPT API
With Will Poynter, I have created a course to introduce you to the ChatGPT API. The 90-minute online course will show you how to set up your API-enabled account, create functions like the ChatGPT one described above, and deploy it to start automating tasks.

As an attendee of the workshop, you will receive a briefing on how to set up your account and create the key function, a copy of the slides from the course, and a recording of the course. You do not need any programming skills to complete the tasks we will be covering, but some experience with macros would be helpful.

To buy a place on this course, click here.

Curious about how hot insights methods can benefit your business? Contact us at SoftOfficePro.com. We’ll help you harness the latest market research techniques to stay ahead of the competition. For all Market Research projects please visit pulsefe.com. They have a great platform comparable to STG at a fractional cost. For ODK Collect projects please contact us at softofficepro.com

Source link

8 Comment on this post

  1. I do believe all the ideas youve presented for your post They are really convincing and will certainly work Nonetheless the posts are too short for novices May just you please lengthen them a little from subsequent time Thanks for the post

  2. Belo blog aqui Além disso, seu site carrega muito rápido Qual host você está usando Posso obter seu link de afiliado para seu host? Desejo que meu site carregue tão rápido quanto o seu haha

  3. O que eu não percebo é que você não é mais bem-favorecido do que você é agora Você é muito inteligente Você sabe muito sobre esse assunto me fez acreditar nisso de vários ângulos diferentes É como homens e as mulheres não ficam fascinadas até que seja algo a ver com Lady gaga Suas próprias coisas excelentes O tempo todo cuide disso

  4. é claro que gosto do seu site, mas você precisa verificar a ortografia de vários de seus posts. Alguns deles estão repletos de problemas ortográficos e acho muito difícil informar a realidade, por outro lado, certamente voltarei novamente

  5. What i dont understood is in reality how youre now not really a lot more smartlyfavored than you might be now Youre very intelligent You understand therefore significantly in terms of this topic produced me personally believe it from a lot of numerous angles Its like women and men are not interested except it is one thing to accomplish with Woman gaga Your own stuffs outstanding Always care for it up

  6. Normalmente eu não leio artigos em blogs, mas gostaria de dizer que este artigo me forçou a tentar fazê-lo. Seu estilo de escrita me surpreendeu. Obrigado, ótima postagem

Join the conversation

Your email address will not be published. Required fields are marked *

Discover more from SOFTOFFICEPRO

Subscribe now to keep reading and get access to the full archive.

Continue reading

Share via
Copy link