Nhúng Form
Hướng dẫn nhúng Form vào SmaxAi
Để nhúng Form vào SmaxAi, bạn cần truy cập module Cài đặt, sau đó chọn phần Tích hợp
Trong cửa sổ tích hợp bạn cần đặt tên của Form (1), phần nền tảng (2) chọn Nhúng form, sau đó nhập URL của form (3) và chọn Lưu (4) để lưu lại

2_ Hướng dẫn giao tiếp giữa SmaxAi LiveChat với Form
2.1_ Nhận event từ SmaxAI
// Nhận event từ SmaxAi Livechat
window.addEventListener('message', function (event) {
if (typeof event.data == 'object' && event.data.name === '__SM_FORM_CUSTOMER') {
console.log(event.data?.data?.customer);
}
}, false);
// event.data?.data?.customer có dạng:
{
"id": "6340818229362746",
"name": "Hoàng Đức",
"address": "",
"phone": "",
"email": "",
"gender": "",
"gid": "",
"picture": "https://platform-lookaside.fbsbx.com/platform/profilepic/?psid=6340818229362746&width=300&ext=1691194252&hash=AeQudyCWzA0X3MZDGrk"
}
2.2_ Yêu cầu SmaxAi
const getIntegrationId = () => {
return window.location.href.split('=')[1]
}
// yêu cầu SmaxAi trả dữ liệu customer
if (window.parent) {
window.parent.postMessage({
name: '__SM_FORM_CUSTOMER',
data: {
integration_id: getIntegrationId(),
}
}, '*')
} else {
console.error('window.parent is undefined')
}
// yêu cầu SmaxAi bật popup
if (window.parent) {
window.parent.postMessage({
name: '__SM_FORM_POPUP',
action: 'SHOW', // 'HIDE'
data: {
integration_id: getIntegrationId(),
url: 'https://crm.com/orders?id=xxx',
title: 'Title Demo',
height: '80vh'
}
}, '*')
} else {
console.error('window.parent is undefined')
}
Last updated