Online customer service SDK, supporting multiple frameworks:
npm install bytedesk-web
# 或
yarn add bytedesk-web
import { BytedeskReact } from 'bytedesk-web/react';
import type { BytedeskConfig } from 'bytedesk-web/react';
const config: BytedeskConfig = {
chatPath: '/chat', // 默认 /chat,历史会话页使用 /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', // 替换为您的组织ID
t: "2",
sid: 'df_rt_uid' // 替换为您的SID
}
};
/chat/thread)将 chatPath 设置为 /chat/thread 后,点击 icon 或调用 showChat() 会打开访客历史会话页面。
const config: BytedeskConfig = {
chatPath: '/chat/thread',
chatConfig: {
org: 'df_org_uid',
t: '1',
sid: 'df_wg_uid',
visitorUid: 'visitor_001',
nickname: '访客小明',
avatar: 'https://weiyuai.cn/assets/images/avatar/02.jpg'
}
};
也可以直接用 URL + 参数接入(参数与 /chat 一致):
https://cdn.weiyuai.cn/chat/thread?org=df_org_uid&t=1&sid=df_wg_uid&visitorUid=visitor_001&nickname=%E8%AE%BF%E5%AE%A2%E5%B0%8F%E6%98%8E&avatar=https%3A%2F%2Fweiyuai.cn%2Fassets%2Fimages%2Favatar%2F02.jpg&lang=zh-cn&mode=light
const App = () => {
const handleInit = () => {
console.log('BytedeskReact initialized');
};
return (
<div>
<BytedeskReact {...config} onInit={handleInit} />
<button onClick={() => (window as any).bytedesk?.showChat()}>
打开聊天
</button>
</div>
);
};
(window as any).bytedesk?.showChat() - 显示聊天窗口
(window as any).bytedesk?.hideChat() - 隐藏聊天窗口
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