line-oa
通过浏览器自动化操作 LINE 官方客户管理器 (chat.line.biz)。当要求检查 LINE 消息、回复 LINE 客户或管理 LINE OA 聊天界面时使用。
安装 / 下载方式
TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~picseeinc-line-oacURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~picseeinc-line-oa/file -o picseeinc-line-oa.md# LINE Official Account Manager
⚠️ **CRITICAL**: Always use `profile:"openclaw"` (isolated browser) for all browser actions. Never use Chrome relay. Keep the same `targetId` across operations to avoid losing the tab.
⚠️ **CONTEXT Management**:
- Snapshot results are large. Do NOT repeat them in thinking.
- Extract needed info and process immediately. Do not re-describe the entire snapshot.
- **Preferred approach**: Use `snapshot refs:"aria" compact:true` to find element refs, then `act` + `click`/`type` with ref.
- **Avoid**: Hard-coded `evaluate` with `textContent.includes()` — unreliable due to DOM timing and structure variations.
⚠️ **AUTO-LOGIN SCRIPTS**:
- `auto-login.mjs` is a **reference implementation** (not directly executable by agents)
- `login-flow.md` is the **agent-executable version** (use this for automation)
- **Why separate?** Agents use browser tool calls, not Node module imports
## Configuration
Before first use, check if `config.json` exists:
```
read file_path:"skills/line-oa/config.json"
```
⚠️ **PATH RULE**: Always use workspace-relative paths starting from `skills/line-oa/`. Never use `../` or absolute paths starting with `/`.
If missing, help the user run the following command to start the setup wizard:
```bash
cd skills/line-oa
node scripts/setup.js
```
# Enter LINE OA Manager
This is the first step for all operations below.
1. **Check and start browser service:**
```
browser action:"status"
```
If `"running": false`, start the browser service:
```
browser action:"start" profile:"openclaw"
```
Wait 2-3 seconds for the service to initialize.
2. **Read config to get chatUrl:**
```
read file_path:"skills/line-oa/config.json"
```
Extract `chatUrl` from the JSON (e.g., `https://chat.line.biz/U1234567890abcdef1234567890abcdef/`).
2. **Open browser:**
```
browser action:"open" profile:"openclaw" targetUrl:"<chatUrl>"
```
Capture `targetId` and `url` from response.
3. **Wait for page load:**
```
browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"wait","timeMs":2000}
```
4. **Check current URL:**
```
browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"evaluate","fn":"function(){return window.location.href;}"}
```
Key result: If the current URL matches `chatUrl`, you have successfully logged in! Go to step 5, else proceed to troubleshooting.
### Troubleshooting
If you see the login page (the URL redirects to `account.line.biz`), use these automation scripts:
a. **Click LINE Account button:**
```
read file_path:"skills/line-oa/scripts/click-line-account.js"
```
Execute the script directly:
```
browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"evaluate","fn":"<script_content>"}
```
Wait 2 seconds.
b. **Click Login button:**
```
read file_path:"skills/line-oa/scripts/click-login.js"
```
Execute the script directly:
```
browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"evaluate","fn":"<script_content>"}
```
Wait 3 seconds.
c. **Reload chatUrl:**
```
browser action:"navigate" profile:"openclaw" targetId:"<targetId>" targetUrl:"<chatUrl>"
```
Wait 2 seconds, then take snapshot to verify left-side chat list is visible.
### After Check
5. **Proceed with the user's other requests.**
6. **Clean Up Browser Tabs**:
a. Open a blank tab:
```
browser action:"open" profile:"openclaw" targetUrl:"about:blank"
```
b. Get all tabs:
```
browser action:"tabs" profile:"openclaw"
```
c. Close all tabs except the newest one (about:blank):
```
browser action:"close" profile:"openclaw" targetId:"<your_targetId>"
```
**Important**: Always clean up tabs after all operations to prevent resource accumulation. The blank tab keeps the browser service running for faster next use.
## Quick Check (for cron / automated checks)
Complete flow: login → list chats → report. Follow these steps exactly.
1. Read config: `read file_path:"skills/line-oa/config.json"` → get `chatUrl`
2. Open browser: `browser action:"open" profile:"openclaw" targetUrl:<chatUrl>` → get `targetId`
3. Wait: `browser action:"act" profile:"openclaw" targetId:<targetId> request:{"kind":"wait","timeMs":3000}`
4. Check URL: `browser action:"act" profile:"openclaw" targetId:<targetId> request:{"kind":"evaluate","fn":"function(){return window.location.href;}"}`
- If URL contains `account.line.biz` → go to **Troubleshooting** section below to login, then come back
- If URL contains `chat.line.biz` → continue
5. Run this one-liner script **as-is, do not modify**:
```
browser action:"act" profile:"openclaw" targetId:<targetId> request:{"kind":"evaluate","fn":"(function(){var r=document.querySelectorAll('.list-group-item-chat');return Array.from(r).map(function(e){var h=e.querySelector('h6');var p=e.querySelector('.text-muted.small');var pt=p?p.textContent.trim():'';var ms=e.querySelectorAll('.text-muted');var t='';for(var i=0;i<ms.length;i++){var v=ms[i].textContent.trim();if(v&&v.length<20&&v!==pt)t=v;}var d=e.querySelector('span.badge.badge-pin');var u=!!d&&getComputedStyle(d).display!=='none';return{name:h?h.textContent.trim():'',time:t,lastMsg:pt.substring(0,100),unread:u};}).filter(function(i){return i.name;});})()"}
```
⚠️ **CHECKPOINT**: Did you actually call the browser tool above? If you only thought about it but didn't call it, STOP and call it NOW. You MUST see a tool result before continuing.
6. Report: take the first 5 items, format each as: `<name> (<time>) <lastMsg> [未讀]` or `[已讀]` based on `unread` field. If empty array, say "目前沒有聊天記錄".
7. Clean up: open `about:blank`, list all tabs, close everything except `about:blank`.
---
## Check LINE Messages
Extracts all chats from the left-side chat list with unread status. Does NOT require clicking into each chat.
**Prerequisites**: You must be logged in and on the chat list page (see Login section Step 5 for verification).
### Steps
1. Read the script content:
```
read file_path:"skills/line-oa/scripts/list-chats.js"
```
2. Run the script via browser evaluate:
Pass the script content directly as the `fn` parameter:
```
browser action:"act" profile:"openclaw" targetId:"<your_targetId>" request:{"kind":"evaluate","fn":"<script_content>"}
```
3. The script returns a JSON array of **all** chat items with structure:
```
[{ name: string, time: string, lastMsg: string, unread: boolean }]
```
- `name`: customer display name
- `time`: timestamp (e.g., "21:32", "Yesterday", "Friday")
- `lastMsg`: last message preview (~100 chars)
- `unread`: `true` if green dot present, `false` otherwise
4. **Get URLs for unread chats** (optional but recommended for faster follow-up):
For each unread chat, click into it to get the direct URL, then return to list:
```
browser action:"act" profile:"openclaw" targetId:"<your_targetId>" request:{"kind":"evaluate","fn":"function(){const items=document.querySelectorAll('.list-group-item-chat');const target=Array.from(items).find(el=>{const h6=el.querySelector('h6');return h6&&h6.textContent.includes('<customer_name>');});if(target){const link=target.querySelector('a.d-flex');if(link){link.click();return {clicked:true};}return {linkNotFound:true};}return {itemNotFound:true};}"}
```
Wait 500ms, then get the URL:
```
browser action:"act" profile:"openclaw" targetId:"<your_targetId>" request:{"kind":"evaluate","fn":"function(){return window.location.href;}"}
```
Navigate back to list:
```
browser action:"navigate" profile:"openclaw" targetId:"<your_targetId>" targetUrl:"<chatUrl>"
```
Wait 1 second before processing next unread chat.
**Result**: Store the chat URL (e.g., `https://chat.line.biz/U1234567890abcd