This project integrates LINE Messaging API with Google Apps Script to send automated emails and screenshots when a train delay occurs. The steps below will guide you through the setup process.
- Go to Google Apps Script.
- Create a new project.
- Copy the code from GitHub (omit the
README.md
file).
-
Create a LINE Messaging API Channel:
- Visit the LINE Developers Console.
- Create a New Provider (if you don’t already have one).
- Create a New Channel and choose Messaging API.
- Obtain your Channel Access Token.
- Replace the
MY_TOKEN
placeholder inconfig.gs
with your Channel Access Token.
- Create a New Google Sheet:
- Go to Google Sheets and create a new blank spreadsheet.
- Copy the Sheet ID from the URL (the long string between
/d/
and/edit
). - Replace the
sheetId
placeholder inconfig.gs
with your Google Sheets ID.
- Create a New Folder in Google Drive:
- Go to Google Drive.
- Click New and select Folder to create a new folder.
- Copy the Folder ID from the URL (the string after
/folders/
). - Replace the
screenshotfolder
placeholder inconfig.gs
with your Folder ID.
-
Deploy the Script as a Web App:
- In Apps Script, click Deploy → Test Deploy → Manage Deployments.
- Choose Web App and give it a name.
- Set the App Executer to your Google Account.
- Set Access to Anyone (even anonymous).
- Click Deploy, and copy the Webhook URL.
-
Configure Webhook in LINE Developers Console:
- Go back to the LINE Developers Console.
- Open your Messaging API Channel.
- Under Messaging API Settings, paste the copied Webhook URL and save.
- Enable Webhooks under the Response Settings and disable the other options.
-
In the LINE Developers Console:
- Go to Home → Rich Menus → Create a new menu.
- Configure your template and set up delays for sending the messages.
-
To change the time when the email is sent:
- Open
settime.gs
and modify the first parameter (1 for 1 minute, 240 for 4 hours). - After updating, deploy the changes and replace the Webhook URL in LINE Developers Console with the new URL from the deployment.
- Open
Once the bot's rich menu and delay settings are configured:
- When the Delay button is pressed, the system will automatically send a delay notification email to the designated teacher.
- After the specified delay, a screenshot of the delay certificate will also be sent automatically.
- Google Apps Script account
- LINE Messaging API account
- Google Sheets and Google Drive access
- Special thanks to Yu (@LiuYuRungGitHub) for her contribution to the
reply.gs
,screenshot.gs
,geturl.gs
andsettime.gs
files. Her work on the response handling logic has been invaluable!
This project is licensed under the MIT License - see the LICENSE file for details.