Common issues and questions#
รวมปัญหาและคำถามที่พบบ่อยสำหรับ Webhook node พร้อมวิธีแก้ไข
Listen for multiple HTTP methods#
โดยปกติ Webhook node จะรับแค่ HTTP method เดียว เช่น รับ GET หรือ POST อย่างใดอย่างหนึ่ง ถ้าอยากให้รับได้หลาย method:
- เปิด Settings ของ node
- เปิด Allow Multiple HTTP Methods
- กลับไปที่ Parameters ตอนนี้ node จะรับ GET และ POST ได้แล้วโดย default สามารถเพิ่ม method อื่นใน field HTTP Methods ได้
Webhook node จะมี output แยกตามแต่ละ method ทำให้กำหนด action ต่างกันได้ตาม method ที่รับ
Use the HTTP Request node to trigger the Webhook node#
HTTP Request node ใช้ส่ง HTTP request ไปยัง URL ที่กำหนด
- สร้าง workflow ใหม่
- เพิ่ม HTTP Request node ใน workflow
- เลือก method ที่ต้องการใน Request Method เช่น ถ้า Webhook node ใช้ GET ให้ HTTP Request node ใช้ GET ด้วย
- คัดลอก URL จาก Webhook node ไปวางใน URL ของ HTTP Request node
- ถ้าใช้ test URL ของ webhook node: ให้ execute workflow ที่มี Webhook node ก่อน
- Execute HTTP Request node
Use curl to trigger the Webhook node#
สามารถใช้ curl เพื่อส่ง HTTP request ไป trigger Webhook node ได้
Note
ในตัวอย่าง ให้แทนที่ <https://your-n8n.url/webhook/path>
ด้วย webhook URL ของคุณ
ตัวอย่างใช้ GET request แต่สามารถใช้ method อื่นที่ตั้งไว้ใน HTTP Method ได้
ส่ง HTTP request โดยไม่มี parameter:
1 |
|
ส่ง HTTP request พร้อม body parameter:
1 |
|
ส่ง HTTP request พร้อม header parameter:
1 |
|
ส่ง HTTP request เพื่ออัปโหลดไฟล์:
1 |
|
/path/to/file
ด้วย path ของไฟล์ที่ต้องการส่ง
Send a response of type string#
โดยปกติ response format จะเป็น JSON หรือ array ถ้าอยากให้ส่ง response เป็น string:
- เลือก Response Mode > When Last Node Finishes
- เลือก Response Data > First Entry JSON
- เลือก Add Option > Property Name
- ใส่ชื่อ property ที่เก็บ response โดย default คือ
data
- เชื่อม Edit Fields node กับ Webhook node
- ใน Edit Fields node เลือก Add Value > String
- ใส่ชื่อ property ใน Name ให้ตรงกับข้อ 4
- ใส่ค่าที่ต้องการใน Value
- เปิด Keep Only Set (ให้เป็นสีเขียว)
เมื่อเรียก Webhook จะได้ string response จาก Edit Fields node
Test URL versus Production URL#
n8n จะสร้าง Webhook URLs สองแบบให้แต่ละ Webhook node: Test URL และ Production URL
ตอนสร้างหรือทดสอบ workflow ให้ใช้ Test URL เมื่อพร้อมใช้งานจริงให้เปลี่ยนไปใช้ Production URL
URL type | How to trigger | Listening duration | Data shown in editor UI? |
---|---|---|---|
Test URL | เลือก Listen for test event แล้ว trigger event จากต้นทาง | 120 seconds | |
Production URL | Activate workflow | จนกว่าจะ deactivate workflow |
ดูรายละเอียดเพิ่มเติมที่ Workflow development
IPs in Whitelist are failing to connect#
ถ้าเชื่อมต่อจาก IP ที่อยู่ใน IP Whitelist ไม่ได้ ให้ตรวจสอบว่ารัน n8n อยู่หลัง reverse proxy หรือไม่
ถ้าใช่ ให้ตั้งค่า environment variable N8N_PROXY_HOPS
เป็นจำนวน reverse-proxy ที่ n8n อยู่ข้างหลัง