Chuyển tới nội dung chính

📘 TÀI LIỆU TÍCH HỢP WEBHOOK GETFLY CRM


I. Webhook là gì?

Webhook là phương thức Getfly CRM tự động đẩy dữ liệu realtime sang server của bạn khi có sự kiện phát sinh (tạo khách hàng, sửa đơn hàng, cập nhật task,....

Ứng dụng:

  • Đồng bộ dữ liệu CRM → ERP / Website / App
  • Tự động hóa quy trình, cảnh báo, workflow
  • Không cần lập lịch cron để đọc API

II. Cách thức gửi webhook

Thuộc tínhGiá trị
Phương thứcPOST
Content-Type mặc địnhapplication/x-www-form-urlencoded
URL nhậnServer của đối tác cung cấp

Webhook gửi kèm secret_key để bảo mật.


III. Cấu trúc request Webhook

event=task.updated&
secret_key=YOUR_SECRET_KEY&
data[task_code]=TASK-2025-001&
data[task_status]=2&
domain=https://crm.com

IV. Danh sách sự kiện hỗ trợ

NhómEvent
Customercustomer.created, customer.updated, customer.deleted, customer.hard_deleted
Orderorder.created, order.approved
Productproduct.created, product.updated
Phiếu khostore_sheet_out.created, store_sheet_in.created, store_sheet_transfer.created
Campaigncampaign.created, campaign.updated
Opportunityopportunity.created, opportunity.updated
Tasktask.created, task.updated

V. Hướng dẫn verify request Webhook

if ($request['secret_key'] !== env('GETFLY_WEBHOOK_KEY')) {
http_response_code(401);
exit('Invalid signature');
}

Khuyến nghị tăng security:

  • Kiểm tra secret_key
  • HMAC SHA256 chữ ký request 🔥

VI. Ví dụ xử lý webhook Laravel nhanh

Route::post('/webhook/getfly', function (Request $req) {
if ($req->secret_key !== env('GETFLY_KEY')) return response('Forbidden',401);

$event = $req->event;
$data = $req->data;

match ($event) {
'customer.created' => CustomerService::syncCreate($data),
'task.updated' => TaskService::syncUpdate($data),
default => Log::warning('Event chưa xử lý: '.$event)
};

return response('OK');
});