Anyway, these days I want to automate various things, but this time it is a method of “notifying LINE when a specific email arrives in Gmail and marking it as read”.
![](https://eguweb.jp/wp-content/uploads/202106302031-00-2.jpg)
Use LINE Notify
This time, I will try using “LINE Notify”, which has been indebted to me before.
![](https://eguweb.jp/wp-content/uploads/202106302031-01-4-1024x615.jpg)
![](http://en.eguweb.jp/wp-content/uploads/cocoon-resources/blog-card-cache/cff42f16916b88efcfc7e93d6cc14e45.png)
LINE NotifyLINE Notify is a convenient service that allows you to receive notifications from web services such as GitHub, IFTTT, and Mackerel on LINE.
![](http://en.eguweb.jp/wp-content/plugins/a3-lazy-load/assets/images/lazy_placeholder.gif)
notify-bot.line.me
With this LINE Notify, you can easily create a LINE notification bot. I am very grateful that we are now in an era where anyone can easily create bots.
![](https://eguweb.jp/wp-content/uploads/202106302032-00-4-1024x437.jpg)
After logging in with your LINE account, specify a specific group and issue a token. In the case of a group where other people are also participating, everyone will receive a notification, so be careful.
![](https://eguweb.jp/wp-content/uploads/202106302036-01-4.jpg)
token issuance
A token will be issued. This LINE Notify token will not be displayed again if you close the screen, so be sure to make a copy at this point . If you accidentally close the screen, you will have to start over from scratch.
![](https://eguweb.jp/wp-content/uploads/202106302037-00-4.jpg)
Prepare variables for tokens
First, let’s put the token we copied earlier into a global variable.
![](https://eguweb.jp/wp-content/uploads/202106302047-00-1024x360.jpg)
//LINE notify TOKEN
const NOTIFY_TOKEN = "XXXXXXXXXXXXXXXXXXXX";
prepare sendLineMessage() function
After preparing the sendLineMessage() function, set UrlFetchApp.fetch.
function sendLineMessage(){
const options =
{
"method" : "post",
"payload" : "message=テスト",
"headers" : {"Authorization" : "Bearer "+ NOTIFY_TOKEN}
};
UrlFetchApp.fetch("https://notify-api.line.me/api/notify",options);
}
![](http://en.eguweb.jp/wp-content/uploads/cocoon-resources/blog-card-cache/8950d7ce9896874c0bf3ce254613f09b.png)
Class UrlFetchApp | Apps Script | Google Developers
![](http://en.eguweb.jp/wp-content/plugins/a3-lazy-load/assets/images/lazy_placeholder.gif)
developers.google.com
I wrote about UrlFetchApp.fetch in another article, so please search the site.
At this point, it should work fine…
script, run.
Try “▶execute” directly from the GAS file. As usual, “Approval is required” is displayed, so check the authority → execute permission and proceed.
![](https://eguweb.jp/wp-content/uploads/202106302054-00-1024x472.jpg)
![](https://eguweb.jp/wp-content/uploads/202106302054-01.jpg)
![](https://eguweb.jp/wp-content/uploads/202106302054-02-1024x505.jpg)
message is arriving
I got your message! !
![](https://eguweb.jp/wp-content/uploads/202106302349-00-1-1024x484.jpg)
summary
So, for the time being, you can now select “Execute script” → “Send message to LINE Notify”.
Next time, we’ll add a trick to this script to get messages from Gmail and send them!
Please refer to it