はじめに
Google App Scriptを使って、Googleカレンダーに登録してある、予定のリマインドをラインに送信する方法です。
システム構成図
コード
var token = "<token>";
var google_calendar_id = '<calendar_id>';
function notify() {
var calendar = CalendarApp.getCalendarById(google_calendar_id);
var today = new Date();
var tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
var events = calendar.getEventsForDay(tomorrow);
if( events.length >= 1 ) {
var title = events[0].getTitle();
var message = title;
sendToLine(message);
}
}
function sendToLine(message){
var options =
{
"method" : "post",
"headers" : {"Authorization" : "Bearer "+ token},
"payload" : "message=" + message
};
UrlFetchApp.fetch("https://notify-api.line.me/api/notify", options);
}
ポイント
- 特定のカレンダーの明日の予定をチェックして、あればラインにメッセージを送信する
トリガーの設定

こんな感じで毎日決まって時間に実行するようにしています。