npc-chat-site

One-click deployment of an AI digital-employee chat website: provides a single-NPC chat interface, a FastAPI backend, CNB NPC scheduling, and separate conversation and history pages. Example triggers: build a chat bot, deploy an AI chat page, digital employee, Moshu chat.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "npc-chat-site" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-a85cf7985dd66b2792537be086b463ff6af341b6554ffa7494af6f2a08204b6c. Verify the upstream source and version against https://skillhub.cn/skills/user_f12a44b7/self-dev-npc-chat-site before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

One-click deployment of an AI digital-employee chat website: provides a single-NPC chat interface, a FastAPI backend, CNB NPC scheduling, and separate conversation and history pages. Example triggers: build a chat bot, deploy an AI chat page, digital employee, Moshu chat.

0 Downloads

Introduction source: third_party · user_f12a44b7 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: npc-chat-site
slug: self-dev-npc-chat-site
version: 1.0.0
displayName: "Self Dev Npc Chat Site"
description: "一键部署 AI 数字员工聊天网站:单NPC对话 + FastAPI后端 + CNB NPC调度 + 独立对话/历史页。当用户说'做个聊天机器人''部署AI对话页''数字员工''麻薯对话'时触发。"
references:
  - references/debug-log.md
  - references/deploy-cheatsheet.md
  - references/workflow-recap.md
assets:
  - assets/app/main.py
  - assets/chat.html
  - assets/history.html

npc-chat-site Skill

部署一个 AI 数字员工聊天网站 —— 前端发消息 → FastAPI 后端 → CNB Issue → @NPC 回复 → 轮询展示。

12 步工作流

1. 创建仓库 & NPC Token

  • 仓库路径:POST /{org}/-/repos,body {"name":"{site}"}
  • Token scope 必须含 repo-code:rw(网页端设置)

2. 后端 FastAPI

  • 单文件约 250 行,5 个端点
  • 部署通杀命令(复制即用):
SITE="mochi"; PORT=8082; REPO="cnbnn/mochi-site"
pip install fastapi uvicorn httpx
mkdir -p /opt/${SITE}-api/data/chat
python3 -c "
import os
code = open('assets/app/main.py').read()
code = code.replace('__CNB_TOKEN__', os.environ.get('CNB_TOKEN',''))
code = code.replace('__MOCHI_REPO__', '$REPO')
open(f'/opt/{SITE}-api/main.py','w').write(code)
"
  • Systemd 服务 + Nginx 反代 /api/ → 127.0.0.1:8082

3. 前端对话页

  • 独立页 /chat.html(用 assets/chat.html)
  • 访客 ID localStorage 持久化
  • 轮询 3s/20 次上限,先取初始评论数再轮询
  • Enter 发送 / Shift+Enter 换行 / 自动聚焦 / 滚动

4. 历史页

  • /history.html(用 assets/history.html)
  • 📋 跳转,倒序展示,空态引导

5. NPC 触发条件

  • 📌 Issue body 和 追加评论都要含 @npc/CodeWhale(CodeWhale-pro)
  • Issue body 需附 INSTRUCTION(口语自然 / 不铺垫 / 有态度)

6. 后端评论分页

# CNB API 每页 10 条,必须遍历
page = 1
while True:
    c = _cb_call("GET", f"/{repo}/-/issues/{n}/comments?page={page}")
    if not c or len(c) == 0: break
    all.extend(c)
    if len(c) < 10: break
    page += 1

7. 轮询 seenCount 初始化

// 前:先取初始评论数,再开始轮询
fetch("/api/chat/status/" + issueNum)
  .then(r => r.json())
  .then(init => {
    seenCount = (init.replies || []).length;
    pollTimer = setInterval(() => { ... }, 3000);
  });

8. 绕过 CNB_TOKEN 掩盖

写工具会自动将 Authorization: Bearer *** 替换为 ***。解法:

  • sed 替换 cat main.py | sed "s|__TOKEN__|$CNB_TOKEN|" > target.py
  • python -c 见步骤 2

9. 验证

curl -X POST /api/chat -d '{"message":"hi","visitor_id":"v_test"}'
curl /api/chat/status/{issue_number}
curl /api/chat/history/v_test

10. 独立页 > 弹框

  • ✅ 独立页面 href="/chat.html"
  • ❌ 弹框 onclick="openChat()" + position: fixed

11. JS 验证

每个 JS 输出后:

node -e "try { new Function(code); console.log('OK'); } catch(e) { console.log(e.message); }"

12. HTML DOM 完整性

多次编辑容易多/少 </div>,修复后在浏览器打开确认可交互。

踩坑速查

# 现象 根因 解法
1 NPC 不回复 Issue body 缺 @mention 加上 @npc/XXX(YYY)
2 复用 Issue 不回复 追加评论缺 @mention 后端 POST 评论也加
3 所有历史 NPC 重播 seenCount=0 轮询前先取初始评论数
4 最新回复取不到 评论分页 10 条 后端遍历所有 page
5 弹框点不动 </div> 多一个 删多余闭合标签
6 刷新历史消失 loadHistory 漏定义 检查所有被调用函数
7 TOKEN 被掩盖 写工具敏感词检测 sed / python -c 绕过

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

    文档未明确说明适用场景和用户群体,影响快速理解。

    Recommendation: 建议在文档开头添加 'When to Use' 章节,说明适合有部署 AI 对话站点需求的技术用户。

  • 文档略长 Reported severity: Minor

    主文档内容较详细,可能影响快速浏览。

    Recommendation: 可考虑将部分技术细节移至附录或参考文档,保持主流程简洁。

Highlights

  • 提供完整的一键部署 AI 数字员工聊天网站方案,涵盖前后端全流程
  • 包含详细的 12 步工作流和踩坑速查表,实用性强
  • 支持独立对话页和历史页,用户体验完整
Trigger Precision85/100

Highlights

  • 触发词覆盖合理,包括'做个聊天机器人''部署AI对话页''数字员工''麻薯对话',边界清晰
  • 能有效命中目标用户的核心需求场景
Structure and Standards90/100

Highlights

  • 12 步工作流结构清晰,步骤划分明确,含端到端示例
  • frontmatter 完整,文档组织规范,踩坑速查表提升实用性
Execution Reliability88/100

Highlights

  • 工具来源明确(FastAPI、CNB API),参数替换逻辑清晰
  • 覆盖主要异常场景(评论分页、seenCount 初始化、TOKEN 掩盖绕过)
  • 提供验证命令和 JS/HTML 完整性检查机制
Evidence Verifiability (mean of the first four)85/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Save or modify files

    Confirm the output directory and whether existing files will be replaced. Back up important files and prefer a new output directory.

    Mentioned in main document · lines 40
  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 33

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.