Members-only tutorial
Watch the video and get the practice sheet with membership.
About this Tutorial
Sheet Resources
Video Transcript
<div>00:00 So here's how to tweet from a sheet. Now, this is actually really simple for you. It was not so simple for me.<br>00:06 Because, yes, I had AI help me write it, but AI was not writing it correctly and kept getting some errors and some failures.<br>00:15 So I'm gonna walk through a few of the things that I think you'll need in order to be able to tweet from a sheet yourself.<br>00:21 So, if you're watching this on BetterSheets.com, then down below is this exact sheet and this exact Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab that you're going to need in order to tweet from a sheet.<br>00:33 And here's what we do.
We write a tweet in column A, and when we send it, it's going to give us a timestamp Understand how to create and use timestamps in your Sheets. Opens in new tab of when it's sent.<br>00:41 It's gonna give us the ID of that tweet, because maybe later we wanna create replies or quote tweets or whatever.<br>00:47 forever. Thank you. But also, we'll get a URL, and in this video, I'm gonna show you how to edit the script so we get that URL.<br>00:54 It's actually pretty simple, but you'll need your username.
Now, also, the extent of how this works is you select Explore the query select clause for data manipulation. Opens in new tab a line that you've written a tweet on, you go up to the X or Twitter, uh, custom menu Discover how to create custom menus in Google Sheets. Opens in new tab that I've created here, and you tweet an active row.<br>01:11 Now, what else? What else can this do? It can also, uh, tweet on schedule. You can schedule your tweets here, but, like, we will need to add more stuff to that, and if you wanna add more automations and triggers, you're gonna want to watch the whole, or, not the whole one, but the lessons in Spreadsheet Get insights into managing and using spreadsheets effectively. Opens in new tab <br>01:31 Automation 101.
Why that's important is because you'll be able to read this script, Thank you You'll be able to edit it, and you'll be able to create the triggers you need to do, which are just a few clicks away, but I just want to focus on you getting over to Spreadsheet Get insights into managing and using spreadsheets effectively. Opens in new tab Automation 101 and learning <br>01:47 that. But here, this is how we set it up.
I'm gonna also go through the script, but I'm also gonna go through a few of the things that you need to do on the developer side of X, uh, or Twitter that are a little clunky.<br>02:02 So what you're gonna end up needing in your script is the API key, the API key secret, access token, and access token secret.<br>02:08 These last two, a little bit complicated, but I'm gonna show you how to get it really, really, really easily.
Here are the notes Find out how to add and manage notes in your Sheets. Opens in new tab that I'm gonna go through later, but I want to just walk through this script very quickly because it's not that complicated.<br>02:21 On open, we're gonna add this menu, and this menu can be anything you want. This, uh, text here, X slash Twitter, could be any text.<br>02:31 You can say post on X slash Twitter You don't even have to use X. The add item, this tweet active row, is gonna activate the function Learn about functions and their applications in Google Sheets. Opens in new tab tweet active row, so that needs to stay the same.<br>02:43 And that's gonna be right here, function Learn about functions and their applications in Google Sheets. Opens in new tab tweet active row.
I'm gonna save this right now because I've edited it, and in order to edit it, this on open and actually see it, I'm gonna have to actually close this Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab , go over to the sheet, and refresh the sheet.<br>02:55 So if you ever do those changes, just know you have to actually refresh the sheet and save your change. There it is, post on Twitter.<br>03:01 So go back to extensions, Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab , and here we will keep going, tweet active row.
We're just gonna get the active sheet Understand the concept of the active sheet in Google Sheets. Opens in new tab that we're on, get the row, we're gonna get the value in the first column.<br>03:15 So this comma one is the first column, meaning A. If your column of tweets are in a different column, just change this one to whatever actual column it is.<br>03:27 And if there is no tweet, it'll say no tweet text found. So like, if we go here, let's say we're on this row, post on Twitter, tweet active row.<br>03:36 We will have to I'll see authorize it and then it'll tell you it can't do it.
Ah, so we will get the ID by posting it.<br>03:46 So what this is doing is it's going to a custom function Learn about functions and their applications in Google Sheets. Opens in new tab called post tweet and we're going to take that text that we have here and we're going to tweet it.<br>03:55 When we come back at the end of this, we're going to put a timestamp Understand how to create and use timestamps in your Sheets. Opens in new tab in column two. We're going to put the ID in column three, and I'm going to show you in this video how to add the URL.<br>04:05 So we're going to add a URL here. Add URL in, in column four. What we're going to need there is a username.<br>04:16 So we're going to have a global function Learn about functions and their applications in Google Sheets. Opens in new tab here, username.
This one can't be on Twitter if you want to check me out.<br>04:25 There we go. So now let's go to this custom function Learn about functions and their applications in Google Sheets. Opens in new tab . It's taking this text of this tweet and it's posting it and getting back an ID.<br>04:35 So here we've written function Learn about functions and their applications in Google Sheets. Opens in new tab , postTweet, has some text. It's going to api.twitter.com slash two slash tweets. This is the URL it's going to send to.<br>04:44 The what it's going to send is the payload, and that's a JSON of, here's the text.
The headers Explore the importance of headers in your data organization. Opens in new tab , now this is really, this is probably the most complicated part.<br>04:53 We need to, like, build a OAuth header Learn about headers and their role in data management. Opens in new tab with all of this stuff up here, and that is a whole nother function Learn about functions and their applications in Google Sheets. Opens in new tab .<br>05:00 So we create the header Learn about headers and their role in data management. Opens in new tab of authorization Understand the authorization process for accessing APIs. Opens in new tab saying we're authorized to post for this person, and here's all the options here.<br>05:07 This is the, the method that we're doing, the content type of our, our action, our payload, and our header Learn about headers and their role in data management. Opens in new tab authorization Understand the authorization process for accessing APIs. Opens in new tab .<br>05:13 All together, send it, now what we get back, we're gonna send it through this URL fetch app, and what we get back is a code that says, is it correct or not, and we get a body, we get some information back, and if we return, we go into that body, and we say, hey, it's JSON, let's parse it, and let's go<br>05:31 to the data Get to know how to handle and manipulate data in Sheets. Opens in new tab , and let's go to the ID, and find it, and return it.
That's all that's doing. So it's all sending that stuff, and then getting back an ID.<br>05:38 So let's skip down to this build-out header Learn about headers and their role in data management. Opens in new tab . This one is a little crunchy.
It's sort Learn how to sort data effectively in Google Sheets. Opens in new tab of doing a lot of stuff for us, but it's just taking these API key, access token, it's turning it into a HMACSH1, it's like an encrypted way to send data Get to know how to handle and manipulate data in Sheets. Opens in new tab , it's taking the API keys, putting them in the right format Discover formatting options to enhance your spreadsheet's appearance. Opens in new tab , in<br>05:57 the right place, getting back signatures, and it's using using, this was, this was sort Learn how to sort data effectively in Google Sheets. Opens in new tab of the chunky, complicated part, is basically when I wrote this script originally, it was not using the correct, uh, utility, so in Google Sheets and Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab , there's only a few of these utilities that are computing<br>06:17 this signature, And we needed to actually set up that, hey, use SHA-1, and here's the important part.
Formation, and here's the signing key, again, signing key is just the secret stuff here, and we're going to get that really, really soon, so you're going to get the API key, you're going to get an access<br>06:35 token, and all the secrets, and you're going put them in here, now, I want to be very, very clear, this is not, this Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab and this Google Sheet is not a safe place to put this stuff, I just want to mention it here.<br>06:49 if you're sharing Find out how to share your Google Sheets with others. Opens in new tab your sheet, but if you're not sharing Find out how to share your Google Sheets with others. Opens in new tab your sheet, if you are keeping your sheet restricted Understand the implications of restricted access in Sheets. Opens in new tab , you're not sharing Find out how to share your Google Sheets with others. Opens in new tab it with anyone, if you are just writing your own tweets, and you just want to schedule them, and you don't want to pay for a schedule, this is perfect for you, but if you are<br>07:04 , uh, sending this to, let's say, freelancers, or people in your same company, and you're saying, hey, write the tweets here, and then I'll send them, and then you're just getting this Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab to do it, it's not safe.<br>07:18 It's not safe at all.
People can access your Apps Script Learn about Apps Script and how it integrates with Google Sheets. Opens in new tab and see your secrets, and they're going to charge you money, because the Twitter API charges you money.<br>07:26 So, don't share Find out how to share your Google Sheets with others. Opens in new tab these information. Now, there are a few ways to share Find out how to share your Google Sheets with others. Opens in new tab this sheet exactly as it is, and have these tokens somewhere URL.<br>07:41 You can access this.
Again, that's why I would recommend you take the course Spreadsheet Get insights into managing and using spreadsheets effectively. Opens in new tab Automation 101, because if we use the URL Fetch App to another sheet, we can.<br>07:49 We can get another sheet here, we can put all this stuff in another sheet, and then access it through that.<br>07:53 Again, keep that sheet secret, but you're going to run into some problematic situations where Explore the query where clause for filtering data. Opens in new tab you need to run it as yourself, you need to set up sort Learn how to sort data effectively in Google Sheets. Opens in new tab of automations that run for, as yourself, and then anyone can access it.<br>08:05 So, I just recommend not doing that. Cool. So, we got our header Learn about headers and their role in data management. Opens in new tab , we got our tweet out.
Now, how do we get this, these pieces of information?<br>08:16 So, we're going to go on to Twitter. By the way, this is, this is the tweet I wrote. I'm writing this inside of a Google sheet, tweet from a sheet, And I did that just to show you that there was a difference.<br>08:25 A, actual, ah, tweet from the sheet. But we're going to go to console.x.com. We're going to go to our accounts, and you're going to need to create an app.<br>08:35 The app has its own keys. That is the API key and API key secret.
Then, you're going to go to this page, which is apps.<br>08:46 You're going to select Explore the query select clause for data manipulation. Opens in new tab , you can select Explore the query select clause for data manipulation. Opens in new tab any number Learn about number formatting and its significance in Sheets. Opens in new tab of apps you have. This, this is the most complicated part. Select Explore the query select clause for data manipulation. Opens in new tab your app.<br>08:53 Over on the right side, you will see OAuth 1.0 keys, and you will also see OAuth 2.0 keys. Ignore 2.0.<br>08:58 Go to OAuth 1.0, and I've already generated mine, but you will need to click generate, and it'll ask you, like, are you sure you want to regenerate, blah, blah, blah.<br>09:11 Yes, I want the keys.
This is this is your, your, uh, second part of this, the access token and access token secret, okay?<br>09:21 So these OAuth keys that you create after you create the, a, app, uh, this will be your, those two pieces.<br>09:29 So you need four pieces of information. Two of those is when you create the app, and the, and the second two pieces are the third and fourth two pieces are here.<br>09:37 OAuth 1.0. Now, it was super confusing for me. Look at me, I had created the OAuth 2.0 keys and I was like, yeah, that'll work.<br>09:43 Nope, it doesn't.
Okay, over on the left side, make sure you go to billing, uh, and get some credits. So here, I've bought five dollars of credits and I've already gone through two cents because I, uh, posted two times.<br>09:59 It's like about a cent per, uh, post. There you go. So make sure you have credits, make sure you actually get the OAuth 1.0, uh, keys here, and you'll be good to go.<br>10:14 You'll be good to go to tweet this. So let's add one more thing to the, uh, outcome of this.
And we're going to post, uh, what is it, here, add URL in the fourth column.<br>10:25 So we're going to go SpreadsheetApp Discover the capabilities of the SpreadsheetApp in Apps Script. Opens in new tab .getActiveSpreadsheet, ActiveSpreadsheet, nope, ActiveSheet, getRange Understand how to get ranges of data in your spreadsheet. Opens in new tab , row, that's just the variable that we have right now, row4. setValue Learn how to set values in specific cells of your Sheets. Opens in new tab , and now we want a tweet URL.<br>10:45 So we're going create a variable tweet URL here and that's going to, having to equal, let me get it one second, it's going to be all of this here.<br>11:00 Put that in, plus the tweet ID. So it's just going to add that tweet ID.
Where Explore the query where clause for filtering data. Opens in new tab do you get this name from?<br>11:09 It's going to be, actually I'm going to use not single quotes, but I'm going I'm gonna use backtick. Because right here, I want to do dollar sign Explore the use of the dollar sign in formulas and references. Opens in new tab , curly bracket, end curly bracket, and inside it, I'm going to put this username, this variable username.<br>11:28 So what that does is it's called interpolation and it's just saying, hey, in this string Get insights into string manipulation in Google Sheets. Opens in new tab , where Explore the query where clause for filtering data. Opens in new tab there's dollar sign Explore the use of the dollar sign in formulas and references. Opens in new tab , curly user name, put it in the text that's up there.<br>11:36 Done. Now.
There is another way to do this, and I will show you here, just in case you wanted to know, we don't need to use, uh, these backticks, we could use quotes, single quote, we could end the quote here, add a plus sign, and instead of interpolation, we just use that username, and then again, plus<br>11:59 sign, quote, status, slash, and then quote. So, you see, these two lines are exactly the same.
It's just saying, plus username inside of these two strings, and then we're gonna add the tweet ID at the end.<br>12:13 That's fine as well, but I like this interpolation, it's pretty cool, but you gotta make sure you use backticks, not single quotes.<br>12:20 So I'm gonna, x that, uh, not x that out, comment Learn how to add comments for better collaboration in Sheets. Opens in new tab that out, Save it, and there you go. So. That's how you use this sheet.<br>12:28 Make sure you use your own username here. All of these script and the sheet is down below in the description if you're watching this on BetterSheets.<br>12:37 If you're not, join!</div>
Courses
Add Icons To Your Sheets With a Domain Name
00:04:21
Automatic Screenshots in Apps Script
Add Tasks to Google Tasks From Google Sheets
Tweet From a Sheet
Convert Google Sheets into a REST API
Expense Tracker Template with Data Entry Form Inside Sheets
Build a Book Recommender with AI in Google Sheets
Build a License Key Generator and API in 20 Minutes
Create Your Own API by Deploying a Web App
Access Free API's with Google Sheets
Use Random Quote API in Google Sheets
OpenSea Data Inside Sheets
Tag Emails From A List of Members in Google Sheets
Spreadsheet Automation 101 Lesson 4: Access APIs Introduction
How to Validate Email Addresses
Build Your Own Free Domain Availability Checker
Build a Job Status Checker API in 15 Minutes
Spreadsheet Automation 101 Lesson 4: UrlFetchApp
Spreadsheet Automation 101 Lesson 4: OmdbAPI get ApiKey, get Data in URL
Spreadsheet Automation 101 Lesson 4: OmdbAPI Parameter Picker
Spreadsheet Automation 101 Lesson 4: OmdbAPI get data in Apps Script
Spreadsheet Automation 101 Lesson 4: JSON (beautifier) and OmdbAPI parameters
Quickstart Tutorial OpenAI API in Google Sheets
Shaman: AI Blog Writer
ChatGPT Clone in Google Sheets Part 1
ChatGPT Clone in Google Sheets Part 2
How To Set Up Stripe Webhook to Google Sheets with Google Script
00:22:10
Create Instant QR Codes
Access the Dictionary API to get Definitions for Words in Google Sheets
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