[x] n8n คืออะไร?
[x] เริ่มต้นใช้งาน
[x] คำศัพท์พื้นฐานที่ควรรู้
Workflow - หน้าจอการทำงานของระบบ Automation
Node - ตัวแทนของ “วิธีการทำงาน” แต่ละขั้นตอน เช่น รับข้อมูล, ส่งข้อมูล, แปลงข้อมูล
Trigger Node (⚡) - จุดเริ่มต้นของ Workflow มีเพียง Output เท่านั้น (ไม่มี Input) ใช้สำหรับ “กระตุ้น” ให้ระบบเริ่มทำงาน
Actions Node - โหนดที่ใช้ทำงานตามที่กำหนด เช่น ส่งอีเมล บันทึกข้อมูล เรียก API มีทั้ง Input (รับจากโหนดก่อนหน้า) และ Output (ส่งต่อไปยังโหนดถัดไป)
Core Node (ขั้นกลาง)
Cluster Node (ขั้นกลาง)
Credentials (ขั้นกลาง)
Community nodes (ขั้นสูง)
[ ] Expressions (ขั้นกลาง)
[ ] มาลองสร้าง Workflow ง่ายๆกัน
[ ] วิธีให้ AI ช่วยเขียน Workflow ให้ (ควรอ่าน Workflow ให้เป็นก่อน เพราะอาจจะมีปัญหาได้)
LINE PUSH API
const res = await fetch("<https://api.line.me/v2/bot/message/push>", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${CHANNEL_ACCESS_TOKEN}`,
},
body: JSON.stringify({
to: userId,
messages: [
{
type: "text",
text: text,
},
],
}),
});
LINE REPLY API
curl -v -X POST <https://api.line.me/v2/bot/message/reply> \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer {channel access token}' \\
-d '{
"replyToken":"nHuyWiB7yP5Zw52FIkcQobQuGDXCTA",
"messages":[
{
"type":"text",
"text":"Hello, user"
},
{
"type":"text",
"text":"May I help you?"
}
]
}'
References
https://docs.n8n.io/integrations/builtin/node-types/#cluster-nodes
https://docs.n8n.io/code/expressions/
https://developers.line.biz/en/docs/messaging-api/getting-started/ - ขั้นตอนการทำ Line Messaging API
https://developers.line.biz/en/docs/messaging-api/sending-messages/ - HTTP List