Using Google Apps Script, you can receive LINE notifications when Gmail arrives.
In the following example, we use ‘subject:(Keepa.com) ’, which is configured to notify LINE when email from Keepa is received.
Keepa is set to notify on my computer, so I notice it when I’m at my computer, but I can’t check it on my smartphone when I’m out or in the bath. However, by notifying through LINE, I can check it by just opening LINE on my smartphone.
Receiving LINE Notifications when Gmail Arrives using Google Apps Script
// Notify Gmail to LINE based on search results
// Search
var FindSubject = 'subject:(Keepa.com) ';
function getMail(){
// Search and get threads with the specified subject
var myThreads = GmailApp.search(FindSubject, 0, 10);
// Get messages from threads and store in 2D array
var myMessages = GmailApp.getMessagesForThreads(myThreads);
for(var i in myMessages){
for(var j in myMessages[i]){
// Process only messages without stars
if(!myMessages[i][j].isStarred()){
var strDate = myMessages[i][j].getDate();
var strSubject = myMessages[i][j].getSubject();
var strMessage = myMessages[i][j].getPlainBody().slice(0,200);
// Send message to LINE
sendLine(strDate,strSubject,strMessage);
// Star processed messages
myMessages[i][j].star();
}
}
}
}
function sendLine(strDate,strSubject,strMessage){
// Token for sending to Line
var strToken = "";
var options =
{
"method" : "post",
"payload" : "message=" + strDate + strSubject + strMessage,
"headers" : {"Authorization" : "Bearer "+ strToken}
};
UrlFetchApp.fetch("https://notify-api.line.me/api/notify",options);
}
- Open the editor from a spreadsheet and copy-paste the above code.
- Access [https://notify-bot.line.me/ja/](https://notify-bot.line.me/ja/) to issue a LINE token.
- Fill in // Search and // Token for sending to Line.
- Set it to run periodically in Edit > Current Project's Triggers.
I referred to this.