💬 Tutorial 1: AI Auto-Reply LINE Bot
บทเรียนที่ 1: LINE Bot ที่ใช้ AI ตอบอัตโนมัติ
Set Up a LINE Bot That Uses AI for Auto-Replies 🌱 Easy
ตั้งค่า LINE Bot ที่ใช้ AI ตอบอัตโนมัติ
สิ่งที่คุณจะได้เรียนรู้:
- วิธีสร้าง LINE Messaging API channel
- การตั้งค่า webhook ที่รับข้อความจาก LINE
- การเชื่อมต่อ AI เพื่อสร้างคำตอบอัตโนมัติ
- การใช้ relative clauses เพื่ออธิบายส่วนประกอบของบอท
What You'll Learn:
Create your first AI-powered LINE bot that automatically replies to messages! You'll learn about webhooks, APIs, and how to connect AI that generates smart responses.
1สร้าง LINE Channel — Create a LINE Channel
ไปที่ developers.line.biz และสร้าง Messaging API channel ใหม่ นี่คือช่องทางที่บอทของคุณจะใช้สื่อสาร
English: Go to developers.line.biz and create a new Messaging API channel. This is the channel that your bot will use to communicate.
2สร้าง Webhook Server — Create a Webhook Server
สร้างเซิร์ฟเวอร์ง่ายๆ ที่รับข้อความจาก LINE Webhook คือ URL ที่ LINE ส่งข้อมูลไปให้เมื่อมีคนส่งข้อความ
English: Create a simple server that receives messages from LINE. A webhook is a URL that LINE sends data to when someone sends a message.
3เพิ่ม AI — Add AI Auto-Reply
เชื่อมต่อ AI ที่สร้างคำตอบอัจฉริยะ แทนที่จะแค่ echo ข้อความกลับ ให้ส่งไปให้ AI ประมวลผลก่อน
English: Connect AI that generates intelligent responses. Instead of just echoing the message back, send it to AI for processing first.
💡 Grammar in Code Comments — ไวยากรณ์ในคอมเมนต์โค้ด
Notice how we use relative clauses in comments:
- "The endpoint that receives LINE messages" — defining clause
- "The system prompt, which tells AI how to behave" — non-defining clause
- "The user who sent the message" — defining clause for people
📖 Tutorial 2: FAQ Bot with Natural Language
บทเรียนที่ 2: บอท FAQ ที่เข้าใจภาษาธรรมชาติ
Create a FAQ Bot That Understands Natural Language 🔍 Medium
สร้างบอท FAQ ที่เข้าใจภาษาธรรมชาติ
สิ่งที่คุณจะได้เรียนรู้:
- วิธีสร้างบอทที่ตอบคำถามที่พบบ่อย (FAQ)
- การใช้ AI เพื่อเข้าใจคำถามที่ถูกถามในหลายรูปแบบ
- การจัดการ conversation flow
- การเขียน system prompt ที่มีประสิทธิภาพ
What You'll Learn:
Build a FAQ bot that understands questions even when users ask in different ways! The AI, which processes natural language, can match questions to the right answers.
1เตรียมข้อมูล FAQ — Prepare Your FAQ Data
สร้างรายการคำถามและคำตอบที่ผู้ใช้มักถามบ่อย AI จะใช้ข้อมูลนี้เพื่อตอบคำถามที่คล้ายกัน
English: Create a list of questions and answers that users frequently ask. The AI will use this data to answer similar questions.
2สร้าง System Prompt — Create an Intelligent System Prompt
เขียน system prompt ที่บอก AI ว่าควรตอบอย่างไร ใส่ข้อมูล FAQ เข้าไปเพื่อให้ AI มีความรู้
English: Write a system prompt that tells the AI how to respond. Include the FAQ data so the AI has the knowledge it needs.
3จัดการคำถามหลายรูปแบบ — Handle Multiple Question Formats
AI ที่ประมวลผลภาษาธรรมชาติ จะเข้าใจคำถามแม้จะถูกถามในรูปแบบต่างๆ ลองทดสอบ:
English: The AI, which processes natural language, will understand questions even when they are asked in different ways. Try testing:
User: "When are you open?" → AI understands: Business hours
User: "เปิดกี่โมง?" → AI understands: เวลาทำการ
User: "How fast is delivery?" → AI understands: Shipping time
User: "ส่งของกี่วันถึง?" → AI understands: ระยะเวลาจัดส่ง
User: "Can I return this?" → AI understands: Return policy
User: "คืนของได้ไหม?" → AI understands: นโยบายคืนสินค้า
4เพิ่ม Fallback Response — Add a Fallback Response
เมื่อ AI ไม่สามารถตอบได้ ให้ส่งข้อความสำรองที่แนะนำให้ผู้ใช้ติดต่อพนักงาน
English: When AI cannot answer, send a fallback message that directs the user to a staff member who can help.
🔍 Tutorial 3: Bilingual AI LINE Bot
บทเรียนที่ 3: สร้างบอท LINE สองภาษาด้วย AI
Build a Bilingual LINE Bot (Thai/English) Using AI 🏆 Hard
สร้าง LINE Bot สองภาษา (ไทย/อังกฤษ) ด้วย AI
สิ่งที่คุณจะได้เรียนรู้:
- การสร้างบอทที่ตรวจจับภาษาอัตโนมัติ
- การสร้าง conversation flow สำหรับหลายภาษา
- การใช้ AI ที่แปลและตอบกลับได้ทั้งสองภาษา
- การออกแบบ UX ที่ดีสำหรับผู้ใช้หลายภาษา
What You'll Learn:
Build an advanced LINE bot that automatically detects the language that the user writes in and responds in the same language! This bot, which uses AI for translation and understanding, provides a seamless bilingual experience.
1ตรวจจับภาษา — Language Detection
ใช้ AI เพื่อตรวจจับภาษาที่ผู้ใช้พิมพ์ แล้วตอบกลับในภาษาเดียวกัน ไม่ต้องเขียนโค้ดตรวจจับเอง!
English: Use AI to detect the language that the user types in, then reply in the same language. No need to write detection code yourself!
2เพิ่ม Conversation Memory — Add Conversation Memory
สร้างระบบจำบริบทการสนทนา เพื่อให้บอทจำสิ่งที่ผู้ใช้พูดก่อนหน้าได้
English: Create a conversation memory system so the bot remembers what the user said before. Users who have ongoing conversations will get more relevant answers.
3เพิ่ม Rich Menu — Add a Rich Menu
สร้าง Rich Menu ที่ให้ผู้ใช้เลือกภาษาหรือฟังก์ชันที่ต้องการ Rich Menu คือเมนูที่แสดงที่ด้านล่างของแชท
English: Create a Rich Menu that lets users choose a language or function. A Rich Menu, which appears at the bottom of the chat, makes the bot easier to use.
4Deploy และทดสอบ — Deploy and Test
Deploy บอทขึ้น server แล้วทดสอบด้วยข้อความทั้งภาษาไทยและอังกฤษ
English: Deploy the bot to a server and test with messages in both Thai and English. Test users who switch between languages during the conversation.
User: "สวัสดีครับ ขอถามหน่อย"
Bot: "สวัสดีค่ะ! ยินดีช่วยเหลือค่ะ มีอะไรให้ช่วยคะ?"
User: "Hello, I need help"
Bot: "Hello! I'd be happy to help. What can I do for you?"
User: "Translate 'ขอบคุณ' to English"
Bot: "'ขอบคุณ' means 'Thank you' in English."
📝 Grammar Checkpoint — ตรวจสอบไวยากรณ์: Relative Clauses
ทบทวน Relative Clauses (that/which/who) กับตัวอย่างจาก LINE Bot:
Defining Clauses (ไม่ใส่ comma / ข้อมูลจำเป็น):
✅ A webhook is a URL that receives data from LINE.
✅ Users who send messages will get auto-replies.
✅ The API key that you created must be kept secret.
ตัดออกไม่ได้ เพราะความหมายจะเปลี่ยน — ใช้ that/which/who ได้
Non-Defining Clauses (ใส่ comma / ข้อมูลเพิ่มเติม):
✅ LINE, which has 54 million Thai users, is perfect for bots.
✅ The developer, who is from Thailand, speaks both languages.
✅ The AI model, which was trained on multilingual data, understands Thai.
ตัดออกได้ ความหมายไม่เปลี่ยน — ใช้ which/who เท่านั้น (ห้ามใช้ that)
Practice / ฝึกหัด — เลือก that, which, หรือ who:
1. A chatbot is a program ___ responds to messages. → that (defining)
2. Our bot, ___ uses GPT-4, is very smart. → which (non-defining, comma)
3. Customers ___ need help can message the bot. → who (defining, people)
4. The webhook, ___ runs 24/7, never sleeps. → which (non-defining, comma)
5. The developer ___ created this bot is Thai. → who (defining, person)
⭐ Best Practices — เทคนิคสำหรับ AI LINE Bots
💡 Tips for Building Great AI LINE Bots — เคล็ดลับสร้าง AI LINE Bot ที่ดี
- Write clear system prompts: A prompt that is specific will give better results — เขียน system prompt ที่ชัดเจน
- Keep responses short: LINE messages that are too long are hard to read — ตอบสั้นๆ ข้อความ LINE ที่ยาวเกินอ่านยาก
- Handle errors gracefully: Users who encounter errors should see a friendly message — จัดการ error อย่างสุภาพ
- Test in both languages: A bot that only works in English will frustrate Thai users — ทดสอบทั้งสองภาษา
- Protect API keys: Keys that are exposed can be stolen and misused — ป้องกัน API key
⚠️ Common Mistakes — ข้อผิดพลาดที่พบบ่อย
- Forgetting error handling: A bot that crashes gives a bad user experience — อย่าลืมจัดการ error
- Not setting response limits: AI responses that are too long get cut off on LINE — จำกัดความยาวคำตอบ
- Exposing API keys: Never put keys in code that is pushed to GitHub — อย่าเผยแพร่ API key บน GitHub
- Ignoring Thai language: Bots that don't support Thai will lose most Thai users — ต้องรองรับภาษาไทย
🏆 เก่งมาก! You've Done Great!
คุณได้ฝึกสร้าง AI LINE Bot และ relative clauses แล้ว!
You have practiced building AI LINE bots and using relative clauses!
ตอนนี้คุณพร้อมทำแบบทดสอบแล้ว!
Now you are ready for the exam!