An open-source Twitter bot that lets you easily set reminders for public tweets. Mention @RemindMe_OfThis in the reply of any tweet and specify the time in natural English when you would like to reminded of that tweet.
You could say things like in 2 days or in 12 hours or next week or even in 5 years. Check out the source on Github.
Save Twitter Threads with @ThreadReaderApp
The gurus on Twitter have figured out that threads are the best way to extend the reach of their tweets and @ThreadReaderApp makes is really easy for you read and save these threads.
To get started, reply to any tweet of a thread and mention @threadreaderapp with the “unroll” keyword. and they create a single page with all the tweets arranged in chronologicusefual order. Blog posts anyone?
Reply to a tweet with the word “screenshot this” and mention @pikaso_me in the reply. You’ll receive a reply tweet with a screenshot image of the original tweet.
The twitter bot capture images in tweets but you can also use Screenshot Guru for that.
Download Videos with @DownloaderBot
You can easily download any video or GIF image from tweets with the help of this Twitter bot.
Mention @DownloaderBot in a reply to any tweet that contains either a video or a gif image, and you will receive a reply with the direct link to download the media.
Twitter, like YouTube, may have a love-hate relationship with bots that allow downloading videos off their platform so it is always a good idea to bookmarks some alternatives. There’s @GetVideoBot, @SendVidBot and @Get_This_V.
This step-by-step tutorial describes how you can connect to the Gmail SMTP server for sending emails from a Node.js web application that could be deployed on Google Cloud Functions, AWS Lambda, Cloud Run or running on your local machine.
And unlike most other Node SMTP tutorials that use the username and password combination, this approach uses OAuth and doesn’t require you to turn on less secured apps access in your Google account.
Create Gmail OAuth Credentials
Create a new Google Cloud Project and enable the Gmail API as described in a previous tutorial.
In the APIs & Services section, click on Credentials and click on Create credentials > OAuth Client Id to create a new client ID that will be used to identify your application to Google’s OAuth servers.
Set the application type as Web Application and put the following URL in the Authorized Redirect URI.
https://developers.google.com/oauthplayground
Click the Create button and you’ll be provided the OAuth Client ID and Client Secret values that you’ll need in the next step.
Create Gmail Refresh Token
Next, we’ll generate a refresh token using the Google Developer OAuth 2.0 playground. The access tokens are valid for an hour but the refresh tokens stay valid forever (unless manually revoked) and can be used to generate a fresh access token.
Go to google.com/oauthplayground, click the Gear Icon and check the option that says Use your own OAuth credentials. Copy-paste the Client ID and Client Secret that you have generated in the previous step.
Inside the Select & Authorize APIs section, enter the scope https://mail.google.com and click the Authorize APIs button to generate the authorization code.
Click the Exchange authorization code for tokens to generate the refresh token that we’ll require in the next step.
Prepare the Node.js Application
Create a new folder and install the googleapis and nodemailer packages.
Create a new .env file in the root folder and add the credentials in the file. Add the file to .gitignore so it is not added to the repository.
// Replace these with your own credentials
CLIENT_ID ='r2l82l8.apps.googleusercontent.com'
CLIENT_SECRET ='GOCSPX-5n00Mqm5Jc45p'
REFRESH_TOKEN ='1//04yt8hEatvIr3uyk-ZJSYIhmYqMk4C4EqfPK24w'
REDIRECT_URL ='https://developers.google.com/oauthplayground'
Open the index.js file and add the following code. You may need to replace the sender’s email with the email address of your own Gmail account that you have authorized to send email.
The Gmail SMTP server name is smtp.gmail.com and the Gmail SMTP port is 465. You can send up to 100 emails per day when the messages sent via SMTP.
const{ google }=require('googleapis');const nodemailer =require('nodemailer');require('dotenv').config();constsendEmail=async()=>{const oauth2Client =newgoogle.auth.OAuth2(
process.env.CLIENT_ID,
process.env.CLIENT_SECRET,
process.env.REDIRECT_URL);
oauth2Client.setCredentials({refresh_token: process.env.REFRESH_TOKEN});const accessToken =await oauth2Client.getAccessToken();const myEmail ='amit@labnol.org';const smtpTransport = nodemailer.createTransport({service:'gmail',host:'smtp.gmail.com',port:465,secure:true,auth:{type:'OAuth2',user: myEmail,clientId: process.env.CLIENT_ID,clientSecret: process.env.CLIENT_SECRET,refreshToken: process.env.REFRESH_TOKEN,
accessToken,},});const mailOptions ={from:'Sender Name <amit@labnol.org>',to:'Receiver Name <hello@example.com>',subject:'Test email 🚀',text:'This is a test email from Node.js 🎉',html:'This is a <b>test email</b> from Node.js 🎉',};try{const response =await smtpTransport.sendMail(mailOptions);
console.log(`Email sent!`, response);}catch(f){
console.error(f.message);}finally{
smtpTransport.close();}};sendEmail().then(()=> console.log('Done!'));
Here’s a test email sent by the application. If the email receiver client doesn’t support HTML mail, the plain text version is rendered.
Correct Gmail OAuth Scope
While you can send emails from Gmail using the https://www.googleapis.com/auth/gmail.send scope, you would need to use the restricted https://mail.google.com/ scope for Gmail SMTP. If your OAuth client uses a different scope when requesting permissions for an user, the application will return the 535-5.7.8 Username and Password not accepted error.
In a previous tutorial, you learned how to send WhatsApp messages from Google Sheets using the official WhatsApp API. The first 1,000 messages per month for each WhatsApp Business Account are free and then you pay per use based on the country of the message sender and the message recipient.
WhatsApp API Pricing
For instance, if you are sending a WhatsApp message from the US phone number to a WhatsApp user in France, the cost would be 14¢ per message. However, if you send messages from WhatsApp number in India to another number in India, the cost would be around 0.006¢ per message. The rate cards for WhatsApp API pricing are available here.
In addition to the cost factor, the WhatsApp Business API requires you to have a verified business on Facebook (see verification requirements) and the terms require that you will only send message to WhatsApp users who have opted-in to receive future messages from you on WhatsApp.
The other limitation of WhatsApp API is that you can only send messages that are based on templates pre-approved by WhatsApp. You can however send free-form messages within 24 hours of the last user message in a conversation.
WhatsApp Function for Google Sheets
If you are a small business that is looking for an alternate route to message customers on WhatsApp without paying for the API, here’s a semi-automated technique. You can use the Click to Chat feature of WhatsApp to quickly send a personalized message to any phone number that’s registered on WhatsApp.
For this example, we have a sheet that list the customer’s name, amount that they have to pay and the due date for payment. We can use the CONCATENATE or TEXTJOIN function of Google Sheets to create a personalized message for each client in column D.
The column E of the Google Sheet contains the phone numbers of each WhatsApp user. We can use the WHATSAPP custom function to create a personalized chat link for different customers in the Google Sheet. When you click this chat link, it automatically open a WhatsApp conversation with the user and the message is pre-filled in the chat box.
This method does require a few extra click but there’s no cost involved and it works for both WhatsApp Business and WhatsApp personal accounts.
WhatsApp Function
Here’s the underlying WHATSAPP function that generates the Click to Chat link in Google Sheets. It also supports Array Formulas.
The third parameter determines whether the link should launch the WhatsApp website or the WhatsApp desktop client. You can play with the live sheet here.
/**
* Create WhatsApp Click to Chat Link
*
* @param {string} phone The phone number with country code
* @param {string} message The text message
* @param {boolean} web Open the message in WhatsApp web?
* @return The pre-filled message link for WhatsApp.
* @customfunction
*/functionWHATSAPP(phone, message, web){if(Array.isArray(phone)){return phone.map((row, index)=>WHATSAPP(row[0], message[index][0]), web);}const phoneNumber =String(phone).replace(/[^\d]/g,'');const messageText =encodeURIComponent(message);return web ===true?`https://web.whatsapp.com/send?phone=${phoneNumber}&text=${messageText}`:`https://wa.me/${phoneNumber}?text=${messageText}`;}
This tutorial describes how you can use the new WhatsApp API with Google Apps Script to send WhatsApp messages from Google Sheets. The same approach would also work for sending WhatsApp messages from Google Forms when new form submissions are received.
Step 1: Create a WhatsApp App
Go to developers.facebook.com and click the Create App button to create a new app that we’ll use for sending WhatsApp messages.
Select Business as the app type.
Give your app a descriptive name (do not use any Facebook trademarks like WhatsApp or Facebook in the app name) and click the Create App button to create the app.
Once the app has been created, click the WhatsApp button on the next screen to add WhatsApp sending capabilities to your app.
On the next screen, you will be required to link your WhatsApp app to your Facebook business account. You will also have the option to create a new business account if you don’t have one yet.
Step 2: Add Recipient’s phone number
Facebook will provide you with a test WhatsApp phone number that will be default sending address of your app. For recipients, you’ll have the option to add a maximum of 5 phone numbers during the development phase without having to make any payment.
Your WhatsApp app will provide you with a temporary access token that will be valid for 23 hours. Make a note of this token as we’ll need it in a later step.
Next, click the Recipient Phone Number dropdown to add up to 5 different WhatsApp phone numbers to your app. You’ll receive a verification code on the added numbers and you’ll be able to send WhatsApp messages to only numbers that have been verified with the code.
Step 3: Create WhatsApp Message Template
Switch to the template manager and create a new WhatsApp message template.
For this example, we’ll choose the category as Account Update and give a unique name for your message template. For languages, we’ll choose English for which the code language is en. If you use another language, make a note of the code language as it is required for sending messages.
Write the Personalized Message
We are using variable parameters in the message and these will be replaced with the actual values from the Google Sheet. It is very similar to markers that you may have used inside Mail Merge and Document Studio with a small difference that these are positional markers and not named markers.
Here’s our message template where variables 1 and 2 are for customer name and item name respectively.
It may take up to a minute for WhatsApp to approve your new message template.
Step 4: Send WhatsApp Messages
Now that all our configuration on the Facebook / WhatsApp side is complete, let’s work on the Google Sheet that will actually send these personalized WhatsApp messages in an automated manner.
Click here to copy the WhatsApp Sheet in your own Google account.
Next, add the phone numbers (with country code) in the Phone number column of the Google Sheet. You should only add numbers that you have verified with your test WhatsApp account in the previous step.
Then go to the Extension menu and choose Apps Script to open the underlying script. Replace WHATSAPP_ACCESS_TOKEN and WHATSAPP_TEMPLATE_NAME with the values that you have copied in the previous steps.
Click the Run button inside the Apps Script editor and it should instantly send the WhatsApp message to your listed phone numbers.
And what you have below is the actual WhatsApp message sent by the WhatsApp API replacing the variable markers in the template with actual values from Google Sheets.
The Technical Details
How WhatsApp API works with Google Apps Script
The Google Apps Script connects to Google Sheets and retrieves the details of customers, including phone numbers, that are to be sent messages through WhatsApp.
// Get data from Google Sheets// for sending messages through WhatsAppconstgetSheetData_=()=>{const sheet = SpreadsheetApp.getActiveSheet();const[header,...rows]= sheet.getDataRange().getDisplayValues();const data =[];
rows.forEach((row)=>{const recipient ={};
header.forEach((title, column)=>{
recipient[title]= row[column];});
data.push(recipient);});return data;};
Next, the script iterates through each row of the sheet and sends a WhatsApp message by invoking the WhatsApp Cloud API with the UrlFetch service.
// Send Message with WhatsApp Cloud APIconstsendMessage_=(e)=>{const apiUrl ='https://graph.facebook.com/v13.0/114746974570888/messages';const request = UrlFetchApp.fetch(apiUrl,{muteHttpExceptions:true,method:'POST',headers:{Authorization:`Bearer ${WHATSAPP_ACCESS_TOKEN}`,'Content-Type':'application/json',},payload:JSON.stringify({type:'template',messaging_product:'whatsapp',to: e.recipient_number,template:{name:WHATSAPP_TEMPLATE_NAME,language:{code:LANGUAGE_CODE},components:[{type:'body',parameters:[{type:'text',text: e.customer_name },{type:'text',text: e.item_name },{type:'text',text: e.delivery_date },],},],},}),});const{ error }=JSON.parse(request);if(error){
Logger.log(`😞 ${error}`);}else{
Logger.log(`Message sent to ${recipient_number}`);}};constmain=()=>{getSheetData_().forEach((row)=>{const status =sendMessage_({recipient_number: row['Phone Number'].replace(/[^\d]/g,''),customer_name: row['Customer Name'],item_name: row['Item Name'],delivery_date: row['Delivery Date'],});});};
This Apps Script sample shows how you can programmatically schedule video meetings inside Google Meet with one or more participants using the Google Calendar API. It can be useful for teachers who wish to schedule regular meetings with their students but instead of manually creating meeting invites, they can easily automate the whole process for the entire class.
Setup Google Meeting with Apps Script
Give your meeting a title, the start date, the meeting duration, the list of attendees and how often you wanted to be reminded of the upcoming Google meeting. A new meeting event will be added to your Google Calendar and you’ll also be provided with a Google Meet link that you share with your students and colleagues through mail merge.
constcreateGoogleMeeting=()=>{// The default calendar where this meeting should be createdconst calendarId ='primary';// Schedule a meeting for May 30, 2022 at 1:45 PM// January = 0, February = 1, March = 2, and so onconst eventStartDate =newDate(2022,5,30,13,45);// Set the meeting duration to 45 minutesconst eventEndDate =newDate(eventStartDate.getTime());
eventEndDate.setMinutes(eventEndDate.getMinutes()+45);constgetEventDate=(eventDate)=>{// Dates are computed as per the script's default timezoneconst timeZone = Session.getScriptTimeZone();// Format the datetime in `full-date T full-time` formatreturn{
timeZone,dateTime: Utilities.formatDate(eventDate, timeZone,"yyyy-MM-dd'T'HH:mm:ss"),};};// Email addresses and names (optional) of meeting attendeesconst meetingAttendees =[{displayName:'Amit Agarwal',email:'amit@labnol.org',responseStatus:'accepted',},{email:'student1@school.edu',responseStatus:'needsAction'},{email:'student2@school.edu',responseStatus:'needsAction'},{displayName:'Angus McDonald',email:'assistant@school.edu',responseStatus:'tentative',},];// Generate a random idconst meetingRequestId = Utilities.getUuid();// Send an email reminder a day prior to the meeting and also// browser notifications15 minutes before the event start timeconst meetingReminders =[{method:'email',minutes:24*60,},{method:'popup',minutes:15,},];const{ hangoutLink, htmlLink }= Calendar.Events.insert({summary:'Maths 101: Trigonometry Lecture',description:'Analyzing the graphs of Trigonometric Functions',location:'10 Hanover Square, NY 10005',attendees: meetingAttendees,conferenceData:{createRequest:{requestId: meetingRequestId,conferenceSolutionKey:{type:'hangoutsMeet',},},},start:getEventDate(eventStartDate),end:getEventDate(eventEndDate),guestsCanInviteOthers:false,guestsCanModify:false,status:'confirmed',reminders:{useDefault:false,overrides: meetingReminders,},},
calendarId,{conferenceDataVersion:1});
Logger.log('Launch meeting in Google Meet: %s', hangoutLink);
Logger.log('Open event inside Google Calendar: %s', htmlLink);};
The above code can be extended to create meetings that occur on a recurring schedule.
You need to simply add a recurrence attribute to the meeting event resource that specifies the recurring event in RRULE notation. For instance, the following rule will schedule a recurring video meeting for your Maths lecture every week on Monday, Thursday for 8 times.
Looking for a place to host images so you can embed them on to your website? The most popular image hosting services are imgur.com and imgbb.com but did you know that you can also use Google Drive to host images.
It works something like this. You upload an image file to Google Drive and make that file public. Google Drive will now generate a high-resolution thumbnail image of the uploaded file that you can directly embed on your website or emails.
Generate Google Drive Image Links
1. Share File
Go to Google Drive and upload the image that you wish to embed in your website. Next, right-click the image and choose Get link to get the shareable link of the uploaded file.
2. Change Permissions
Inside the share dialog, choose the permissions drop-down and select Anyone with a link. This will make the file visible to anyone on the internet who has access to the share link. The file will be available to even users who do not have a Google account.
Click the Copy link button to copy the file’s link to your clipboard.
3. Generate Link
Next, open the Google Drive Embed page and paste the file link in the input text box. Click the Generate button to grab the direct link of the image that you can place in your website or emails.
How Drive Image Links are Generated
Internally, the tool takes the public link of the image on your Google Drive and grabs the Open Graph image from the HTML. It then changes the s parameter of the OG image to switch to a high resolution thumbnail. It is a similar technique that we use to get direct links for Google Drive photos.
Alternate Approach
If you prefer mangling URLs on your own, here’s an alternate approach that will help you generate direct links for your drive images.
Make the image file in your Google Drive public as described earlier and grab the file link of the public image. The URL will be something like this:
You can use this link to easily embed images into Google Sheets. The only downside of this approach is that you do not have control over the size of the image that is generated. In the previous example, you can easily change the width parameter to generate images of any specific size.