EB.

Making an AI Assistant With Always-Updated Data

Posted on Sep 29, 2024 Author: Eytan
Reading time: 4 minutes Tags: AI Marketing Data

tldr

Marketers keep stuff in Google Sheets. Leads, product data, whatever. In this article, I’ll show you how to create an OpenAI API that has its context knowledge updated daily based on what’s in Google Sheets. It might sound complicated, but this opens up amazing possibilities when paired with tools like Zapier. It’s geeky, but it works—automating the kind of stuff that drains time.


It’s hard to play with ChatGPT and not see its potential.

But real-world B2B uses hit a snag because you aren’t a developer. Why? The real power comes when APIs can query your own data.

And if that data updates daily, you don’t want to upload it manually like it’s 1998.

Here, we’ll remove the daily data grind. No-code style. It’s like a Labradoodle in a butcher shop—a ton of energy and excitement.

The Use Cases

Imagine this: A customer pings your support team. Your rep gets their full profile instantly (orders, registration date, favorite Power Ranger) and maybe even a response suggestion. The reply is fast. Your mom calls, proud. Doves fly, and a chorus sings “No Code.”

This normally costs a lot ($95/user/month?!) for AI features…OR dev time. But it doesn’t have to.

Here’s what you need:

  1. Updated Data: Ensure your AI is working with fresh data (like a Google Sheet).
  2. Automation: Programmatic access to that AI so you don’t have to manually interact (using Zapier to trigger the Assistant API).

Two Okay Solutions

  1. Build a CustomGPT. The downside? Manual data uploads and no API interaction.
  2. Use Zapier to fetch data for a non-trained OpenAI API, constraining it to the data you pull instead of its broader knowledge.

Neither scales well when dealing with daily updated data.


Building an Assistant API with Automatically Updated Knowledge

Here’s an elegant solution: an Assistant API that Zapier can reach, which updates its knowledge daily from a Google Sheet. I’ve built 5-10 internal apps using this.

This means when you query the API, it considers fresh data from your chosen source.

This guide assumes you know how to use Zapier and set up your spreadsheet.

The Workflow

The link between Intercom and the Assistant API is Zapier. Here’s the flow:

  1. User sends a message in Intercom, triggering a Zap with their email.
  2. The request goes to an OpenAI Assistant API, which already has the right prompt and data.
  3. The response is sent back to Intercom via Zapier.

What the Zapier workflow would look like.

Building the Assistant API with Google Sheet Sync

Here’s where the magic happens:

The Process:

  1. Create an Assistant API at platform.openai.com and add your prompt.
  2. Get data into Google Sheets (via Zapier or forms like Typeform).
  3. Use Google App Script to sync the data into the Assistant API, erasing previous info with each sync.

The Step-by-step Guide

Three things to note:

  1. API calls cost a little money (very little).
  2. More data = more cost. Keep the data minimal but useful.
  3. When you do this, you’re sharing data with OpenAI. Make sure you have the right privacy considerations in place. I’m not a lawyer, not your lawyer, and honestly, don’t even have any great friends that practice law.

Step 1: Create the Assistant API

Head to platform.openai.com, click on Assistants, and create a new one. Copy the API id and save it (copy-paste, not pen).

Make sure “File Search” is on, since we’ll be sending data.

Create your Assistant here

Step 2: Add your prompt

In “Instructions,” write the prompt for what your Assistant API will do. For this example, it takes an email and provides some info in a specific format. Use XML tags and examples.

Here’s what I used:

<instructions> Find relevant shipper info (total shipments, shipments in progress). Include links to shipment numbers. </instructions>

Step 3: Copy your API key

Get your OpenAI API key by clicking “API keys” on the left. Copy it.

Step 4: Sync the Google Sheet data

Head to this Google Sheet, duplicate it, and paste your Assistant ID in B3 and your OpenAI API key in B5.

View Google Sheet

Set up the sync, add relevant data, and set the expiration (in hours) in B4.

Now run the script (“Extensions > Apps Script > processData”). Approve permissions when asked.

Step 5: Schedule the sync

In App Script, go to “Triggers,” click “Add Trigger,” choose processData, and set it to run daily.

You’re done! Run “processData” one more time, and you’re golden.

Bonus Tip: Keep data slim by summarizing in another sheet before syncing.

Step 6: Test in Playground

Go to OpenAI’s “Playground,” select your Assistant, and add the email. If everything worked, you’re set!

Step 7: Connect to Zapier

Create a Zapier Action with OpenAI, add your Assistant ID, and populate the “Message” field. Done!

What your action should look like in Zapier

Why Bother?

Here are ten potential use cases for this setup:

  1. Survey-Bot: Let users engage with real-time survey data.
  2. Chatbot interactions for order tracking.
  3. Internal customer info lookups in Slack.
  4. Integrate external public data APIs for live chat.
  5. Real-time content calendar updates via chat.
  6. Feature request info through live chat.
  7. Chat to explore customer feedback.
  8. Automatically add blog posts to your Assistant.
  9. Test new leads against your database.
  10. Create an ultimate research bot.

Drop me a line with your cool use cases!