Add the Email filter in the Gmail
- Create a filter (any text sent to a google voice number goes to your gmail with the following address appended to it)
- Matches: from:(@txt.voice.google.com)
- Do this: Skip Inbox, Apply label “autoreply”
Add google scripts as a document type
- Go to Google Drive
Click New –> More –> Connect more apps –> Search for “google apps scripts“ (by Google) and add it. - Now create a new script: New –> More –> Google Apps Scripts.
- Name the script “Auto Replier“
Replace what you see with the code from below :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25function autoReplier() {
var labelObj = GmailApp.getUserLabelByName('autoreply');
var gmailThreads;
var messages;
var sender;
for (var gg = 0; gg < labelObj.getUnreadCount(); gg++) {
gmailThreads = labelObj.getThreads()[gg];
messages = gmailThreads.getMessages();
for (var ii = 0; ii < messages.length; ii++) {
if (messages[ii].isUnread()) {
msg = messages[ii].getPlainBody();
sender = messages[ii].getFrom().slice(16, 74);
MailApp.sendEmail(sender, "Auto Reply", "Hi, I'm out of town till the end of the month. Talk to you then!");
messages[ii].markRead();
messages[ii].moveToTrash();
}
}
}
}After you’ve saved the code, perform these steps:
- Click Edit
- Select Current Projects Triggers
- Select autoReplier, Time-driven, Minutes timer, Everyminute
- Hit save.
- Approve any permissions that pop up.
Voila, now you have an auto reply system.
If the script doesn’t work ,please try change the codesender = messages[ii].getFrom().slice(16, 74);
tosender = messages[ii].getFrom();