[[{“value”:”

👋 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

  1. Google Workspace Account: Ensure you have access to Google Sheets.

  2. Perplexity API Key: Sign up at Perplexity’s platform and retrieve your API key.

    1. Don’t forget to add credits to your Perplexity API account ($5 should be more than enough for testing this)

  3. 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

  1. Visit Perplexity’s API platform and sign up.

  2. Generate your API key and copy it. Keep it confidential.

Step 2: Access the Script Editor in Google Sheets

  1. Open a new or existing Google Sheet.

  2. Navigate to Extensions > Apps Script to open the editor.

Step 3: Add the Perplexity Apps Script

  1. In the Apps Script editor, you’ll see a code window with a default function myFunction(). Delete it.

  2. Paste the script provided at the end of this tutorial.

  3. Replace "YOUR_PERPLEXITY_API_KEY_HERE" in the script with your actual API key.

  4. 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

  1. Click the Save icon in the toolbar, or press Ctrl+S (Windows) / Cmd+S (Mac).

  2. 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

  1. Go back to Google Sheets.

  2. In any cell, type: =Perplexity(“Your Query”)

  3. 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:


Read more

“}]] Read More in  The AI Break