Better Sheets - Free AI Integration
Hi Spreadsheeters! Andrew from Better Sheets here with a very simple, and quick thing for you. I say thing because it's just a piece of code but it can help you in an infinite number of ways. Want to integrate AI?You can use the OpenAI API. and I made a 2 minute video to show you how.
and... you can copy the code from here, or from Better Sheets.
function ai(prompt) {
var apikey = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("apikey").getRange("A1").getValue();
var role = ""
var data = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "system", "content": role},
{"role": "user", "content": prompt }],
"temperature": 1,
"max_tokens": 500,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
}
var options = {
'method': 'POST',
'contentType': 'application/json',
'headers': {
'Authorization' : 'Bearer ' + apikey
},
'payload': JSON.stringify(data)
}
var answer = UrlFetchApp.fetch("https://api.openai.com/v1/chat/completions",options)
var response = answer.getContentText()
var json = JSON.parse(response)
return json.choices[0].message.content
}
Now do you want to be able to read the code?Basically the function is named "ai" and then a text variable is used to fill in for the prompt you can enter in the function in sheets. Any text you add in the function in side of your cell will be used as "prompt" inside the function. We'll get the apikey for the API call from the cell A1 in the tab named "apikey" Then we'll add the settings like max_tokens and top_p as data. Then we'll create the payload and the headers for the API call. In this case we're using a POST api call to essentially add the prompt text to OpenAI and we'll end up getting a response that's text. We execute the API call with UrlFetchApp.fetch() along with the options we stated earlier. Then we'll get the response, get the text, and parse it with JSON. Finally we'll return just the message content from the JSON we get back to we can read the text the AI gives us back. Now do you want to be able to Master the code?Master Spreadsheet Automation on Udemy is the course that includes learning apps script AND the OpenAI Api.
If you're already a Better Sheets member, I'd recommend Spreadsheet Automation 101 and Adventures in AI, so that you can both understand the apps script and fully use AI to it's greatest potential inside of Google Sheets.
Both of these courses are available in the one course on Udemy. -Andrew Your resident Google Sheets wizard at Better Sheets |
Older messages
If you want to sell a spreadsheets, you have to write a sales page
Monday, March 18, 2024
Better Sheets Members and Non-Members, Just added a brand new section to the course: Selling Spreadsheets Available free for Better Sheets members 👍 Selling Spreadsheets → on BetterSheets.co And the
Free Course
Wednesday, March 6, 2024
Hi, It's Andrew from Better Sheets. You've heard it before "Learn to Code" Have you ever wanted to code and just get overwhelmed? HTML → CSS →Javascript → Oh my! And then you jump
You Can Build Web Apps with Google Sheets
Monday, March 4, 2024
I recently got a kick out of building full apps within Google Sheets and Apps Script and putting those on the web. Front end and all! Of course I made some videos. Essentially I'm showing you how
How to Make a Sellable Spreadsheet
Tuesday, February 27, 2024
Hello Sheet Fans! Just added a whole new section to Selling Spreadsheets: How to Make a Spreadsheet Monthly and Lifetime members already have access here: → https://bettersheets.co/courses/selling-
Free Tool: Spintax Updated!
Friday, February 23, 2024
Hi, This week I've updated Spintax. It can now generate Spintax for you. You give it a sentence or a paragraph and it will be "spin" it. The tool is free, but uses OpenAI API KEY to
You Might Also Like
• Book Series Promos for Authors • All in one order • Social Media • Blogs
Wednesday, January 15, 2025
~ Book Series Ads for Authors ~ All in One Order! SEE WHAT AUTHORS ARE SAYING ABOUT CONTENTMO ! BOOK SERIES PROMOTIONS by ContentMo We want to help you get your book series out on front of readers. Our
🤝 2 Truths Every Biz Buyer Should Know
Tuesday, January 14, 2025
Plus 1 Game-Changing Idea for SMB Acquisition Biz Buyers, Welcome to Main Street Minute — where we share some of the best ideas from inside our acquisitions community. Whether you're curious or
Artistic activism, the genetics of personality & archeological strategies
Tuesday, January 14, 2025
Your new Strategy Toolkit newsletter (January 14, 2024) ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
Reminder: B2B Demand Generation in 2025
Tuesday, January 14, 2025
Webinar With Stefan and Tycho ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
Why Some Types of Art Speak to You More Than Others
Tuesday, January 14, 2025
Your weekly 5-minute read with timeless ideas on art and creativity intersecting with business and life͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
How Chewbacca Roared a Woman into New Teeth
Tuesday, January 14, 2025
It started as a prank. A funny, and mostly harmless one -- annoying, sure, but most pranks are.
🧙♂️ [SNEAK PEEK] Stop giving brands what they ask for…
Tuesday, January 14, 2025
Why saying “no” could actually be your smartest move ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
Book Promos • SIX posts each day on X.com • Over 33 days •
Tuesday, January 14, 2025
Tweeted 6 times daily for 33 days only $33 Logo ContentMo Tweets Your Book to Our Twitter Followers Each Day We TWEET Your Book for 33 Days, 6 Times/Day = 198 tweets SEE WHAT AUTHORS ARE SAYING ABOUT
The Ad. Product Backlog Management Course — Tools (4): GO Product Roadmap and the Now-Next-Later Roadmap
Monday, January 13, 2025
The 25000 Feet Level of the Course's Alignment Model ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏
Using this free CRO tool?
Monday, January 13, 2025
Improved insights, results and workflow. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏