🎬 วิดีโอภาพรวม
Video Overview
ดูวิดีโอภาษาไทยอธิบายสถาปัตยกรรมและการใช้งาน OpenClaw + LINE (1:52)
🎯 ภาพรวม — มันทำงานยังไง?
Overview — How Does It Work?
🇹🇭 ภาษาไทย
ลองนึกภาพว่าคุณพิมพ์ข้อความใน LINE บนมือถือ แล้วข้อความนั้นวิ่งไปหา AI ที่รันอยู่บนคอมพิวเตอร์ของคุณเอง แล้ว AI ก็ตอบกลับมาใน LINE ทันที — หรือแม้แต่สั่งรันคำสั่งบนคอมของคุณได้!
OpenClaw คืออะไร? มันคือ แพลตฟอร์ม AI ส่วนตัว ที่เป็น open-source (ฟรี) คล้ายๆ กับ Claude Code แต่ออกแบบมาให้เชื่อมต่อกับแอปแชทหลายตัว รวมถึง LINE เขียนด้วย TypeScript และติดตั้งผ่าน npm
ระบบทำงานโดย:
- OpenClaw Gateway — รันบนคอมของคุณ เป็นศูนย์กลางรับ-ส่งข้อความ
- LINE Plugin — ปลั๊กอินในตัวที่เชื่อมต่อกับ LINE Messaging API
- AI Model (ChatGPT/Claude) — สมองของระบบ สร้างคำตอบอัจฉริยะ
- exec — เครื่องมือที่ให้ AI รันคำสั่งบนคอมของคุณได้!
🇬🇧 English
Imagine typing a message in LINE on your phone and having it go to an AI running on your own computer. The AI replies in LINE — or even runs commands on your PC!
OpenClaw is a free, open-source personal AI assistant platform, similar to Claude Code. It's written in TypeScript, installed via npm, and designed to connect to many chat apps — including LINE.
Here's how it works:
- OpenClaw Gateway — runs on your computer as the central message hub
- LINE Plugin — a built-in plugin that connects to LINE Messaging API
- AI Model (ChatGPT/Claude) — the brain that generates intelligent answers
- exec — a tool that lets the AI execute commands on your PC!
🔄 How the System Works — ระบบทำงานอย่างไร
User sends message
ผู้ใช้พิมพ์ข้อความ
ngrok / Tailscale
อุโมงค์สู่คอมคุณ
Gateway on your PC
เกตเวย์บนคอมคุณ
ChatGPT / Claude
สร้างคำตอบ
The AI can also run commands on your PC via the exec tool, then reply back through LINE!
AI ยังสั่งรันคำสั่งบนคอมคุณผ่านเครื่องมือ exec แล้วตอบกลับผ่าน LINE ได้!
🌟 Fun Facts — ข้อเท็จจริงน่าสนใจ
- OpenClaw supports 22+ messaging channels — LINE, WhatsApp, Telegram, Discord, Slack and more! — OpenClaw รองรับมากกว่า 22 แอปแชท!
- OpenClaw is MIT-licensed and free to use — anyone can download and run it — OpenClaw ฟรีและเปิดให้ใครก็ได้ใช้
- It can use different AI models — ChatGPT, Claude, and others — with automatic failover — ใช้ AI ได้หลายรุ่น มีระบบสำรองอัตโนมัติ
- The AI can run commands on your computer — open files, check weather, control your PC from LINE! — AI สั่งรันคำสั่งบนคอมได้ เปิดไฟล์ เช็คสภาพอากาศ ควบคุมคอมจาก LINE!
🧪 Section Check — ตรวจสอบความเข้าใจ
System Overview & Conditionals — ภาพรวมระบบและ If...then
If a user sends a message in LINE, ______ OpenClaw's Gateway receives it through a tunnel.
ถ้าผู้ใช้ส่งข้อความใน LINE ______ Gateway ของ OpenClaw จะรับข้อความผ่านอุโมงค์
What is OpenClaw?
OpenClaw คืออะไร?
Complete: "If you run OpenClaw on your computer, you ______ need to rent a cloud server."
เติมคำ: "ถ้าคุณรัน OpenClaw บนคอม คุณ______ ต้องเช่า cloud server"
📚 คำศัพท์สำคัญ
Key Vocabulary
แพลตฟอร์ม AI ส่วนตัวแบบ open-source ที่รันบนคอมของคุณ เชื่อมต่อกับแอปแชทกว่า 22 ตัว (รวมถึง LINE)
ศูนย์กลางของ OpenClaw ที่รันบนคอมของคุณ รับข้อความจากทุกช่องทางแล้วส่งไปให้ AI ประมวลผล
URL ที่รับข้อมูลอัตโนมัติเมื่อมีเหตุการณ์เกิดขึ้น LINE ส่งข้อความไปที่ webhook ของ OpenClaw
รหัสลับที่ให้โปรแกรมเข้าถึงบริการออนไลน์ได้ ต้องมี API key สำหรับ LINE และ AI model
การเชื่อมต่อที่ปลอดภัยที่ทำให้คอมเข้าถึงจากอินเทอร์เน็ตได้ ใช้ ngrok หรือ Tailscale Funnel
เครื่องมือของ OpenClaw ที่ให้ AI รันคำสั่งบนคอมของคุณ สั่งเปิดไฟล์ เช็คข้อมูลระบบ หรือรันสคริปต์ได้!
🛠️ สิ่งที่ต้องเตรียม
What You Need Before Starting
🇹🇭 ภาษาไทย
ก่อนเริ่มลงมือทำ ให้เตรียมสิ่งเหล่านี้:
| สิ่งที่ต้องมี | รายละเอียด |
|---|---|
| 💻 คอมพิวเตอร์ | Windows, Mac หรือ Linux — เปิดไว้ตลอดเวลาที่ต้องการให้บอททำงาน |
| 📦 Node.js 18+ | JavaScript runtime ที่ใช้รัน OpenClaw (ดาวน์โหลดจาก nodejs.org) |
| 📱 บัญชี LINE Developers | สมัครฟรีที่ LINE Developers Console |
| 🔑 OpenAI API Key | สมัครที่ OpenAI แล้วสร้าง API key (มีค่าใช้จ่ายเล็กน้อย) — หรือใช้ Claude API ก็ได้ |
| 🌐 ngrok หรือ Tailscale | สร้างอุโมงค์ให้ LINE เข้าถึงคอมคุณจากอินเทอร์เน็ต (ทั้งสองตัวมีแบบฟรี) |
🇬🇧 English
Before you start building, prepare these things:
| What You Need | Details |
|---|---|
| 💻 A Computer | Windows, Mac, or Linux — must stay on while the bot is running |
| 📦 Node.js 18+ | JavaScript runtime needed to run OpenClaw (download from nodejs.org) |
| 📱 LINE Developers Account | Sign up free at the LINE Developers Console |
| 🔑 OpenAI API Key | Sign up at OpenAI and create an API key (small cost) — or use Claude API instead |
| 🌐 ngrok or Tailscale | Creates a tunnel so LINE can reach your computer from the internet (both have free tiers) |
⚠️ Important — สำคัญ
English: If your computer goes to sleep or shuts down, the bot will stop working. If you want a bot that runs 24/7, you need to keep your computer on or use a cloud server instead.
ไทย: ถ้าคอมพิวเตอร์ดับหรือ sleep บอทจะหยุดทำงาน ถ้าต้องการบอทที่ทำงาน 24 ชั่วโมง ต้องเปิดคอมไว้ตลอดหรือใช้ cloud server แทน
📋 ขั้นตอนการติดตั้ง
Step-by-Step Setup Guide
1 สร้าง LINE Bot — Create a LINE Bot
🇹🇭 ภาษาไทย
1. ไปที่ LINE Developers Console แล้วล็อกอินด้วยบัญชี LINE ของคุณ
2. สร้าง Provider ใหม่ (ตั้งชื่ออะไรก็ได้ เช่น "My AI Bot")
3. สร้าง Messaging API Channel ใหม่
4. ไปที่แท็บ Messaging API แล้วคลิก Issue เพื่อสร้าง Channel Access Token
5. คัดลอก Channel Access Token และ Channel Secret เก็บไว้
🇬🇧 English
1. Go to the LINE Developers Console and log in with your LINE account
2. Create a new Provider (name it anything, e.g., "My AI Bot")
3. Create a new Messaging API Channel
4. Go to the Messaging API tab and click Issue to generate a Channel Access Token
5. Copy both the Channel Access Token and Channel Secret
💡 Tip — เคล็ดลับ
English: If you already have a LINE bot from a previous lesson, you can reuse it! Just update the webhook URL later.
ไทย: ถ้ามี LINE bot จากบทเรียนก่อนแล้ว ใช้ตัวเดิมได้เลย! แค่อัปเดต webhook URL ทีหลัง
2 ติดตั้ง OpenClaw — Install OpenClaw
🇹🇭 ภาษาไทย
เปิด Terminal (Mac/Linux) หรือ Command Prompt (Windows) แล้วพิมพ์คำสั่งเหล่านี้:
🇬🇧 English
Open Terminal (Mac/Linux) or Command Prompt (Windows) and type these commands:
npm install -g openclaw
# Install the LINE plugin (ติดตั้งปลั๊กอิน LINE)
openclaw plugins install @openclaw/line
# Start the Gateway for the first time (เริ่ม Gateway ครั้งแรก)
openclaw gateway start
💡 Tip — เคล็ดลับ
English: If you don't have Node.js, download it from nodejs.org first. npm comes included with Node.js.
ไทย: ถ้ายังไม่มี Node.js ให้ดาวน์โหลดจาก nodejs.org ก่อน npm จะมาพร้อมกับ Node.js
3 ตั้งค่า — Configure OpenClaw
🇹🇭 ภาษาไทย
แก้ไขไฟล์ตั้งค่าที่ ~/.openclaw/openclaw.json (OpenClaw สร้างไฟล์นี้ให้อัตโนมัติเมื่อเริ่มครั้งแรก)
ใส่ข้อมูล AI model และ LINE credentials:
🇬🇧 English
Edit the config file at ~/.openclaw/openclaw.json (OpenClaw creates this automatically on first start)
Add your AI model settings and LINE credentials:
// ไฟล์ตั้งค่าของ OpenClaw
{
// AI Model settings (ตั้งค่า AI model)
"model": "openai/gpt-4o-mini",
// Channel settings (ตั้งค่าช่องทาง)
"channels": {
"line": {
"enabled": true,
"channelAccessToken": "YOUR_LINE_TOKEN_HERE",
"channelSecret": "YOUR_LINE_SECRET_HERE",
"dmPolicy": "pairing"
}
}
}
⚠️ Security — ความปลอดภัย
English: Never share your openclaw.json publicly! It contains your API keys. If someone gets your keys, they can use your account and you will be charged.
ไทย: อย่าแชร์ไฟล์ openclaw.json ให้ใคร! มันมี API keys ของคุณ ถ้าใครได้ key ไปจะใช้บัญชีของคุณได้
4 สร้างอุโมงค์ — Create a Tunnel
🇹🇭 ภาษาไทย
LINE ต้องส่งข้อความมาที่คอมของคุณผ่านอินเทอร์เน็ต แต่คอมคุณอยู่หลัง router ต้องสร้าง "อุโมงค์" ให้ LINE เข้าถึงได้
เปิด Terminal อีกหน้าต่างหนึ่ง แล้วพิมพ์:
🇬🇧 English
LINE needs to send messages to your computer through the internet, but your computer is behind a router. You need to create a "tunnel" so LINE can reach it.
Open another Terminal window and type:
ngrok http 18789
# Option 2: Using Tailscale Funnel (ตัวเลือก 2: ใช้ Tailscale)
tailscale funnel 18789
🇹🇭 สิ่งที่จะเห็น (ngrok)
ngrok จะแสดง URL แบบนี้:
Forwarding https://abc123.ngrok-free.app → http://localhost:18789
คัดลอก URL ที่ขึ้นต้นด้วย https://
🇬🇧 What You'll See (ngrok)
ngrok will show a URL like:
Forwarding https://abc123.ngrok-free.app → http://localhost:18789
Copy the URL that starts with https://
5 ตั้งค่า Webhook URL — Set the Webhook URL in LINE
🇹🇭 ภาษาไทย
1. กลับไปที่ LINE Developers Console
2. ไปที่แท็บ Messaging API
3. ในส่วน Webhook URL ใส่ URL จาก ngrok แล้วเพิ่ม /line/webhook ต่อท้าย
4. เปิดใช้งาน "Use webhook"
5. คลิก Verify — ถ้าขึ้น "Success" แสดงว่าเชื่อมต่อสำเร็จ!
🇬🇧 English
1. Go back to the LINE Developers Console
2. Go to the Messaging API tab
3. In the Webhook URL field, paste your tunnel URL and add /line/webhook at the end
4. Enable "Use webhook"
5. Click Verify — if it says "Success", the connection works!
# URL webhook ของคุณจะหน้าตาแบบนี้:
https://abc123.ngrok-free.app/line/webhook
6 ทดสอบ! — Test It!
🇹🇭 ภาษาไทย
1. ตรวจสอบว่า OpenClaw Gateway ยังทำงานอยู่ (ดูใน Terminal ที่รัน openclaw gateway start)
2. เปิด LINE บนมือถือ
3. เพิ่มบอทเป็นเพื่อน (สแกน QR Code จาก LINE Developers Console)
4. พิมพ์ข้อความอะไรก็ได้ เช่น "สวัสดี" หรือ "What is AI?"
5. รอสักครู่ แล้ว AI จะตอบกลับมาใน LINE! 🎉
🇬🇧 English
1. Make sure the OpenClaw Gateway is still running (check the Terminal with openclaw gateway start)
2. Open LINE on your phone
3. Add the bot as a friend (scan the QR Code from LINE Developers Console)
4. Type any message, like "Hello" or "What is AI?"
5. Wait a moment, and the AI will reply on LINE! 🎉
🧪 Section Check — ตรวจสอบความเข้าใจ
Setup Steps & Conditionals — ขั้นตอนติดตั้งและ If...then
What should you add to the end of the tunnel URL when setting the webhook in LINE?
คุณต้องเพิ่มอะไรต่อท้าย URL ของอุโมงค์เมื่อตั้ง webhook ใน LINE?
Complete: "If the config file is missing the API key, the AI ______ generate responses."
เติมคำ: "ถ้าไฟล์ config ไม่มี API key AI ______ สร้างคำตอบได้"
What port does the OpenClaw Gateway run on by default?
OpenClaw Gateway รันบน port อะไรโดยปริยาย?
ngrok http 18789. — Gateway รันบน port 18789 โดยปริยาย🖥️ สั่งงานคอมจาก LINE!
Running PC Commands from LINE!
🇹🇭 ภาษาไทย
นี่คือส่วนที่เจ๋งที่สุด! OpenClaw มีเครื่องมือ exec ที่ให้ AI รันคำสั่งบนคอมของคุณได้ แปลว่าคุณสามารถพิมพ์ข้อความใน LINE บนมือถือ แล้ว AI จะไปทำงานบนคอมพิวเตอร์ของคุณจริงๆ!
ตัวอย่างสิ่งที่ทำได้:
- ถาม "คอมฉันเหลือ disk space เท่าไหร่?" → AI รันคำสั่งเช็คแล้วตอบกลับ
- สั่ง "เปิดไฟล์ report.pdf" → AI เปิดไฟล์ให้บนคอม
- ถาม "process อะไรกิน RAM เยอะสุด?" → AI เช็คแล้วบอก
- สั่ง "สร้างโฟลเดอร์ใหม่ชื่อ photos" → AI สร้างให้เลย
🇬🇧 English
This is the coolest part! OpenClaw has an exec tool that lets the AI execute commands on your computer. This means you can type a message in LINE on your phone and the AI will actually do things on your PC!
Examples of what you can do:
- Ask "How much disk space is left?" → AI runs the command and replies
- Say "Open the file report.pdf" → AI opens it on your computer
- Ask "What process is using the most RAM?" → AI checks and tells you
- Say "Create a new folder called photos" → AI creates it
⚠️ Security — ความปลอดภัย
English: The exec tool gives the AI access to run commands on your computer. OpenClaw has security features like DM pairing (unknown users get a pairing code) and sandbox mode (group chats can be sandboxed in Docker). But be careful — only pair with people you trust!
ไทย: เครื่องมือ exec ให้ AI เข้าถึงคอมของคุณได้ OpenClaw มีระบบความปลอดภัยเช่น DM pairing (คนแปลกหน้าต้องใส่รหัสจับคู่) และ sandbox mode (แชทกลุ่มจำกัดสิทธิ์ใน Docker) แต่ระวัง — จับคู่กับคนที่ไว้ใจเท่านั้น!
🎨 ปรับแต่งบอทของคุณ
Customizing Your Bot
🇹🇭 ภาษาไทย
คุณสามารถเปลี่ยน AI model ที่ใช้ได้ในไฟล์ openclaw.json:
🇬🇧 English
You can change which AI model to use in the openclaw.json config:
| Model / โมเดล | Config Value / ค่าตั้ง | Notes / หมายเหตุ |
|---|---|---|
| 🧠 GPT-4o Mini | "openai/gpt-4o-mini" |
Fast and cheap — เร็วและถูก |
| 🧠 GPT-4o | "openai/gpt-4o" |
More capable, slightly slower — ฉลาดกว่า ช้ากว่านิดหน่อย |
| 🤖 Claude Sonnet | "anthropic/claude-sonnet-4-6" |
Excellent at Thai! — เก่งภาษาไทยมาก! |
| 🤖 Claude Opus | "anthropic/claude-opus-4-6" |
Most capable model — โมเดลที่เก่งที่สุด |
💡 Pro Tip — เคล็ดลับมือโปร
English: OpenClaw supports model failover — if one model is unavailable, it automatically switches to a backup. You can also set up different models for different channels!
ไทย: OpenClaw รองรับ model failover — ถ้าโมเดลหนึ่งใช้ไม่ได้ จะสลับไปใช้โมเดลสำรองอัตโนมัติ ตั้งค่าโมเดลต่างกันสำหรับแต่ละช่องทางได้!
🔧 แก้ปัญหาที่พบบ่อย
Common Problems & Solutions
| Problem / ปัญหา | Solution / วิธีแก้ |
|---|---|
| ❌ LINE says "Webhook verification failed" LINE แจ้ง "Webhook verification failed" |
Make sure both the Gateway AND the tunnel (ngrok) are running. Check that the URL ends with /line/webhookตรวจสอบว่า Gateway และ tunnel ทำงานอยู่ และ URL ลงท้ายด้วย /line/webhook |
| ❌ Bot doesn't reply บอทไม่ตอบ |
Check your openclaw.json — make sure the AI model API key is correct. Check the Terminal for errors. ตรวจไฟล์ openclaw.json ว่า API key ถูกต้อง ดู error ใน Terminal |
| ❌ ngrok URL changed URL ของ ngrok เปลี่ยน |
Free ngrok gives a new URL every restart. Update the Webhook URL in LINE Developers Console. Consider Tailscale Funnel for a stable URL. ngrok ฟรีให้ URL ใหม่ทุกครั้ง อัปเดตใน LINE Console ลองใช้ Tailscale Funnel สำหรับ URL ถาวร |
| ❌ "npm: command not found" หา npm ไม่เจอ |
Install Node.js from nodejs.org. npm comes included with Node.js. ติดตั้ง Node.js จาก nodejs.org — npm มาพร้อมกับ Node.js |
| ❌ DM pairing code required ต้องใส่รหัสจับคู่ |
This is a security feature! The pairing code appears in the Gateway terminal. Send it to pair your LINE account. นี่คือระบบความปลอดภัย! รหัสจับคู่จะแสดงใน Terminal ส่งรหัสนั้นเพื่อจับคู่บัญชี LINE |
📝 Grammar Focus — If...then (Conditionals)
First Conditional — สิ่งที่เป็นไปได้ในอนาคต
Use the first conditional to talk about things that will probably happen. Pattern: If + present simple, will + base verb
ใช้ first conditional พูดถึงสิ่งที่น่าจะเกิดขึ้น โครงสร้าง: If + ปัจจุบัน, will + กริยาช่อง 1
✅ If you type a message in LINE, the AI will reply through OpenClaw.
ถ้าคุณพิมพ์ข้อความใน LINE AI จะตอบผ่าน OpenClaw
✅ If the Gateway crashes, the bot won't be able to respond.
ถ้า Gateway ล่ม บอทจะตอบไม่ได้
✅ If you change the AI model, the responses will be different.
ถ้าเปลี่ยน AI model คำตอบจะต่างออกไป
❌ If you will type a message, the bot replies.
✅ If you type a message, the bot will reply.
อย่าใช้ "will" ในส่วน if — ใช้ present simple
Zero Conditional — ความจริงทั่วไป (Facts)
Use the zero conditional for things that are always true. Pattern: If + present simple, present simple
ใช้ zero conditional สำหรับสิ่งที่เป็นจริงเสมอ: If + ปัจจุบัน, ปัจจุบัน
✅ If the tunnel stops, LINE can't reach your computer.
ถ้าอุโมงค์หยุด LINE เข้าถึงคอมคุณไม่ได้
✅ If you install a plugin, OpenClaw gains new features.
ถ้าติดตั้งปลั๊กอิน OpenClaw จะมีฟีเจอร์ใหม่
🧪 Section Check — ตรวจสอบความเข้าใจ
Grammar & Features — ไวยากรณ์และฟีเจอร์
Choose the correct conditional: "If the user ______ in Thai, the AI will reply in Thai."
เลือกคำที่ถูกต้อง: "ถ้าผู้ใช้______ เป็นภาษาไทย AI จะตอบเป็นภาษาไทย"
What tool does OpenClaw use to run commands on your computer?
OpenClaw ใช้เครื่องมืออะไรรันคำสั่งบนคอมของคุณ?
Complete: "If the tunnel ______, LINE can't reach your computer." (Zero conditional)
เติมคำ: "ถ้าอุโมงค์______ LINE เข้าถึงคอมคุณไม่ได้" (zero conditional)
📊 สรุป
Summary — What We Learned
🇹🇭 ภาษาไทย
- OpenClaw คือแพลตฟอร์ม AI ส่วนตัวแบบ open-source ที่รันบนคอมของคุณ
- เขียนด้วย TypeScript ติดตั้งผ่าน npm
- มี LINE plugin ในตัว — ไม่ต้องเขียนโค้ด webhook เอง!
- Gateway รันบน port 18789 เป็นศูนย์กลางรับ-ส่งข้อความ
- รองรับ AI หลายรุ่น — ChatGPT, Claude และอื่นๆ
- exec ให้ AI รันคำสั่งบนคอมของคุณได้จาก LINE!
- ใช้ ngrok หรือ Tailscale Funnel สร้างอุโมงค์
- ตั้งค่าผ่านไฟล์ openclaw.json
🇬🇧 English
- OpenClaw is an open-source personal AI platform that runs on your computer
- Written in TypeScript, installed via npm
- Has a built-in LINE plugin — no custom webhook code needed!
- The Gateway runs on port 18789 as the central message hub
- Supports multiple AI models — ChatGPT, Claude, and more
- exec lets the AI execute commands on your PC from LINE!
- Use ngrok or Tailscale Funnel to create a tunnel
- Configured via openclaw.json
🎉 ยินดีด้วย! Congratulations!
ตอนนี้คุณรู้วิธีเชื่อมต่อ LINE กับ AI บนคอมของคุณ — แล้วยังสั่งงานคอมจากมือถือได้!
Now you know how to connect LINE to AI on your computer — and even control your PC from your phone!
If you send a message in LINE, then OpenClaw's AI will answer — or run a command on your computer! 🐾