🎯 LINE Chatbot คืออะไร?
What is a LINE Chatbot?
🇹🇭 ภาษาไทย
LINE คือแอปพลิเคชันส่งข้อความที่ได้รับความนิยมสูงสุดในประเทศไทย มีผู้ใช้มากกว่า 55 ล้านคนในไทยและมากกว่า 200 ล้านคนทั่วโลก
LINE Chatbot คือโปรแกรมคอมพิวเตอร์ที่ทำงานอยู่ใน LINE และสามารถรับ-ส่งข้อความโดยอัตโนมัติ เมื่อผู้ใช้พิมพ์ข้อความ bot จะตอบกลับทันทีโดยไม่ต้องมีคนช่วย
บริษัทและร้านค้าหลายแห่งใช้ LINE Chatbot เพื่อตอบคำถามลูกค้า รับออเดอร์ และส่งโปรโมชั่น
🇬🇧 English
LINE is the most popular messaging app in Thailand, with over 55 million users in Thailand and more than 200 million users worldwide.
A LINE Chatbot is a computer program that lives inside LINE and can send and receive messages automatically. When a user types a message, the bot replies instantly — no human needed!
Businesses use LINE Chatbots to answer questions, take orders, and send promotions.
🌟 Fun Facts — ข้อเท็จจริงน่าสนใจ
- LINE was created in Japan in 2011 after the Tōhoku earthquake — LINE ถูกสร้างในญี่ปุ่นปี 2011 หลังแผ่นดินไหว
- Thailand has the highest LINE usage per capita outside Japan — ไทยใช้ LINE มากที่สุดนอกญี่ปุ่น
- Over 50% of Thai businesses use LINE Official Account — กว่า 50% ของธุรกิจไทยใช้ LINE Official Account
- LINE bots can speak, show images, maps, and even payment buttons — Bot สามารถพูด แสดงรูป แผนที่ และปุ่มชำระเงินได้
🇹🇭 ทำไมต้องเรียน LINE Bot?
- ทักษะที่ตลาดแรงงานต้องการสูงมากในไทย
- สร้างได้จริงด้วย Python หรือ Node.js
- ใช้ได้กับธุรกิจของตนเองหรือลูกค้า
- เรียนรู้ API, Webhook และ JSON จริงๆ
🇬🇧 Why Learn LINE Bot?
- High-demand skill for Thai tech jobs
- Build real bots with Python or Node.js
- Use for your own business or clients
- Learn real APIs, webhooks, and JSON
📚 คำศัพท์สำคัญ
Key Vocabulary
โปรแกรมที่ตอบข้อความโดยอัตโนมัติ
URL ที่รับข้อมูลเมื่อมีเหตุการณ์เกิดขึ้น LINE ส่งข้อความมาที่ webhook ของคุณ
รหัสที่ยืนยันว่าเซิร์ฟเวอร์ของคุณมีสิทธิ์ส่งข้อความจาก bot
สิ่งที่เกิดขึ้นบน LINE เช่น ข้อความ การติดตาม การเลิกติดตาม
รหัสชั่วคราวที่ส่งมากับทุก message event ใช้สำหรับตอบกลับข้อความนั้น
ข้อมูล JSON ที่ LINE ส่งมายัง webhook ของคุณ
รูปแบบข้อความสวยงามที่กำหนดเองได้ เหมือนหน้าเว็บย่อยๆ
เมนูรูปภาพขนาดใหญ่ที่ด้านล่างของแชท ผู้ใช้แตะเพื่อส่งคำสั่งได้
บัญชี LINE ของ bot คุณสร้าง channel ใน LINE Developers Console
เว็บไซต์ที่ใช้สร้างและจัดการ channel ของ LINE bot
เงื่อนไขที่ทำให้ bot ทำงาน เช่น คีย์เวิร์ดหรือประเภทเหตุการณ์
รหัสเฉพาะที่ระบุผู้ใช้ LINE แต่ละคน bot ใช้รหัสนี้ในการส่งข้อความ
ข้อความที่ bot ส่งออกไปเองโดยไม่รอให้ผู้ใช้ถาม
ข้อความที่ bot ส่งตอบกลับข้อความของผู้ใช้ ใช้ reply token
เกิดขึ้นเมื่อมีคนเพิ่ม bot เป็นเพื่อน เหมาะสำหรับส่งข้อความต้อนรับ
เฟรมเวิร์กที่ทำให้สร้างเว็บแอปที่ทำงานภายใน LINE ได้
🔧 เริ่มต้นใช้งาน
Getting Started
🇹🇭 สิ่งที่ต้องเตรียม
- บัญชี LINE (แอปปกติ)
- บัญชี LINE Business (ฟรี)
- Python 3 หรือ Node.js
- ngrok (สำหรับทดสอบในเครื่อง)
- Code editor เช่น VS Code
🇬🇧 What You Need
- A LINE account (regular app)
- A LINE Business account (free)
- Python 3 or Node.js
- ngrok (to test locally)
- A code editor like VS Code
1สร้าง Provider และ Channel — Create a Provider and Channel
2ตั้งค่า Channel — Configure Your Channel
3รับ Channel Access Token — Get Your Access Token
⚠️ สำคัญมาก! / Very Important!
Thai: อย่าแชร์ Channel Access Token ของคุณกับใคร เหมือนกับรหัสผ่าน!
English: Never share your Channel Access Token. Treat it like a password!
4ติดตั้ง Python Library — Install Python Library
5ติดตั้ง ngrok — Install ngrok
6ตั้งค่า Webhook URL — Set Your Webhook URL
🤖 โปรเจกต์แรก: Echo Bot
First Project: Echo Bot
🇹🇭 Echo Bot คืออะไร?
Echo Bot คือ bot ที่ง่ายที่สุด — มันรับข้อความจากผู้ใช้แล้วส่งข้อความเดิมกลับไป เหมือน "เสียงสะท้อน" นี่คือจุดเริ่มต้นที่ดีที่สุดในการเรียนรู้ LINE Chatbot!
🇬🇧 What is an Echo Bot?
An Echo Bot is the simplest bot — it receives a message from the user and sends the same message back, like an echo. It is the perfect starting point for learning LINE Chatbot development!
1รันโปรแกรม — Run the Program
echo_bot.py จากนั้นรันใน terminalecho_bot.py then run it in the terminal.
2ทดสอบ Bot ของคุณ — Test Your Bot
💡 สิ่งที่เกิดขึ้น / What is happening?
ไทย: เมื่อคุณส่งข้อความ → LINE ส่ง event ไปที่ webhook → Flask รับ request → Python อ่านข้อความ → ส่งข้อความเดิมกลับผ่าน LINE API
English: When you send a message → LINE sends an event to the webhook → Flask receives the request → Python reads the message → sends it back through the LINE API
🎉 ยินดีด้วย! / Congratulations!
คุณสร้าง LINE Chatbot ตัวแรกของคุณแล้ว!
You just built your first LINE Chatbot! Your bot is now listening for messages and replying automatically. 🤖
🚀 ก้าวต่อไป
Next Steps
🇹🇭 คุณได้เรียนรู้
- LINE Chatbot คืออะไรและทำงานอย่างไร
- คำศัพท์สำคัญ: webhook, token, event, payload
- สร้าง channel ใน LINE Developers Console
- เขียน Echo Bot ด้วย Python + Flask
- เชื่อม ngrok เข้ากับ LINE
🇬🇧 You Have Learned
- What a LINE Chatbot is and how it works
- Key vocabulary: webhook, token, event, payload
- Creating a channel in LINE Developers Console
- Writing an Echo Bot with Python + Flask
- Connecting ngrok to LINE
🚀 In the Activities Page You Will Build — ในหน้า Activities คุณจะสร้าง:
- 🔑 Keyword Response Bot — ตอบตามคีย์เวิร์ด (if "สวัสดี" → "สวัสดีครับ!")
- 👋 Welcome Message Bot — ส่งข้อความต้อนรับเมื่อมีคนติดตาม
- 🎨 Flex Message Bot — ส่งการ์ดสวยงามพร้อมรูปและปุ่ม