Website chat setup guide
Add chat to your HTTPS website, then send a message as a visitor and reply from the workspace.
Installation
- Create a website in the workspace
As an administrator, open Website Integration (网站接入) and enter a name and your website domain.
- Copy the embed code for this website
Each website has its own
site_key. The embed code uses the following format. - Add the script and publish
Place the script before
</body>, then open the published page.
<script src="https://service36.com/embed.js"
data-site-key="site-xxxx" defer></script>
Test both directions
- Send a visitor message
Open your website in a signed-out browser, select Live Chat, and send a test message you can identify.
- Reply as an agent
Open the right workspace, find the message in the inbox (聊天收件箱), and reply.
- Check the reply as a visitor
Confirm that the reply arrives. If AI support is enabled, also try Talk to an agent or your site's configured handoff.
SDK requests
| Purpose | Endpoint | Required fields |
|---|---|---|
| Load website config | GET /api/sdk/config | site_key |
| Send a message | POST /api/sdk/message | site_key, content |
| Poll for replies | GET /api/sdk/poll | site_key, conversation_id, after_id |
If you build your own chat interface, save the conversation_id and conversation_token returned by the send endpoint. Pass the token in the X-Conversation-Token header when polling or continuing the chat, and replace both values when the server issues a new pair.
Identify signed-in website visitors
- Map website roles
In Website Integration, configure the allowed domains and create the visitor profiles and tags you need. Open the site's identity settings, enter your own role codes and identity endpoint path, then save the server-side integration key and copy the updated embed code.
- Read the role from the current sign-in session
Implement a server-side endpoint on your website, such as
GET /api/support/identity. Use the current sign-in session to look up the user's stable ID, role code, and optional display name. Return HTTP 204 for signed-out visitors. - Exchange identity for a short-lived token
From your server, send the JSON below to
POST /api/sdk/identity-tokenon your workspace host, withAuthorization: Bearer <integration key>. Return theidentity_tokento your page withCache-Control: private, no-store. The token expires in five minutes.
{
"site_key": "site key from the workspace",
"user_id": "stable account ID",
"role": "domestic_supplier",
"display_name": "optional display name"
}
Continue a chat after sign-up or sign-in
In the same browser, the widget uses the guest credential and the signed-in account's token to link that site's guest conversation. The messages join the account's history, and the old guest credential expires. Notify the widget when the current account changes.
The connected conversation remains available to the signed-in account. In long chats, the AI uses recent turns and relevant earlier messages. The full conversation stays visible in the chat history.
Use role codes from your own database or authorized API. Unmapped roles receive general support. Tags update when the account next sends a message. In single-page apps, call window.dispatchEvent(new Event('service24:identity-change')) after sign-in, sign-out, or account switching.
Store the integration key on your server. Send only the short-lived token for the current user to the browser. Your website handles the lookups on its own server.
Troubleshooting
The chat button is missing
Check that the page is published, the script loads over HTTPS, the website is enabled, and the domain is allowed.
Messages are missing from the inbox
Verify which workspace owns the embed key, then search that workspace's chat inbox for your test message.
How can I add an agent?
An administrator creates an agent account in Roles and Permissions (角色与权限). The agent signs in, selects Start Accepting Chats (开始接待), and opens the inbox.