Files
assistant/scripts/set-contact-token.sh
wangliang c8f26b6f9f chore: 清理 scripts 目录,保留核心运维和部署脚本
## 变更内容

### 保留的核心运维脚本
-  start.sh - 启动服务
-  stop.sh - 停止服务
-  init-pgvector.sql - 数据库初始化

### 保留的部署工具
-  deploy-production.sh - 生产环境部署
-  backup-production.sh - 生产环境备份
-  set-contact-token.sh - 设置联系令牌
-  set-remote-contact-token.sh - 设置远程令牌
-  verify-contact-token.sh - 验证令牌

### 删除的临时调试脚本
-  debug-webhook.sh - 实时监控日志
-  check-conversations.sh - 检查会话
-  check-chatwoot-config.sh - 检查配置
-  verify-webhook.sh - 验证webhook
-  update-chatwoot-webhook.sh - 更新webhook

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-27 13:59:12 +08:00

42 lines
1.2 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 为 Chatwoot Contact 设置 JWT Token
#
# 使用方法:
# ./set-contact-token.sh <contact_id> <jwt_token>
#
# 示例:
# ./set-contact-token.sh 4 "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
CHATWOOT_BASE_URL="http://192.168.15.34:3000"
ACCOUNT_ID="2"
# 从环境变量或参数获取 token
CONTACT_ID=${1:-"4"}
JWT_TOKEN=${2:-"your_jwt_token_here"}
MALL_TOKEN=${3:-"$JWT_TOKEN"} # 默认使用相同的 token
# Chatwoot API Token需要在管理界面创建
CHATWOOT_API_TOKEN="fnWaEeAyC1gw1FYQq6YJMWSj"
echo "📝 为 Contact #$CONTACT_ID 设置 token..."
echo "JWT Token: ${JWT_TOKEN:0:30}..."
echo "Mall Token: ${MALL_TOKEN:0:30}..."
# 更新 contact 的 custom_attributes
curl -X PUT "$CHATWOOT_BASE_URL/api/v1/accounts/$ACCOUNT_ID/contacts/$CONTACT_ID" \
-H "Authorization: Bearer $CHATWOOT_API_TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"custom_attributes\": {
\"jwt_token\": \"$JWT_TOKEN\",
\"mall_token\": \"$MALL_TOKEN\"
}
}" | python3 -m json.tool
echo ""
echo "✅ Token 设置完成!"
echo ""
echo "验证:"
echo " curl -H \"Authorization: Bearer $CHATWOOT_API_TOKEN\" \\"
echo " $CHATWOOT_BASE_URL/api/v1/accounts/$ACCOUNT_ID/contacts/$CONTACT_ID"