办公效率
BambooHR 员工事件订阅与验签
备妥有权限的API密钥、HTTPS端点和签名密钥,配置全局或权限型Webhook并验证事件签名
# BambooHR Webhook 与事件
## 概述
BambooHR 支持两种 Webhook:**全局 Webhook**(在 BambooHR 管理界面中配置,可访问部分字段)和**权限型 Webhook**(通过 API 创建,可访问 API 密钥所属用户能看到的所有字段)。此技能涵盖两种类型的创建、验证和处理。
## 前提条件
- 具有 Webhook 管理权限的 BambooHR API 密钥
- 可从互联网访问的 HTTPS 端点
- 用于 HMAC-SHA256 签名验证的 Webhook 密钥
## 操作说明
### 第 1 步:了解 Webhook 类型
| 特性 | 全局 Webhook | 权限型 Webhook |
|---------|----------------|----------------------|
| 配置方式 | BambooHR 管理界面 | API(`POST /webhooks/`)|
| 字段访问范围 | 部分标准字段 | 用户可访问的所有字段 |
| 身份验证 | 共享密钥 | 每个 Webhook 独立的密钥 |
| 签名 | SHA-256 HMAC | SHA-256 HMAC |
| 操作 | Created、Updated、Deleted | Created、Updated、Deleted |
### 第 2 步:通过 API 创建权限型 Webhook
```typescript
// POST /webhooks/ — register a new webhook
const webhook = await client.request<{
id: number;
name: string;
privateKey: string; // Save this — used for HMAC verification
}>('POST', '/webhooks/', {
name: 'Employee Sync Webhook',
monitorFields: [
'firstName', 'lastName', 'jobTitle', 'department',
'division', 'location', 'workEmail', 'status',
'supervisor', 'hireDate', 'terminationDate',
],
postFields: {
firstName: 'firstName',
lastName: 'lastName',
jobTitle: 'jobTitle',
department: 'department',
status: 'status',
workEmail: 'workEmail',
},
url: 'https://your-app.example.com/webhooks/bamboohr',
format: 'json',
frequency: { every: 0 }, // 0 = immediate, or N = batch every N minutes
limit: { enabled: false },
});
console.log(`Webhook ID: ${webhook.id}`);
console.log(`Private Key: ${webhook.privateKey}`);
// IMPORTANT: Store the privateKey securely — it's the HMAC secret
```
### 第 3 步:列出和管理 Webhook
```typescript
// GET /webhooks/ — list all webhooks for this API key
const webhooks = await client.request<any[]>('GET', '/webhooks/');
for (const wh of webhooks) {
console.log(`${wh.id}: ${wh.name} -> ${wh.url} (${wh.status})`);
}
// GET /webhooks/{id}/ — get webhook details
const detail = await client.request<any>('GET', `/webhooks/${webhook.id}/`);
// GET /webhooks/{id}/log — get webhook delivery logs
const logs = await client.request<any[]>('GET', `/webhooks/${webhook.id}/log`);
for (const log of logs) {
console.log(`${log.timestamp}: ${log.statusCode} (${log.employeeId})`);
}
// DELETE /webhooks/{id}/ — remove a webhook
await client.request('DELETE', `/webhooks/${webhook.id}/`);
// GET /webhooks/monitor_fields — see available fields to monitor
const fields = await client.request<any>('GET', '/webhooks/monitor_fields');
```
### 第 4 步:签名验证
BambooHR 发送两个请求头:`X-BambooHR-Signature`(HMAC-SHA256 十六进制摘要)和 `X-BambooHR-Timestamp`。
```typescript
import crypto from 'crypto';
function verifyBambooHRWebhook(
rawBody: Buffer | string,
signature: string,
timestamp: string,
secret: string,
): boolean {
// 1. Reject timestamps > 5 minutes old (replay protection)
const age = Math.abs(Date.now() - parseInt(timestamp, 10) * 1000);
if (age > 300_000) {
console.error(`Webhook timestamp too old: ${age}ms`);
return false;
}
// 2. Compute expected HMAC
const payload = `${timestamp}.${rawBody.toString()}`;
const expected = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
// 3. Timing-safe comparison
try {
return crypto.timingSafeEqual(
Buffer.from(signature, 'hex'),
Buffer.from(expected, 'hex'),
);
} catch {
return false;
}
}
```
### 第 5 步:Webhook 处理程序(Express.js)
```typescript
import express from 'express';
const app = express();
app.post('/webhooks/bamboohr',
express.raw({ type: 'application/json' }),
async (req, res) => {
const sig = req.headers['x-bamboohr-signature'] as string;
const ts = req.headers['x-bamboohr-timestamp'] as string;
if (!sig || !ts || !verifyBambooHRWebhook(req.body, sig, ts, process.env.BAMBOOHR_WEBHOOK_SECRET!)) {
console.error('Webhook signature verification failed');
return res.status(401).json({ error: 'Invalid signature' });
}
// Parse the webhook payload
const payload = JSON.parse(req.body.toString());
// Respond immediately — process asynchronously
res.status(200).json({ received: true });
// Process each employee in the payload
await processWebhookPayload(payload);
},
);
```
### 第 6 步:处理 Webhook 载荷
BambooHR Webhook 载荷包含按操作类型分组的员工数据。
```typescript
interface BambooHRWebhookPayload {
employees: {
id: string;
action: 'Created' | 'Updated' | 'Deleted';
changedFields: string[]; // Which fields triggered this notification
fields: Record<string, string>; // Current field values (from postFields config)
}[];
}
async function processWebhookPayload(payload: BambooHRWebhookPayload): Promise<void> {
for (const employee of payload.employees) {
const { id, action, changedFields, fields } = employee;
switch (action) {
case 'Created':
console.log(`New employee: ${fields.firstName} ${fields.lastName} (ID: ${id})`);
await onEmployeeCreated(id, fields);
break;
case 'Updated':
console.log(`Employee ${id} updated: ${changedFields.join(', ')}`);
// Route to specific handlers based on what changed
if (changedFields.includes('department') || changedFields.includes('jobTitle')) {
await onPositionChanged(id, fields);
}
if (changedFields.includes('status')) {
if (fields.status === 'Inactive') {
await onEmployeeTerminated(id, fields);
}
}
if (changedFields.includes('supervisor')) {
await onManagerChanged(id, fields);
}
break;
case 'Deleted':
console.log(`Employee ${id} deleted`);
await onEmployeeDeleted(id);
break;
}
}
}
// Example handlers
async function onEmployeeCreated(id: string, fields: Record<string, string>) {
// Provision accounts in external systems
// e.g., create Slack account, set up email, assign training
}
async function onEmployeeTerminated(id: string, fields: Record<string, string>) {
// Deprovisioning: disable accounts, revoke access, archive data
}
async function onPositionChanged(id: string, fields: Record<string, string>) {
// Update org chart, Slack channels, access groups
}
async function onManagerChanged(id: string, fields: Record<string, string>) {
// Update reporting hierarchy in downstream systems
}
async function onEmployeeDeleted(id: string) {
// Remove from external systems
}
```
### 第 7 步:幂等性(防止重复处理)
```typescript
import { Redis } from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
async function deduplicateWebhook(
employeeId: string,
action: string,
changedFields: string[],
): Promise<boolean> {
// Create a unique key for this specific change
const changeKey = `bamboohr:webhook:${employeeId}:${action}:${changedFields.sort().join(',')}`;
const wasSet = await redis.set(changeKey, '1', 'EX', 3600, 'NX'); // 1 hour TTL
return wasSet === 'OK'; // true = first time, false = duplicate
}
```
### 第 8 步:在本地测试 Webhook
```bash
# 1. Expose local server with ngrok
ngrok http 3000
# Note the https:// URL
# 2. Create a test webhook pointing to your ngrok URL
# Use the API to create webhook with your ngrok URL
# 3. Or manually send a test payload
curl -X POST http://localhost:3000/webhooks/bamboohr \
-H "Content-Type: application/json" \
-H "X-BambooHR-Timestamp: $(date +%s)" \
-H "X-BambooHR-Signature: test" \
-d '{"employees": [{"id":"1","action":"Updated","changedFields":["department"],"fields":{"firstName":"Jane","department":"Engineering"}}]}'
```
## 输出
- 通过 BambooHR API 注册 Webhook 并设置监控字段
- 对所有传入的 Webhook 进行 HMAC-SHA256 签名验证
- 按操作类型(Created、Updated、Deleted)路由事件
- 针对特定字段的变更处理程序(职位、状态、经理)
- 通过 Redis 去重
- 使用 ngrok 的本地测试流程
## 错误处理
| 问题 | 原因 | 解决方案 |
|-------|-------|----------|
| 签名无效 | Webhook 密钥错误 | 验证创建 Webhook 时的 `privateKey` |
| `changedFields` 为空 | Created/Deleted 操作 | 正常——只有 Updated 包含已更改的字段 |
| 载荷中缺少字段 | 不在 `postFields` 配置中 | 更新 Webhook 的 `postFields` 配置 |
| Webhook 未触发 | Webhook 已禁用或 URL 无法访问 | 通过 API 检查 Webhook 状态和日志 |
## 企业使用注意事项
- **必须使用 HTTPS**:BambooHR 仅向 HTTPS URL 发送 POST 请求
- **重试行为**:BambooHR 会重试失败的投递;需实现幂等性
- **自定义字段**:权限型 Webhook 可以监控自定义字段(使用来自 `/meta/fields/` 的字段 ID)
- **批处理频率**:将 `frequency.every` 设为 > 0,以便将多项更改合并成更少次数的投递
## 资源
- [BambooHR Webhook 指南](https://documentation.bamboohr.com/docs/webhooks)
- [BambooHR 全局 Webhook](https://documentation.bamboohr.com/docs/global-webhooks)
- [BambooHR 权限型 Webhook](https://documentation.bamboohr.com/docs/permissioned-webhooks)
- [BambooHR Webhook API 参考](https://documentation.bamboohr.com/reference/webhooks-1)
## 后续步骤
有关性能优化,请参阅 `bamboohr-performance-tuning`。同类提示词
办公效率· n8n 工作流的对话模型
商品照片转棚拍广告生图指令
上传商品照片并提供说明文字,分析材质、配色和原图问题,写出保留商品外观的棚拍广告生图指令。
=你是一位专业产品摄影师和广告创意总监。分析上传的产品图片及其配文:{{ $('Telegram Trigger Received').item.json.message.caption }} 你的任务是创建一段详细的图像生成提示词,将这张产品照片转化为高端、商业级的广告视觉作品。 分析要求: 1. **产品识别**:识别产品类型、尺寸、类别、材质、配色和关键特征 2. **当前状态评估**:指出当前的光线、背景、构图和质量问题 3. **目标美学**:根据产品类别确定理想的广告风格(奢侈品、科技、食品、时尚等) 输出(严格使用 JSON 格式):办公效率· n8n 工作流的对话模型
Veo 3营销视频分镜指令
填写视频需求、营销目标、图像描述和画幅,生成包含场景、运镜、动作、灯光与结尾的结构化制片指令。
=# Veo3 视频生成系统提示词 你是一名专业的视频提示词工程师,擅长为 Veo3 视频生成撰写细致、富有电影感的提示词。你的角色是分析用户输入,将其转化为全面的视频生成指令,以产出高质量、引人入胜的内容。 ## 输入分析 你将收到以下用户输入: - **AI Videos instructions**:视频生成的核心用户请求 - **Campaign objectives**:营销活动目标和说明 - **Images Description**:用户提供的视觉背景信息 - **Aspect Ratio**:要求的视频尺寸比例 ## 输出格式 你
可填 21 项
办公效率· n8n 工作流的对话模型
保留原品的社媒广告视觉方案
提供商品图和配文,生成保留原品外观的广告生图说明,广告文字仅从配文提取,缺项留空。
={ "system_prompt": "你是一位顶尖创意总监,专攻爆款产品广告,拥有15年以上奢侈品牌广告活动经验。将产品图片转化为商业级广告,让浏览者停下滑动并促进转化。", "instructions": { "core_rules": [ "保持原始产品100%不变——不得修改、替换或扭曲", "只提取和使用用户配文中提供的文字", "如果配文中没有相关文字,文字字段留空——绝不生成AI广告语", "专注于高端视觉强化和商业摄影技巧", "制作适合在Instagram展办公效率· Claude Fable 5.2
用代码制作长纪录片流程
从题材调研、脚本和样帧审核开始,按章节生成三维分镜、旁白、环境声与可复现渲染。
<inputs> 向我询问: 1. 我的主题 2. 目标视频时长 3. 我是否已有脚本 如果我只给你一个主题,先研究该主题并撰写脚本。 开始制作任何内容之前,先向我展示: - 完整脚本 - 章节拆分 - 前 60 seconds 的分镜计划 - 6 张展示预期视觉方向的静帧 在我认可视觉效果之前,不要渲染完整视频。 </inputs> <story> 按照高品质 YouTube 纪录片的方式来写,不要写成 AI 科普解说。 故事必须始终向前推进。 每个部分都需要包含以下内容之一: - 一个新问题 - 一个揭示 - 一个矛盾 - 一个后果 - 一条证据
办公效率
同场景表情变化九宫格自拍
上传主角照片,可选搭档参考图或设定,并填写服装、背景或姿势偏好,生成同一布光和构图的九张变化。
# photo-booth ## 何时使用此 skill - 当用户希望根据参考图制作大头贴宫格、表情宫格、情侣自拍宫格、同步姿势组图或多种人像变体时使用。 - 当请求制作 3x3 宫格,且主体、房间、服装、构图和布光保持一致,仅表情或细微姿势发生变化时触发。 ## 必需输入 - 主要人物的主参考图。 - 可选的伴侣或角色参考图。 - 如果未提供伴侣参考图,需提供期望的伴侣设定。 - 用户指定的服装、背景、摄影时代、姿势清单或氛围。 如果缺少主参考图,请用户附上。如果伴侣设定或预期风格不明确,提出一个有针对性的问题。 ## 连续性规则 -
需参考图
办公效率· Claude Code / 动效编程
单镜头立体落地页飞越动画
提供落地页链接、品牌名、标志和两段收尾文案,可选配乐,制作卡片随镜头掠过而浮起的连续飞越短片。
<inputs> 向我索取:我的落地页链接、品牌名称和标志、由两部分组成的结尾文案(一句陈述,后接一小段斜体文字),以及一条 15 second 音轨(可选)。 </inputs> <direction> 以 60fps 对我的落地页进行 14.5 second 3D 飞越拍摄,1440x1152。页面平放在明亮的摄影棚地面上(中央为 #f9fbfb,角落为 #f2f3f6),周围有柔和宽阔的阴影,圆角为 24px。全程使用一个连续镜头,绝不切镜:镜头从首屏上方低处开始,以恒定速度沿页面向后滑行,同时朝页面上方看去;然后垂直升至正上方,将整个页面呈现为