👋 Hi AI Break family! Luis and Rui here with another AI tutorial!
Imagine having your own research assistant right inside your Google Sheets.
In this tutorial, you’ll learn how to integrate Perplexity into Google Sheets using Apps Script and Perplexity API.
(Full script at the end!)
Why Integrate Perplexity into Google Sheets?
Real-time Research Assistant: Get instant, well-researched answers to your queries directly within cells
Scalable Solution: Use the function across multiple cells for bulk processing
Streamlined Workflow: No more switching between tabs - get Perplexity's responses right in your spreadsheet
What You’ll Need
Google Workspace Account: Ensure you have access to Google Sheets.
Perplexity API Key: Sign up at Perplexity’s platform and retrieve your API key.
Don’t forget to add credits to your Perplexity API account ($5 should be more than enough for testing this)
A Blank Spreadsheet: Start fresh or use an existing one to add Perplexity functionality.
Step-by-Step Tutorial
Step 1: Obtain Your Perplexity API Key
Visit Perplexity’s API platform and sign up.
Generate your API key and copy it. Keep it confidential.
Step 2: Access the Script Editor in Google Sheets
Open a new or existing Google Sheet.
Navigate to Extensions > Apps Script to open the editor.
Step 3: Add the Perplexity Apps Script
In the Apps Script editor, you’ll see a code window with a default
function myFunction()
. Delete it.Paste the script provided at the end of this tutorial.
Replace
"YOUR_PERPLEXITY_API_KEY_HERE"
in the script with your actual API key.If you want you can change the model here (in this example we are using the llama-3.1-sonar-small-128k-online)
Step 4: Save the Script
Click the Save icon in the toolbar, or press Ctrl+S (Windows) / Cmd+S (Mac).
This should be enough for you to be able to use the function. If not then run the script once to trigger the authorization process. If prompted, grant the script the necessary permissions.
Step 5: Use the Function in Your Sheet
Go back to Google Sheets.
In any cell, type: =Perplexity("Your Query")
Press Enter to get a response directly in the cell.
Step 6: Experiment with Different Queries
Example:
=Perplexity("What is the capital of Australia?")
If you want to use Perplexity with information from other cells just add “& CELL NUMBER” after the prompt like the example below.
=Perplexity("prompt"&A1)
Advanced Tips
Since Perplexity can search the web, you can use it to research specific companies by providing website URLs. Here's an example:
Copy this Perplexity Script into Google Sheets
Here’s the Apps Script to copy and paste:
Keep reading with a 7-day free trial
Subscribe to The AI Break to keep reading this post and get 7 days of free access to the full post archives.