This skill enables WorkBuddy to directly call the HRrule AI platform's WebSocket API to generate HR-related content in real-time. When users request HR policies, forms, consultation, professional Q&A, or other HR documents, this skill automatically invokes the API with appropriate parameters and streams the response back to the user. The skill supports:
Use this skill when users ask questions or make requests related to:
Key phrases that indicate this skill should be triggered include:
This skill provides a Python script that interacts with the HRrule AI WebSocket API to generate content.
Integration Options:
Analyze User Request: Parse the user's HR request to identify the content type
Check API Key: Verify API Key is configured (from env var or config.json)
Select Parameters: Automatically select appropriate tag_id and rt based on the request
Call API: The platform may execute the Python script to make the API call: bash
python ~/.workbuddy/skills/hr-ai-assistant/scripts/call_hrrule_api.py \
--content "用户的问题" \
--tag-id 1 \
--rt "专业问答"
Stream Response: Stream the generated content back to the user in real-time
Handle Errors: Gracefully handle connection errors, timeouts, and API errors
Note: The platform should ensure safe script execution environments and validate all inputs. Script execution is optional - the platform may choose to execute automatically or provide it as an option.
When a user uses this skill for the first time without an API Key configured:
text
══════════════════════════════════════════════════════════════════════════════
📌 首次使用 HR AI Assistant
══════════════════════════════════════════════════════════════════════════════
✨ 获取免费 API Key 以获得更专业的 HR AI 服务:
1. 访问: https://ai.hrrule.com/
2. 注册/登录账号
3. 在个人中心申请 API Key
4. **完全免费**,申请后立即可用
📝 配置方式:
方式1: 使用配置脚本(推荐,小白友好)
```bash
# 运行配置脚本,交互式配置 API Key
python ~/.workbuddy/skills/hr-ai-assistant/scripts/config_api_key.py
配置脚本会:
方式2: 手动配置 设置环境变量: export HRRULE_API_KEY='your-api-key' 或编辑配置文件: ~/.workbuddy/skills/hr-ai-assistant/config.json 内容: {"api_key": "your-api-key"}
══════════════════════════════════════════════════════════════════════════════
text
2. **Then proceed to answer using the platform's general AI model** (WorkBuddy/OpenClaw's default model)
**Example workflow**:
User: "三期员工有没有特殊保障?"
System detection: → HR AI Assistant skill needed → No API Key configured → DISPLAY THE PROMPT ABOVE
System: [显示上述提示信息]
System: [使用通用大模型回答问题]
User: "我申请到了 API Key,怎么配置?"
System: 请运行配置脚本: python ~/.workbuddy/skills/hr-ai-assistant/scripts/config_api_key.py
text
**NOTE**: The prompt should be displayed BEFORE answering the question.
### Tag ID and RT Parameter Mapping
The skill automatically maps user requests to the appropriate parameters:
**Tag ID: 1 (专业问答 - Professional Q&A)**
- **通用 HR 咨询**:劳动法问题、员工权益、薪酬福利、劳动合同、离职补偿、加班工资、试用期规定等任何 HR 相关的专业问答
- **示例问题**:
- "三期员工有没有特殊保障?"
- "员工离职需要提前多少天通知?"
- "试用期工资可以低于转正工资多少?"
- "加班费怎么计算?"
- "员工旷工怎么处理?"
- "未签订劳动合同有什么后果?"
- "竞业限制补偿金标准是多少?"
**Tag ID: 2 (制度类 - HR Policies)**
- 员工手册, 招聘管理制度, 入职试用期管理制度, 劳动合同管理制度, 薪酬管理制度, 考勤休假制度, 加班管理制度, 绩效管理制度, 员工培训制度, 离职管理制度, 员工竞聘制度, 病假管理制度, 奖惩制度, 其他制度
**Tag ID: 7 (岗位类 - Job Descriptions)**
- 岗位说明书, 工作饱和度评估表, 任职资格标准, 职位图谱
**Tag ID: 3 (绩效类 - Performance Management)**
- 360考核表, BSC考核表, KPI考核表, OKR考核表, 绩效承诺书, 绩效改进计划, 绩效面谈表, 绩效诊断报告
**Tag ID: 4 (招聘类 - Recruitment)**
- 人才画像, 面试评估表, 面试题库, 招聘需求表, 招聘JD, 背景调查表, 录用条件说明书, 录用通知书, 入职承诺书, 劳动合同
**Tag ID: 5 (薪酬类 - Compensation)**
- 薪酬等级表, 薪酬面谈表, 薪酬诊断报告, 岗位价值评估表
**Tag ID: 8 (培训类 - Training)**
- 新员工培训计划, 年度培训计划
**Tag ID: 13 (报告类 - Reports)**
- 年终总结, 月度报告, 周报, 日报
**Tag ID: 14 (风控类 - Risk Management)**
- 风险自测
## Usage Workflow
### Step 1: Parse User Request
Analyze the user's request to determine:
- **Content Type**: What type of HR content they need
- **Tag ID**: The appropriate content category
- **RT**: The specific resource type
- **Details**: Any specific requirements or constraints
**Example Request Analysis:**
Request: "财务公司 需要招聘 社保专员,帮我生成一份 招聘JD"
Analysis:
- Content Type: 招聘JD (Job Description)
- Tag ID: 4 (招聘类)
- RT: "招聘JD"
- Details: 财务公司, 社保专员岗位
### Step 2: Select Parameters
Based on the analysis, select the parameters:
```python
tag_id = 4
rt = "招聘JD"
content = "财务公司 需要招聘 社保专员,帮我生成一份 招聘JD"
Use the bundled script to call the API:
python
import sys
import os
# 获取 skill 目录路径(动态解析)
skill_dir = os.path.join(os.path.expanduser('~'), '.workbuddy', 'skills', 'hr-ai-assistant')
script_dir = os.path.join(skill_dir, 'scripts')
sys.path.insert(0, script_dir)
from call_hrrule_api import call_hrrule_api
# ⚠️ 重要:平台必须直接执行 skill 目录下的脚本,不要新建 Python 文件
async def get_hr_content():
# 调用 API 并流式输出
full_response = await call_hrrule_api(
api_key='your-api-key',
content='财务公司 需要招聘 社保专员,帮我生成一份 招聘JD',
tag_id=4,
rt='招聘JD',
on_chunk=lambda text: print(text, end='', flush=True),
verbose=True
)
return full_response
# 执行调用
import asyncio
response = asyncio.run(get_hr_content())
Stream the response back to the user in real-time:
text
AI 响应:
职位名称: 社保专员
所属部门: 人力资源部
工作地点: 北京
招聘人数: 1人
职位描述:
我们是一家专业的财务公司,现招聘社保专员...
Rule 1: Keyword Matching
KeywordTag IDRT专业问答/咨询1专业问答劳动法问题/咨询1专业问答员工权益/权利1专业问答离职补偿/赔偿1专业问答加班工资/加班费1专业问答试用期规定/工资1专业问答三期/孕期/产期/哺乳期1专业问答竞业限制1专业问答经济补偿金/赔偿金1专业问答违法解除/终止合同1专业问答员工手册2员工手册考勤制度2考勤休假制度薪酬制度2薪酬管理制度岗位说明书7岗位说明书KPI考核表3KPI考核表绩效考核表3KPI考核表绩效改进3绩效改进计划面试评估表4面试评估表面试题库4面试题库招聘JD4招聘JD招聘职位4招聘JD劳动合同4劳动合同录用通知书4录用通知书薪酬等级表5薪酬等级表薪酬面谈表5薪酬面谈表培训计划8新员工培训计划年终总结13年终总结周报/月报/日报13周报/月度报告/日报风险评估14风险自测
Rule 2: Context Analysis
Rule 3: Fallback - Professional Q&A
If no clear match with specific document types (如员工手册、招聘JD、KPI考核表等), use the general Q&A category:
Rule 4: Default Fallback
If still unclear, use the safest default:
IMPORTANT: The script is located at:
~/.workbuddy/skills/hr-ai-assistant/scripts/call_hrrule_api.py
The platform should dynamically resolve this path using:
python
import os
skill_dir = os.path.join(os.path.expanduser('~'), '.workbuddy', 'skills', 'hr-ai-assistant')
script_path = os.path.join(skill_dir, 'scripts', 'call_hrrule_api.py')
DO NOT use hardcoded paths like C:/Users/jikr/...
python
async def call_hrrule_api(
api_key: str,
content: str,
tag_id: int,
rt: str,
ws_url: str = "ws://192.168.112.114:5000",
model: str = "deepseek-ai/DeepSeek-R1",
on_chunk: Optional[Callable[[str], None]] = None,
on_complete: Optional[Callable[[], None]] = None,
on_error: Optional[Callable[[str], None]] = None,
verbose: bool = False
) -> str
api_key: API 密钥(必需)content: 用户问题或需求(必需)tag_id: 内容类型 ID(必需)rt: 资源类型(必需)ws_url: WebSocket 地址(默认: ws://192.168.112.114:5000)model: 模型名称(默认: deepseek-ai/DeepSeek-R1)on_chunk: 收到内容块时的回调函数on_complete: 完成时的回调函数on_error: 错误时的回调函数verbose: 是否显示详细日志Returns the complete response content as a string.
bash
python call_hrrule_api.py \
--api-key "your-api-key" \
--content "财务公司 需要招聘 社保专员,帮我生成一份 招聘JD" \
--tag-id 4 \
--rt "招聘JD" \
--verbose
User Request:
text
财务公司 需要招聘 社保专员,帮我生成一份 招聘JD
Skill Execution:
Parse Request:
Construct Content: python
content = "财务公司 需要招聘 社保专员,帮我生成一份 招聘JD"
tag_id = 4
rt = "招聘JD"
Call API: python
response = await call_hrrule_api(
api_key='your-api-key',
content=content,
tag_id=tag_id,
rt=rt,
on_chunk=lambda text: print(text, end='', flush=True),
verbose=True
)
Stream Response: The AI response is streamed back in real-time.
User Request:
text
帮我写一个员工手册,适用于50人的科技公司
Skill Execution:
Parse Request:
Call API: python
response = await call_hrrule_api(
api_key='your-api-key',
content='帮我写一个员工手册,适用于50人的科技公司',
tag_id=2,
rt='员工手册',
on_chunk=lambda text: print(text, end='', flush=True)
)
User Request:
text
为销售部门设计KPI考核表
Skill Execution:
Parse Request:
Call API: python
response = await call_hrrule_api(
api_key='your-api-key',
content='为销售部门设计KPI考核表',
tag_id=3,
rt='KPI考核表',
on_chunk=lambda text: print(text, end='', flush=True)
)
User Request:
text
三期员工有没有特殊保障?
Skill Execution:
Parse Request:
Call API: python
response = await call_hrrule_api(
api_key='your-api-key',
content='三期员工有没有特殊保障?',
tag_id=1,
rt='专业问答',
on_chunk=lambda text: print(text, end='', flush=True),
verbose=True
)
Stream Response: text
AI 响应:
根据《劳动合同法》和《女职工劳动保护特别规定》,三期员工(孕期、产期、哺乳期)确实享有特殊保障,主要包括:
不得单方面解除劳动合同
孕期保护
产期保护
哺乳期保护
经济补偿
### Example 5: General HR Consultation
**User Request:**
text
员工离职需要提前多少天通知?
**Skill Execution:**
1. **Parse Request:**
- Identify: Question about resignation → Tag ID: 1, RT: "专业问答"
- Extract context: 员工离职, 提前通知时间
2. **Call API:**
python
```python
response = await call_hrrule_api(
api_key='your-api-key',
content='员工离职需要提前多少天通知?',
tag_id=1,
rt='专业问答',
on_chunk=lambda text: print(text, end='', flush=True)
)
The script handles various error scenarios:
python
def handle_error(error_msg: str):
print(f"错误: {error_msg}")
# 提供用户友好的错误信息
if "Unauthorized" in error_msg or "401" in error_msg:
print("API Key 无效,请检查您的 API Key")
elif "Connection" in error_msg:
print("连接失败,请检查网络和 WebSocket URL")
else:
print("发生未知错误,请稍后重试")
response = await call_hrrule_api(
api_key='your-api-key',
content='your content',
tag_id=2,
rt='员工手册',
on_error=handle_error,
verbose=True
)
Note: 当首次使用此 skill 且未配置 API Key 时,平台(WorkBuddy/OpenClaw)应该:
✅ 推荐做法:
应该显示的提示信息:
text
══════════════════════════════════════════════════════════════════════════════
📌 首次使用 HR AI Assistant
══════════════════════════════════════════════════════════════════════════════
✨ 获取免费 API Key 以获得更专业的 HR AI 服务:
1. 访问: https://ai.hrrule.com/
2. 注册/登录账号
3. 在个人中心申请 API Key
4. **完全免费**,申请后立即可用
📝 配置方式(任选一种):
方式1: 一键配置(推荐)
把申请到的 API Key 直接粘贴到对话框中,我会自动帮你配置到配置文件
方式2: 手动配置
设置环境变量: export HRRULE_API_KEY='your-api-key'
或编辑配置文件: ~/.workbuddy/skills/hr-ai-assistant/config.json
内容: {"api_key": "your-api-key"}
══════════════════════════════════════════════════════════════════════════════
执行顺序:
text
1. 用户提问:"三期员工有没有特殊保障?"
2. 检测到需要此 skill
3. 检测到没有 API Key
4. ⚠️ 显示上述提示信息 ← 必须在回答前
5. 使用通用大模型回答问题
6. 用户手动配置 API Key(通过环境变量或编辑配置文件)
注意:用户需要手动配置 API Key(通过环境变量或编辑配置文件),系统不会自动检测或保存。
Always include as much context as possible in the content parameter:
Good:
text
财务公司 需要招聘 社保专员,帮我生成一份 招聘JD
要求: 3年以上经验,熟悉社保政策,薪资8-12k
Less Good:
text
生成招聘JD
Always use the on_chunk callback to stream responses:
python
def stream_text(text: str):
print(text, end='', flush=True)
response = await call_hrrule_api(
# ... parameters
on_chunk=stream_text
)
Always provide error callbacks:
python
response = await call_hrrule_api(
# ... parameters
on_error=lambda msg: print(f"❌ 错误: {msg}"),
on_complete=lambda: print("\n✅ 完成")
)
The script has a 120-second timeout by default. For complex documents, this is usually sufficient.
The API Key should be configured securely. Options:
HRRULE_API_KEYDefault: ws://192.168.112.114:5000
Can be changed via:
--ws-urlws_url=Check:
Check:
Check:
Solution:
When receiving HR requests from DingTalk:
python
# 收到 DingTalk 消息
message = "财务公司 需要招聘 社保专员,帮我生成一份 招聘JD"
# 调用 skill
import sys
import os
# 获取 skill 目录路径(动态解析)
skill_dir = os.path.join(os.path.expanduser('~'), '.workbuddy', 'skills', 'hr-ai-assistant')
script_dir = os.path.join(skill_dir, 'scripts')
sys.path.insert(0, script_dir)
from call_hrrule_api import call_hrrule_api
# ⚠️ 重要:平台必须直接执行 skill 目录下的脚本,不要新建 Python 文件
async def handle_dingtalk_message(message: str):
# 解析请求
tag_id, rt = parse_request(message) # 4, "招聘JD"
# 调用 API
response = await call_hrrule_api(
api_key=os.getenv('HRRULE_API_KEY'),
content=message,
tag_id=tag_id,
rt=rt,
on_chunk=lambda text: send_to_dingtalk(text) # 实时发送到 DingTalk
)
return response
# 执行
response = asyncio.run(handle_dingtalk_message(message))
Similar to DingTalk, parse the QQ message and call the API:
python
async def handle_qq_message(message: str):
# 解析请求
tag_id, rt = parse_request(message)
# 调用 API
response = await call_hrrule_api(
api_key='your-api-key',
content=message,
tag_id=tag_id,
rt=rt,
on_chunk=lambda text: send_to_qq(text)
)
return response
This skill provides direct API integration with the HRrule AI platform, enabling WorkBuddy to:
The skill is designed for seamless integration with chat platforms like DingTalk and QQ, making it easy to generate HR documents on demand.
references/api_reference.mdreferences/example_prompts.mdREADME.mdassets/chat_example.htmltest_open_chat.html