Bỏ qua, đến nội dung

@digiforce-nc/plugin-workflow-request

Plugin đăng ký node HTTP request trong workflow, mở rộng plugin-workflow. Gọi API bên ngoài hoặc endpoint nội bộ với URL, headers, body có thể sử dụng template biến workflow.

Plugin này làm gì?

Node HTTP Request gửi HTTP request đến URL chỉ định. Hỗ trợ tất cả HTTP methods (GET, POST, PUT, PATCH, DELETE), tùy chỉnh headers, body, và query params. URL, headers, body đều hỗ trợ template biến workflow để tạo request động.

Đây là node quan trọng nhất cho tích hợp hệ thống bên ngoài. Bất kỳ API nào có HTTP endpoint đều có thể gọi từ workflow qua node này.

Cấu hình

Tham sốKiểuMô tả
methodstringHTTP method: GET, POST, PUT, PATCH, DELETE
urlstringURL đích (hỗ trợ template biến)
headersobjectHTTP headers tùy chỉnh
paramsobjectQuery parameters
bodyobject/stringRequest body (JSON hoặc text)
timeoutnumberTimeout request (ms), mặc định 5000
ignoreFailbooleanTiếp tục workflow ngay cả khi request lỗi
contentTypestringContent-Type: application/json, form-data, ...

Input / Output

HướngDữ liệuMô tả
Inputurl, methodEndpoint và phương thức HTTP
Inputheaders, bodyNội dung request (hỗ trợ template)
OutputstatusCodeHTTP status code từ response
OutputheadersResponse headers
OutputbodyResponse body (auto-parse JSON)

Tính năng chính

#Tính năngChi tiết
1Mọi HTTP methodGET, POST, PUT, PATCH, DELETE, HEAD
2Template URLURL chứa biến workflow
3Auth headersTruyền Bearer token, API key qua headers
4Auto parseTự động parse JSON response body
5Error handlingCấu hình bỏ qua lỗi hoặc dừng workflow
6TimeoutGiới hạn thời gian chờ response

Trường hợp sử dụng

#Kịch bảnMô tả
1Gọi API thanh toánPOST đến payment gateway để tạo giao dịch
2Lấy tỷ giáGET API tỷ giá ngoại tệ để tính giá
3Đồng bộ CRMPUT cập nhật contact trong Salesforce/HubSpot
4Webhook callbackPOST kết quả xử lý về hệ thống gọi

HTTP Status Code xử lý

StatusHành viignoreFail = true
2xxThành công, tiếp tụcTiếp tục
3xxFollow redirectFollow redirect
4xxLỗi client, dừng workflowTiếp tục (body = error)
5xxLỗi server, dừng workflowTiếp tục (body = error)
TimeoutDừng workflowTiếp tục (body = null)

Lưu ý quan trọng

  • Timeout mặc định 5 giây - tăng lên cho API chậm (file upload, báo cáo)
  • ignoreFail: true giữ workflow chạy khi API lỗi - kiểm tra statusCode ở node sau
  • Response body quá lớn có thể ảnh hưởng memory - chỉ lấy field cần qua JSON Query
  • Headers nhạy cảm (API key, token) nên lưu trong biến môi trường
  • Cẩn thận retry: POST request có thể tạo duplicate nếu API không idempotent

Dependencies

PackageVai trò
@digiforce-nc/plugin-workflowWorkflow engine (peer)
@digiforce-nc/serverServer framework (peer)

Mục lục chi tiết