A LINE chatbot built with Google Apps Script and TypeScript for Over Party Lab. This bot helps users search for cocktail recipes and recommendations through LINE Messaging API.
- Cocktail Search: Query cocktail recipes by name (English or Chinese)
- Smart Recommendations: Get ingredient-based cocktail suggestions when exact match is not found
- Interactive Buttons: User-friendly button templates for browsing recommendations
- User Activity Tracking: Logs user interactions to Google Sheets for analytics
- Automated Deployment: Use clasp for seamless Google Apps Script deployment
- Runtime: Google Apps Script
- Language: TypeScript
- Messaging Platform: LINE Messaging API
- Data Storage: Google Sheets
- Development Tools: clasp (Command Line Apps Script Projects)
┌─────────────┐ ┌──────────────────┐ ┌─────────────┐
│ LINE User │─────▶│ Google Apps │─────▶│ Google │
│ │◀─────│ Script (Bot) │◀─────│ Sheets │
└─────────────┘ └──────────────────┘ └─────────────┘
│
│ Data lookup
▼
Cocktail & Element
Mapping Data
- Node.js v12.0.0 or later
- npm or yarn
- Google Account
- LINE Developer Account
- LINE Messaging API Channel
# Install clasp globally
npm install -g @google/clasp
# Install project dependencies
npm install# Login to Google Account
clasp login
# Create a new Apps Script project (or clone existing one)
clasp create --type webapp --title "Over Party Lab Chatbot"
# Or clone existing project
clasp clone <SCRIPT_ID>Create a config.ts file in the root directory (see config.ts.example for template):
const CONFIG = {
LINE: {
CHANNEL_ACCESS_TOKEN: 'YOUR_LINE_CHANNEL_ACCESS_TOKEN',
URL_LINE: 'https://api.line.me/v2/bot/message/'
},
GOOGLE_SHEET: {
API_KEY: 'YOUR_GOOGLE_SHEET_ID'
},
COLUMN_KEY_MAPPING: {
name: 1,
nameen: 2,
link: 3,
detail: 4,
recommendation: 5
},
OVERPARTYLAB: {
IG: 'https://www.instagram.com/over.party.lab/'
},
CONFIG_DEBUG: {
USERID: 'YOUR_LINE_USER_ID_FOR_TESTING'
}
};
export default CONFIG;Create a Google Sheet with the following tabs:
- DRINK_LIST: Contains cocktail data
- Columns:
name,nameen,link,detail
- Columns:
- ELEMENT_MAPPING: Contains ingredient recommendations
- Columns:
name,nameen,recommendation
- Columns:
- USER_ACTION: Logs user interactions
- Columns:
index,search,user,time
- Columns:
# Push code to Google Apps Script
clasp push
# Deploy as web app
clasp deploy- Get your web app URL from Google Apps Script
- Go to LINE Developers Console
- Set webhook URL to your deployed Google Apps Script URL
- Enable webhook
# Pull latest code from Google Apps Script
clasp pull
# Push local changes to Google Apps Script
clasp push
# Watch for changes and auto-push
clasp push --watchUse the debug functions in debug.ts:
// Test POST endpoint
test_post();
// Test sending message
test_send();.
├── app.ts # Main application logic and webhook handler
├── lineService.ts # LINE Messaging API service
├── sheetService.ts # Google Sheets operations
├── logService.ts # Logging utility
├── timeService.ts # Time formatting utility
├── wording.ts # Response message templates
├── debug.ts # Testing utilities
├── config.ts # Configuration (gitignored)
├── appsscript.json # Apps Script manifest
├── package.json # Node.js dependencies
└── tsconfig.json # TypeScript configuration
- User sends message via LINE
- Webhook triggers
doPost()function in Google Apps Script - Bot parses message and searches Google Sheets for matching cocktail
- If found: Returns cocktail details and link
- If not found: Searches for ingredient-based recommendations
- Bot responds with text or button template messages
- User action logged to Google Sheets
doPost(e): Webhook handler for LINE messageslineService.pushMsg(config): Send messages to LINEsheetService.query(params): Query Google Sheets datasheetService.save(params): Save user actions
{
"timeZone": "Asia/Hong_Kong",
"webapp": {
"access": "ANYONE_ANONYMOUS",
"executeAs": "USER_DEPLOYING"
},
"exceptionLogging": "STACKDRIVER"
}Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- How to create a LINE chatbot using Google Apps Script
- Using clasp and TypeScript to develop Google Apps Script
- LINE Messaging API Documentation
- Google Apps Script Documentation
- clasp Documentation
Sean Chou - GitHub
- Over Party Lab - Cocktail community
- LINE Messaging API
- Google Apps Script Platform
