SDK 分为两类客户端:
GrowthOSServerConnectorClient:用于插件服务端、客户后端和连接器服务。
GrowthOSBrowserWidgetClient:用于浏览器,但只能请求客户站点代理。
| 名称 | 版本 | 更新时间 | 获取方式 |
|---|
| Connector SDK | 0.1.0 | 2026-06-02 | 下载 |
不要在浏览器代码中使用 GrowthOS site token。
激活连接器
import { activateGrowthOSConnector } from "@growthos/connector";
const activation = await activateGrowthOSConnector(
{ baseUrl: process.env.GROWTHOS_CONNECTOR_API_BASE! },
{
licenseKey: process.env.GROWTHOS_LICENSE_KEY!,
domain: "YOUR_CUSTOMER_SITE_ORIGIN",
platform: "custom",
locale: "zh-CN"
}
);
服务端客户端
import { GrowthOSServerConnectorClient } from "@growthos/connector";
const client = new GrowthOSServerConnectorClient({
baseUrl: process.env.GROWTHOS_CONNECTOR_API_BASE!,
token: process.env.GROWTHOS_SITE_TOKEN!,
timeoutMs: 25000
});
const status = await client.getSiteStatus();
浏览器客户端
import { GrowthOSBrowserWidgetClient } from "@growthos/connector";
const client = new GrowthOSBrowserWidgetClient({
baseUrl: "YOUR_CUSTOMER_SITE_ORIGIN/wp-json/gza-ai-growth/v1"
});
await client.sendMessage({
conversationId,
visitorId,
message: "你好"
});