Use GPT-3 to input a website category and generate ‘award winning’ digital PR headlines automatically (this one’s just a bit of fun) ๐ ๐ค
Check out the GIF to see it in action ๐ฅ

How to add the Script to Google Sheets
1. Sign up to OpenAI
Sign up to OpenAI here: https://beta.openai.com/signup (there’s no longer a waiting list, so you’ll get access right away).
If you haven’t heard of GPT-3, where have you been? It provides a wide variety of natural language tasks from copywriting, summarising, classifying text, translation (and even writing code). Check this out: https://copilot.github.com/
You get $18 credit in the free account, and on the main engine, davinci, every request will cost you $0.02 – so not bad. There are other fast, cheaper engines too which I’ll explain below.

2. Get your API Key
You can copy your API key from here: https://beta.openai.com/account/api-keys

3. Copy the script below:
/**
* Use GPT-3 to generate an award winning digital pr headline
*
* @param {"clothing"} category - enter your website category
* @customfunction
*/
function headline(category) {
// add your apiKey from OpenAi here. Found at: https://beta.openai.com/account/api-keys
const apiKey = "";
// Prompt copied exactly from 'View code' in GPT-3 Playground: https://beta.openai.com/playground/
const prompt = "This bot will generate a creative digital pr headline that is guaranteed to get coverage and links, based on a website category that you input\n\nWebsite category: finance\nHeadline: influencer investors: How common is misinformation among TikTokโs finance influencers?\n\nWebsite category: betting\nHeadline: Research shows how much bacteria is on the average gaming console\n\nWebsite category: cleaning\nHeadline: Map reveals hay fever hotspots as pollen set to explode this weekend as temperatures soar\n\nWebsite category: used cars\nHeadline: A flying car would cost more than Ferrari's top model, study finds\n\nWebsite category: holiday park\nHeadline: The Worldโs First Hedgehog Holiday Park\n\n";
const apiCall = (prompt) => {
// increase temperature for more randomness, and variations of the output. Max tokens set at 240 characters (could be lower).
// using Keyword: as a stop sequence so that it only generates one result.
const parameters = {
'prompt': prompt + 'Website category: ' + category + '\nHeadline:',
'max_tokens': 40,
'temperature': 0.65,
"frequency_penalty": 1,
"presence_penalty": 0.21,
'stop': '["\n"]'
};
const options = {
'method': 'post',
'contentType': 'application/json',
'payload': JSON.stringify(parameters),
'headers': {
Authorization: 'Bearer ' + apiKey,
},
};
// fetch from GPT-3 - Engines can be changed. eg. https://api.openai.com/v1/engines/curie/completions
// worth exploring each individual Engine in more detail here:https://beta.openai.com/docs/engines
const response = UrlFetchApp.fetch('https://api.openai.com/v1/engines/davinci/completions', options,);
return JSON.parse(response.getContentText())['choices'][0]['text'];
}
const output = apiCall(prompt);
const idea = output.split('\n').shift().trim();
return idea;
}
4. Head over to Google Sheets
Or if you’re really smart, create a new sheet by going to: https://sheets.new
Select Script editor from the Tools menu.
Paste the script and replace line 11 with your API key:
const apiKey = 'addapikeyhere';
Save it.

5. Add the formula to any cell in your sheet
=headline("greeting card")
Add any website category to the formula and it will output a creative digital PR headline. You can cut and paste the formula with the same website category and you’ll receive different outputs (great for inspiration๐ก). I’d recommend doing this to get the best possible output.
How does it work?
I took all (or most) of the the award winning digital PR campaigns from the UK Search Awards and extracted one of the headlines from the campaign. For some of the headlines, I had to exclude words like ‘dirty’ and ‘bomb’ as GPT-3 went a little left-field.
I accompanied the headlines with the most relevant website category and added it to a prompt to effectively ‘program’ GPT-3 to create more ‘award winning’ digital PR headlines.
Is it any good?
This sounded like a fun experiment, but in all honesty I had little confidence in the quality of the results. However, some of them aren’t half-bad!
Here’s some examples:
- ‘Greeting cards’ – ‘Greeting cards for people who don’t do Christmas’
- ‘Women’s clothing’ – ‘New research reveals the best time of day to buy your clothes’
- ‘Coffee’ – ‘This is what happens to your body after you drink two cups of coffee’
Not bad, right? Some of them are TERRIBLE, but hey, isn’t every ideation session the same?
This is just a bit of a fun, but it could be used for inspiration. I’d love to see some of your examples in the comments below ๐

Thanks for stopping by ๐
I’m Andrew Charlton, the Google Sheets nerd behind Keywords in Sheets. ๐ค
Questions? Get in touch with me on social or comment below ๐
hee Andrew. Im one of the people that was actually under the bridge or something because I vaguely heard of AI, deeplearning and GPT-3 but I always thought it was to difficult to learn or practically make a use case out of it. So after reading about it I think my assumption was true, I still find it incredibly difficult to wrap my head around it.
Your tool though seems interesting and Im gonna give it a go, but I was wondering, you mention training the tool. How does that practically work? Do you copy paste all those headlines into the formula and then run it or something? Does it remember through my generated API the input I give it?
Thanks!
Luuk