Online customer service SDK, supporting multiple frameworks:
npm install bytedesk-web
# or
yarn add bytedesk-web
import { BytedeskReact } from 'bytedesk-web/react';
import type { BytedeskConfig } from 'bytedesk-web/react';
const config: BytedeskConfig = {
chatPath: '/chat', // default: /chat, thread history: /chat/thread
placement: 'bottom-right',
marginBottom: 20,
marginSide: 20,
bubbleConfig: {
show: true,
icon: '👋',
title: 'Need help?',
subtitle: 'Click to chat'
},
chatConfig: {
org: 'df_org_uid', // Replace with your organization ID
t: "2",
sid: 'df_rt_uid' // Replace with your SID
}
};
/chat/thread)Set chatPath to /chat/thread to open the visitor history thread page when clicking the icon or calling showChat().
const config: BytedeskConfig = {
chatPath: '/chat/thread',
chatConfig: {
org: 'df_org_uid',
t: '1',
sid: 'df_wg_uid',
visitorUid: 'visitor_001',
nickname: 'Visitor',
avatar: 'https://weiyuai.cn/assets/images/avatar/02.jpg'
}
};
Direct URL usage (same params as /chat):
https://cdn.weiyuai.cn/chat/thread?org=df_org_uid&t=1&sid=df_wg_uid&visitorUid=visitor_001&nickname=Visitor&avatar=https%3A%2F%2Fweiyuai.cn%2Fassets%2Fimages%2Favatar%2F02.jpg&lang=en&mode=light
const App = () => {
const handleInit = () => {
console.log('BytedeskReact initialized');
};
return (
<div>
<BytedeskReact {...config} onInit={handleInit} />
<button onClick={() => (window as any).bytedesk?.showChat()}>
Open Chat
</button>
</div>
);
};
(window as any).bytedesk?.showChat() - Show chat window
(window as any).bytedesk?.hideChat() - Hide chat window
yarn install
yarn demo:react # Run React demo
yarn demo:vue # Run Vue demo
yarn demo:svelte # Run Svelte demo
yarn demo:vanilla # Run Vanilla JS demo
# JavaScript demo requires build first
yarn build
yarn demo:javascript