Introduction

Overview

If you plan to be away from your Gmail account—say, a vacation or a place without access to the internet—you can set up a vacation responder in Gmail to automatically notify people that you won’t be able to get back to them right away.

When the autoresponder is active, whenever somebody sends you an email, they’ll receive an email response containing what you’ve written in your vacation auto reply.

That’s all Gmail 101…

But what if you want to reply to your customer even while you are not on vacation?

(Like, for example, when your office is closed).

Well, there is a script that helps you to do that!

Video Tutorial

Setting up the Gmail AUTORESPONDER script

The instructions on this article work for Gmail or G Suite email accounts.

1 – Go to https://www.google.com/script/start/ and click on the ‘Start Scripting‘ button.

2 – Click New Script at the top left.
New Script 300x143 - How to set up a Gmail Auto Reply for Office Hours

3 – Rename the project to whatever you want (where you see “Untitled project”) – this will be the app name.

Rename Project 320x200 - How to set up a Gmail Auto Reply for Office Hours

4 –  Replace the code in Code.gs with the code below:

gs

function autoReply() {
var interval = 5; // if the script runs every 5 minutes; change otherwise
var wkend = [6,0]; // 1=Mo, 2=Tu, 3=We, 4=Th, 5=Fr, 6=Sa, 0=Su
var wkendMessage = "Hi, Thank you for contacting us. The office is now closed. All emails will be attended to when the office re-opens at 9:00am PST on Monday morning.";
var wkdayMessage = "Hi! Thank you for your email. The office hours are Mondays – Fridays 9-6pm PST. Thank you for your patience!";
var date = new Date(); var day = date.getDay(); var hour = date.getHours(); if (wkend.indexOf(day) > -1 || (day == 5 && hour >= 18)) { var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval; var threads = GmailApp.search('is:inbox after:' + timeFrom); for (var i = 0; i < threads.length; i++) { threads[i].reply(wkendMessage); } } else if (hour < 9 || hour >= 18) { var timeFrom = Math.floor(date.valueOf()/1000) - 60 * interval; var threads = GmailApp.search('is:inbox after:' + timeFrom); for (var i = 0; i < threads.length; i++) { threads[i].reply(wkdayMessage); } } }
function doGet() {
 return ContentService.createTextOutput(”");
}

5 – Customize the message based on your needs.

The current message is a generic one that is set for offices that work from 09:00AM to 18:00PM.

6 –  Customize the days based on your needs.

The current week day message will be sent from Monday to Friday.

7 – When the customization is completed, click Save and Run.

8 – Then click Publish > Deploy as Web App
Web app 300x91 - How to set up a Gmail Auto Reply for Office Hours

9 – Authorize the script with your Gmail Account.

10 – Go back into “My Projects” on the dashboard

11 – Click the 3 dots icon next to the project name

12 – Select Triggers

13 – Click on Add Triggers button will appear at the bottom right

14 – Choose next options:

Choose which function to run – Autoreply
Which runs at deployment – Head
Select Event Source – Time-Driven
Select type of time based trigger – Minutes Times
Select Minute Interval – Every 5 Minutes                
Failure Notification Settings – Notify me dail

15 – Click on save

16 – Test the script and verify it works.

Results

Voila! Your after working hours emails will be auto-replied for you!

Using this script will allow you to maintain high levels of customer service!

What do you think of this tutorial?

Article Title: How to set up a Gmail Auto Reply for Office Hours

Short Description: Learn how to set up a Gmail autoresponder that applies to certain parts of the day only.

Author: Ardian Lumi

Publisher - Orgnization: MemberFix

Publisher Logo: mermberfix logo x200 1 - How to set up a Gmail Auto Reply for Office Hours

User Review
0 (0 votes)

 

R

Now let’s hear from you!

Are you using this script for your Gmail account?

Is this article helpful for you?

Tell us in the comments section below.