Members-only tutorial

Watch the video and get the practice sheet with membership.

See membership options

ChatGPT Clone in Google Sheets Part 2

About this Tutorial

We fix the problem of OpenAI's API not remembering our last questions. And we label the text as Human and AI. I also add an archive Chat and new Chat function to create a new chat fresh.

Video Transcript

<div>00:01 All right, well we have made chat c p t in Google Sheets, but I think there's a few more things we can do to make this just a little bit better.<br>00:10 One thing is I can't really tell right now what is human, what is, I mean, I can tell what is human versus AI versus like the questions, but if we get into like a real dialogue, right?<br>00:23 It's really hard to tell.

So I want to label Learn how to label your queries effectively in Google Sheets. Opens in new tab these human and ai or chat G P t I want to also make it so that we can have multiple chats.<br>00:33 One of the new interfaces in chat G P T is you can create a new chat and then you can go back to old chats.<br>00:38 So I wanna do that and instead of enter chat here, I'm gonna create, first off a couple more items, add item, and I'm gonna call it new chat or create new chat maybe.<br>00:56 And what I wanna do is I'm gonna label Learn how to label your queries effectively in Google Sheets. Opens in new tab this well, I wanna make a copy, duplicate Find out how to duplicate sheets and data in Google Sheets. Opens in new tab it, and I'm gonna call it template Explore how to use templates for efficient data management. Opens in new tab .<br>01:07 Then I'm gonna delete all the stuff here.

We're actually delete a bunch of rows maybe, and what else can we do?<br>01:18 So we're gonna copy this and call in new chat and then make the that new chat active and then make the active cell Understand the concept of the active cell in Google Sheets. Opens in new tab b2.<br>01:27 So we'll do this, we'll do new chat and we'll call it new chat function Get to know how functions work in Google Sheets. Opens in new tab , new chat. All right. And when we click that button, what do we want to do?<br>01:41 First off, we want to duplicate Find out how to duplicate sheets and data in Google Sheets. Opens in new tab a template Explore how to use templates for efficient data management. Opens in new tab . So we'll do variable template Explore how to use templates for efficient data management. Opens in new tab equals spreadsheet Dive into the basics of spreadsheets in Google Sheets. Opens in new tab , app dot get active spreadsheet Learn about the active spreadsheet and its importance. Opens in new tab dot, get sheet by name and call it template Explore how to use templates for efficient data management. Opens in new tab .<br>01:58 Is it? I had a capital T there. Gotta make sure temp lit.

All right.&nbsp; Template Explore how to use templates for efficient data management. Opens in new tab , template Explore how to use templates for efficient data management. Opens in new tab dot copy two. Now here's the weird thing is we need to copy this to its own, to the own destination.<br>02:17 Like the, the sheet we're in. So I think think we do spreadsheet Dive into the basics of spreadsheets in Google Sheets. Opens in new tab , app dot get active spreadsheet Learn about the active spreadsheet and its importance. Opens in new tab . I think we do that.<br>02:30 Let's double check. We're gonna save it, close it. We're going to copy open it again or refresh it so that on open in our menu, we get that function Get to know how functions work in Google Sheets. Opens in new tab .<br>02:44 And we're gonna look at, in case we have any errors, we'll see create new chat. Should say copy of template Explore how to use templates for efficient data management. Opens in new tab .<br>02:51 Perfect. Now we wanna n name it.

How do we set the new name is we probably do variable new chat.<br>03:03 New page equals that. And then new page dot. Can we set the name to chat? Okay, because we want chat to be the one here.<br>03:23 We don't want this to be chat. We want the copy to Discover how to copy data to different locations in Sheets. Opens in new tab be chat, right? Let's delete that. We have a template Explore how to use templates for efficient data management. Opens in new tab , we have chat.<br>03:30 Maybe we need also like archive chat or like maybe when we create new chat, we variable chat sheet equals spreadsheet Dive into the basics of spreadsheets in Google Sheets. Opens in new tab app dot get active spreadsheet Learn about the active spreadsheet and its importance. Opens in new tab , get Active spreadsheet Learn about the active spreadsheet and its importance. Opens in new tab , get sheet by name.<br>03:51 We want to make sure that chat is renamed.

Chat sheet dot setnam is chat. And then we're gonna do plus timestamp Understand how to use timestamps in your Google Sheets. Opens in new tab .<br>04:08 Actually we can just do new date there. Okay, so we know that whatever, if there's a chat that exists, we're gonna rename it to chat plus the timestamp Understand how to use timestamps in your Google Sheets. Opens in new tab .<br>04:19 Then the template Explore how to use templates for efficient data management. Opens in new tab . We're gonna take the template Explore how to use templates for efficient data management. Opens in new tab that we have and we're gonna make it, we're, we're gonna copy it and we're gonna name that chat.<br>04:28 Ideally, that's what's gonna happen, hopefully. Let's see.

So we have chat now create new chat that renames it and we have chat over here.<br>04:38 But now we need to make chat spreadsheet Dive into the basics of spreadsheets in Google Sheets. Opens in new tab , app dot get sheet by. We need to make it active, get active spreadsheet Learn about the active spreadsheet and its importance. Opens in new tab dot, get sheet by name.<br>04:50 Chat dot. I think we can do act. I think we can just do activate. We might be able to get away with that or we might have to do set active.<br>05:03 Let's try to just do activate. Let's, so now we have this big old timestamp Understand how to use timestamps in your Google Sheets. Opens in new tab . We probably don't want all of it, but it's okay for this.<br>05:16 We'll create new chat. We rename it and now we have a new chat. Great.

And now this, if I command click, this should still be assigned.<br>05:31 Yeah, that's still the same, same. The that in that image Learn how to insert and manage images in Google Sheets. Opens in new tab is duplicated as well. So we're gonna ask a question Find out how to ask questions effectively in your Sheets. Opens in new tab .<br>05:40 Hi, what's your name? We're gonna hit this button, Running the script. You can call me open AI assistant. Cool. Now we need to set these as human and ai, right?<br>05:57 So we'll go through our chat, we'll go to the bottom where Explore the use of the WHERE clause in queries. Opens in new tab we return stuff. We will set a value for chat sheet dot get range Understand how to define and use ranges in Google Sheets. Opens in new tab .<br>06:11 The row is gonna be four. The column is gonna be one.

This is going to be set value, and it's gonna be the question is human.<br>06:24 And then the same exact thing, copy paste. But row five will be ai. Now as we go, what's your middle name?<br>06:43 Hit the, enter the, the button. Now we have human and ai. Cool. Maybe we can style that a little differently.<br>06:54 That maybe we can also add colons to. That might be nice. Should I do ai? No. Capital ai? I don't know.<br>07:06 We'll do that. I don't have a minimum name. However, I cannot &lt;laugh&gt;, he really wants to help me. What tasks can you help me with?<br>07:15 Hit that button.

Ooh, it's exciting, right? What tests? I can help you with various tasks. Let's make sure this template Explore how to use templates for efficient data management. Opens in new tab has I think we need, oh, it is this, the text wrapping is correct.<br>07:35 Hmm. It's gonna be a bit of an issue, right? Cause it doesn't look very good when it enters that data Learn about data management techniques in Google Sheets. Opens in new tab in there.<br>07:40 It doesn't automatically. Do you have any? So now this feels like a chat, right? But it's, I know, I know on the backend what's going on is that this chat is only, the prompt is only the exact question that I ask.<br>07:54 Okay?

So it's not really, the prompt doesn't really know that I have some other questions and the answers Discover how to manage and display answers in your Sheets. Opens in new tab that it's given me.<br>08:03 So I want to insert here some of the past question answers Discover how to manage and display answers in your Sheets. Opens in new tab . If there are past question and answers Discover how to manage and display answers in your Sheets. Opens in new tab and what they're gonna be is there gonna be this b a a four and B four, A five and B five?<br>08:27 And we probably want to limit Learn how to limit the results of your queries. Opens in new tab it maybe to like three or four. Because if we got a lot of text in there, it's just gonna cost a lot in prompt tokens.<br>08:40 So one easy thing to do, maybe let's do the easy thing first and then fix it as we go.

So we wanna get past questions.<br>08:52 Is going to be, this should be chat. Actually, I copied the wrong one. That's the a p i key. Here's the question.<br>09:02 Okay, let's write variable past question and let's do ver the same thing, but past answer. This is going to be a, what was it not a three, A four was the question and a five was the answer.<br>09:28 Wait, no, that's just, we know what that is. So we actually B five, this needs to be B four. All right, let's do that again, but it'll be six and seven.<br>09:42 Hmm.

Okay, so now we can add these in here, but we don't wanna necessarily add, could we add them blank?<br>09:52 And is it gonna like not be a bad thing? Sort Understand how to sort data effectively in Google Sheets. Opens in new tab of. Okay, so I think, I think I thought of something.<br>10:05 Okay, so we know how big the template Explore how to use templates for efficient data management. Opens in new tab is. So we know that there are eight rows in the template Explore how to use templates for efficient data management. Opens in new tab before anything has been asked.<br>10:16 So we can guess if some, if the, if there's more rows than eight in this sheet, then we have some past questions and answers Discover how to manage and display answers in your Sheets. Opens in new tab .<br>10:24 We don't necessarily know how many. So we can do something here.

So I'm gonna pause this part cuz this we don't need, we can, we need those, but we don't necessarily need to do it in this piece by piece.<br>10:35 We can get it all at once. So if let's do variable row count equals we can also fix this chat sheet equals all of this.<br>10:54 So we don't need to do that again and again. Chat sheet chat sheet dot get max rose is going to get us the number Explore how to work with numbers in Google Sheets. Opens in new tab of rows, right?<br>11:06 So if row counts greater than eight, then we're gonna do something else other than this else.

It's gonna do, we're gonna do this.<br>11:30 Wait, actually we can do less than eight then the variable past questions Equals we're just gonna have nothing here. So we can add right here, plus past questions.<br>11:48 And then I think we can just need to for figure out how to format Learn about formatting options to enhance your Sheets. Opens in new tab this human and ai.

The last part is going to be the same, the last like question, right?<br>11:58 We're gonna put in the human question and then the ai dot colon, that's gonna stay the same, but our previous questions need to, I think be here.<br>12:10 And if the row count is less than eight, then variable past questions is just gonna be quotes, nothing. It's not gonna be anything.<br>12:24 But if it's greater else, variable past questions, it's equal to. Now we have to do sort Understand how to sort data effectively in Google Sheets. Opens in new tab of a four loop, I think.<br>12:37 I think we can do an array. Hmm, no, we don't want it to be an array.

We want it to be a string Understand how to manipulate strings in Google Sheets. Opens in new tab .<br>12:46 Okay, here we go. Four. I equals zero I is less than, we actually only want like three or four, right?<br>13:02 Oh, I got an idea. Actually we can, I'm gonna, I'm gonna do this super valley. If you're watching this and trying to learn how to program, this might not be the best way, but row count is Equal to 10, right?<br>13:14 It's gonna be two at a time. Now we know there's only one. So we can do something here and we're gonna do variable past questions as equal to this.<br>13:23 And then if row count is equal to 12, we're gonna do something else here.

Not else, but we're gonna do variable There.<br>13:34 So we need to figure what this is. It's probably gonna be question one. Question human question each question. AI answer equals check sheet dot get range Understand how to define and use ranges in Google Sheets. Opens in new tab .<br>14:03 What Was this again? It's going to be, let's look at a past one. B four is the question. B five is the answer.<br>14:18 B five is the answer. And now this is equal to the slash nhu.

We do have a space there, human plus question plus in AI plus AI answer.<br>14:46 So now we're inserting if the ro count is exactly 10, we're gonna insert the past question and answer, oh, what are we doing?<br>14:54 Line 36. Okay. And then if we need two of them, we'll do exactly the same thing, except we're going to add another one.<br>15:10 Or actually it's gonna be greater than 10. We only wanna have two. I I think it's gonna be outta the bounds of this particular video if we're gonna do more than two.<br>15:20 So we'll just add two and let's see if this actually works right.

Go through all of this and find out it doesn't work.<br>15:28 Would be crazy, right? Each Question two, actually one, one plus we can add all of this here. One. Now I think that is it.<br>15:53 So now let's look at our current chat. Our current chat has more than, you know, 10. So it's should grab in all of this.<br>16:03 What was the last thing I asked? Let's See. Chat sheet does not defined details. &lt;laugh&gt;, okay we just need to find all of the, where Explore the use of the WHERE clause in queries. Opens in new tab , where Explore the use of the WHERE clause in queries. Opens in new tab is all of this?<br>16:26 So maybe in here, this variable or maybe this needs to be constant. Sorry, let's try this again.

Okay, that wasn't it.<br>16:41 Hmm. See the executions, see if there's a, oh, is there, this is chat, right? That is chat sheet should be telling me what line?<br>16:51 No. Ah, there is 37. Let's look at this line. 37 chat sheet. Oh, &lt;laugh&gt;. It's supposed to be a capital S CHT sheet.<br>17:07 So actually we probably didn't even need these. These were, this is overkill. How many chat chat sheets do we need?<br>17:13 Do, do, do, do, do. So we had it up here, so we don't need it here. Should not need it here.<br>17:22 And if we see that again, we'll no grab it. Okay.

Dismiss, Do, Do, can I read properties? Undefined get range Understand how to define and use ranges in Google Sheets. Opens in new tab .<br>17:31 Let's look at the error Find solutions for common errors in Google Sheets. Opens in new tab again. Executions. That was my silly mistake. I accidentally deleted an extra chat. One. So that should work.<br>17:41 Now. Let's see, what was the last thing? US range Understand how to define and use ranges in Google Sheets. Opens in new tab . That's not actually true. I mean, what? &lt;laugh&gt; It's nonsensical. Can I have a conversation with you?<br>17:59 I mean, tech, it seems like it's working, right? Do we really need to go through this? But yeah absolutely. I'm here to help.<br>18:05 So write a tweet about chat, G p T and Google sheets. Let's See. Nice.

Make it shorter. Hmm. All right, this is strange range Understand how to define and use ranges in Google Sheets. Opens in new tab .<br>18:32 Ah, I see an error Find solutions for common errors in Google Sheets. Opens in new tab that I did here is I'm rewriting over this. This should not be B four and B five.<br>18:38 Again, this should be B six and seven. All right, let's see if this fixes it a little bit. Write a tweet.<br>18:48 A tweet hook about Google sheets. Write A Write it shorter. Ah, what range Understand how to define and use ranges in Google Sheets. Opens in new tab do you need? Something weird about the range Understand how to define and use ranges in Google Sheets. Opens in new tab ?<br>19:12 Oh, is it? Oh, this is so stupid. I can believe I did this. Okay, so this is get range Understand how to define and use ranges in Google Sheets. Opens in new tab .

We need to get value.<br>19:22 Oh my god, that's, I can't believe that's that's so funny that I did that. All right, value. Alright, this is gonna work because it's &lt;laugh&gt;.<br>19:29 This is exciting. Dot get value. We need the value, not just the range Understand how to define and use ranges in Google Sheets. Opens in new tab . I'm so excited. All right, now let's see.<br>19:41 Will it work? All right, &lt;laugh&gt;, let's try this again. Write a tweet about Google Sheets. Hit Yep. Mm Running that script.<br>19:56 Get organized, work smart. Write it shorter please. It is shorter. Take out the hash text. Nice.

So now we have a pretty cool implementation of chat G p t coming in, in that Google sheet.<br>20:22 We now are able to create more chats, save our chats. We are also able to add in the questions and answers Discover how to manage and display answers in your Sheets. Opens in new tab that we're getting into the prompt a little bit, right?<br>20:34 We haven't really done it a programmatic way. I sort Understand how to sort data effectively in Google Sheets. Opens in new tab of just hacked this together.

It's only giving up to the last two questions and answers Discover how to manage and display answers in your Sheets. Opens in new tab , but I think for this video, this is a pretty cool place we're in Now we can create new chats, save our old ones, archive our old ones based on our timestamp Understand how to use timestamps in your Google Sheets. Opens in new tab of what, when they're times when they're ended.<br>20:54 If you are looking to use this, go ahead and make a copy and try it out and you'll need your own API key.</div>

Courses

Sheet Stories / Video Notes + ADDED: Email Notifications

00:00:00

Fast FAQS

Enter Google Drive File Name Get URL

ChatGPT Clone in Google Sheets Part 2

Create an Internal Google Sheets Add-on

Tweet From a Sheet

Why Different Cell References in AI Integration in Sheets?

Show Sheet Tabs Based on Edit

Add Title Case to Google Sheets

How to Power Testimonials with Google Forms and Sheets

Getting Started Coding in Apps Script

Seek Errors When Coding Apps Script

Think Like a Programmer: Develop The Mindset of an Apps Script Coder

ChatGPT Clone in Google Sheets Part 1

Embed a Number in a Website from a Google Sheet

Create Navigation Like A Book or Presentation

Add Click Tracking To Your Google Sheets | Bitly in a Google Sheet

00:29:08

Hold a Giveaway Raffle in a Google Sheet

Quickstart Tutorial OpenAI API in Google Sheets

Capture Emails from Website Form to a Google Sheet (Without Zapier)

Embed a Headline in a Website from Google Sheets

Create a new Spreadsheet from just a Name in a Sheet.

00:05:21

Bjarne Asks: Can I show the Last Time of the Last Edit in a sheet?

00:05:43

Email Yourself a Cell from a Google Sheet, Every Day

OpenSea Data Inside Sheets

Create an Email Campaign Stats Calculator

00:35:13

Twitter App Clone in a Google Sheet

Dylan Asks: How to Automatically Delete Rows If Cell Contains Value

Highlight Row as You Move Your Cell Selection

Create a Timer with Apps Script

LinkTree in a Google Sheet

00:11:22

Password Protecting Data In a Google Sheet

Automatic Weekly Backup of Google Sheets

Create a CPM Custom Function (Create Better Calculators!)

Move Entire Row when a Cell is changed to "Yes" - The $75,000 Google Script

00:12:29

What Can You Automate in Google Sheets? Every single trigger available to Google Sheet users

Sync Two Tabs Without ImportRange()

Google Sheets Stories? No! But we'll add timestamped video notes to your google sheets.

00:00:00

Password Protecting Data In a Google Sheet Part 2 The Basics

Benoit Asks: How to Convert Case

00:07:35

Learn to Code in Google Sheets, For Programmers

Add a Checkbox to Turn on Dark Mode

00:05:10

Write Your First Script

00:08:31

Find Keywords in Any Column. Create quick search dropdown to find keywords

00:09:37

Basic CRM - Add a Powerful Script To Move Row Based on Status

How To Improve: 1,000 Business ideas: Business Idea Generator

00:11:20

Let's Make a Bookmarklet!

00:12:37

Troubleshooting Bitly in a Google Sheet Script

00:07:07

Unique Features - Design a Better Dashboard Part 2

00:04:13

How To Set Up Stripe Webhook to Google Sheets with Google Script

00:22:10

How to Edit a Macro

00:08:22

Sheet Stories / Video Notes + Clear 24 Hour Old Videos

00:35:10

Add A Timestamp to Task Lists (without Now Formula)

00:07:44

Make your Custom Functions Like Native Functions | Custom Function Autocomplete

00:17:58

Create a Changelog Between 2 Cells Custom Function | To learn Double For Loop

00:23:26

New Syntax for WhatChanged Formula in Google Script

00:07:14

How to Record Macros

00:06:20

2 Ways to Delete Lines Quickly (CAREFUL, it's a script!)

00:09:53

Deep Inside Dark Habits Google Script

00:18:54

How to Trigger Macros Daily

00:06:58

5 Ways to Create Coupon Codes | Create UUIDs

Create a Radio Button From Checkboxes Using Google Apps Script

00:15:01