Googlevoice保号——使用Google Drive里的脚本功能实现Googlevoice消息的自动回复

由于GV号超过6个月不使用会自动销号,因此使用gmail+Google Drive设置自动回复。

需要先设置Google Voice短信转发到Gmail邮箱,设置方法如下:

登录Google Voice,Settings—>Settings—>Forward messages to email,打开将短信转发到你Gmail邮箱的选项

然后在gmail中设置:

  1. Create a filter (any text sent to a google voice number goes to your gmail with the following address appended to it) --
    1. Matches: from:(@txt.voice.google.com)
    2. Do this: Skip Inbox, Apply label "autoreply"
  2. Add google scripts as a document type
    1. Go to Google Drive
    2. Click New --> More --> Connect more apps --> Search for "google apps scripts" (by Google) and add it.
  3. Now create a new script: New --> More --> Google Apps Scripts.
  4. Name the script "Auto Replier"
  5. Replace what you see with the code below the **********
    1. After you've saved the code, perform these steps:
    2. Click Edit
    3. Select Current Projects Triggers
    4. Select autoReplier, Time-driven, Minutes timer, Every minute
    5. Hit save.
    6. Approve any permissions that pop up.
  6. Voila, now you have an auto reply system.

 

**********

 

function 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(); 

 

        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();

 

      }

    }

  }

  

}

 

*****************

来自Googlevoice论坛中rahulvarshney(6/7/17)的回复

*****************

参考VPS大玩家

他的代码中有个小错误,(上文已更改)

把sender = messages[ii].getFrom().slice(16, 74);  修改为 sender = messages[ii].getFrom();即可

 

                        感谢@VPS大玩家

其中该语句的Hi, I'm out of town till the end of the month. Talk to you then!可以改为自己喜欢的内容。

MailApp.sendEmail(sender, "Auto Reply", "Hi, I'm out of town till the end of the month. Talk to you then!");

另外messages[ii].moveToTrash();可以删除或者将Trash改为gmail中任意喜欢的标签

你可能感兴趣的:(GV,Gmail)