Chatwoot 是做什么的?
概述
Chatwoot 是一个开源客户支持平台。作为自托管的 Intercom 替代方案,提供实时聊天、共享收件箱、多渠道支持(网站、电子邮件、WhatsApp、Telegram、Twitter)和聊天机器人。自托管时完全免费。
使用指南
步骤 1:Docker 部署
# docker-compose.yml — 自托管 Chatwoot
services:
chatwoot:
image: chatwoot/chatwoot:latest
depends_on: [postgres, redis]
ports: ["3000:3000"]
environment:
RAILS_ENV: production
SECRET_KEY_BASE: your-secret-key-base
FRONTEND_URL: https://chat.example.com
POSTGRES_HOST: postgres
POSTGRES_USERNAME: chatwoot
POSTGRES_PASSWORD: chatwoot
REDIS_URL: redis://redis:6379
MAILER_SENDER_EMAIL: [email protected]
SMTP_ADDRESS: smtp.gmail.com
SMTP_PORT: 587
SMTP_USERNAME: [email protected]
SMTP_PASSWORD: app-password
command: bundle exec rails s -p 3000 -b 0.0.0.0
sidekiq:
image: chatwoot/chatwoot:latest
depends_on: [postgres, redis]
environment: *chatwoot-env
command: bundle exec sidekiq
postgres:
image: postgres:15
environment:
POSTGRES_DB: chatwoot
POSTGRES_USER: chatwoot
POSTGRES_PASSWORD: chatwoot
volumes: [pgdata:/var/lib/postgresql/data]
redis:
image: redis:7-alpine
volumes: [redisdata:/data]
volumes:
pgdata:
redisdata:
步骤 2:添加聊天小部件
<!-- 添加到您的网站 -->
<script>
(function(d,t) {
var BASE_URL="https://chat.example.com";
var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=BASE_URL+"/packs/js/sdk.js";
g.defer = true;
g.async = true;
s.parentNode.insertBefore(g,s);
g.onload=function(){
window.chatwootSDK.run({
websiteToken: 'YOUR_WEBSITE_TOKEN',
baseUrl: BASE_URL
})
}
})(document,"script");
</script>
步骤 3:API 集成
// lib/chatwoot.ts — 通过 API 创建联系人和对话
const CHATWOOT_URL = 'https://chat.example.com'
const CHATWOOT_TOKEN = process.env.CHATWOOT_API_TOKEN!
// 用户注册时创建联系人
await fetch(`${CHATWOOT_URL}/api/v1/accounts/1/contacts`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
api_access_token: CHATWOOT_TOKEN,
},
body: JSON.stringify({
name: 'John Doe',
email: '[email protected]',
custom_attributes: { plan: 'pro', mrr: 49 },
}),
})
指南
- 自托管:完全免费,无限代理和对话。
- 云端:每月每代理 $19 起。
- 在一个收件箱内支持 WhatsApp Business、Telegram、Twitter、电子邮件和网站渠道。
- 使用 Webhook 将对话同步到您的 CRM 或工单系统。