任务看板查询与卡片自动创建
连接用户的任务管理账户,查找目标看板和列表,按要求新建任务卡片并返回访问链接。
完整提示词
---
name: trello-integration-skill
description: 此技能允许你与 Trello 账户交互,以列出看板、查看列表,并自动创建卡片。
---
# Trello Integration Skill
Trello Integration Skill 提供了 AI 代理与用户 Trello 账户之间的无缝连接。它使代理能够自主获取现有看板和列表,并根据用户提示在特定看板上创建新的任务卡片。
## 功能
- **获取看板**:检索用户有权访问的所有 Trello 看板,包括其名称、ID 和 URL。
- **获取列表**:检索属于特定看板的所有列表(如“待办”、“进行中”、“已完成”等列)。
- **创建卡片**:在指定列表中自动创建带有标题和描述的新卡片。
---
## 设置与先决条件
要在本地使用此技能,你需要提供你的 Trello 开发者 API 凭据。
1. 在 [Trello 开发者门户(Power-Ups 管理)](https://trello.com/app-key) 生成你的凭据。
2. 创建一个 API 密钥。
3. 生成一个密钥令牌(读/写权限)。
4. 将这些凭据添加到项目根目录的 `.env` 文件中:
```env
# Trello Integration
TRELLO_API_KEY=your_api_key_here
TRELLO_TOKEN=your_token_here
```
---
## 使用方法与架构
该技能使用位于 `.agent/skills/trello_skill/scripts/` 目录下的独立 Node.js 脚本。
### 1. 列出所有看板
获取已认证用户的所有看板,以确定正确的目标 `boardId`。
**执行:**
```bash
node .agent/skills/trello_skill/scripts/list_boards.js
```
### 2. 列出看板中的列(列表)
获取特定看板内的所有列表,以找到确切的 `listId`(例如,获取“待办”列的 ID)。
**执行:**
```bash
node .agent/skills/trello_skill/scripts/list_lists.js <boardId>
```
### 3. 创建新卡片
向指定列表推送一张新卡片。
**执行:**
```bash
node .agent/skills/trello_skill/scripts/create_card.js <listId> "<卡片标题>" "<可选描述>"
```
*(始终用双引号包裹卡片标题和描述,以防止 bash 参数拆分)。*
---
## AI 代理工作流程
当用户请求在 Trello 中管理或添加任务时,请按以下步骤自主执行:
1. **确定目标**:如果目标 `listId` 未知,首先运行 `list_boards.js` 以识别正确的 `boardId`,然后执行 `list_lists.js <boardId>` 以检索对应的 `listId`(例如,用于“待办”列)。
2. **执行命令**:运行 `create_card.js <listId> "任务标题" "任务描述"` 脚本。
3. **反馈结果**:向用户确认卡片创建成功,并提供指向新创建的 Trello 卡片的直接 URL。
FILE:create_card.js
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '../../../../.env') });
const API_KEY = process.env.TRELLO_API_KEY;
const TOKEN = process.env.TRELLO_TOKEN;
if (!API_KEY || !TOKEN) {
console.error("Error: TRELLO_API_KEY or TRELLO_TOKEN is missing from the .env file.");
process.exit(1);
}
const listId = process.argv[2];
const cardName = process.argv[3];
const cardDesc = process.argv[4] || "";
if (!listId || !cardName) {
console.error(`Usage: node create_card.js <listId> "${card_name}" ["${card_description}"]`);
process.exit(1);
}
async function createCard() {
const url = `https://api.trello.com/1/cards?idList=${listId}&key=${API_KEY}&token=${TOKEN}`;
try {
const response = await fetch(url, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: cardName,
desc: cardDesc,
pos: 'top'
})
});
if (!response.ok) {
const errText = await response.text();
throw new Error(`HTTP error! status: ${response.status}, message: ${errText}`);
}
const card = await response.json();
console.log(`Successfully created card!`);
console.log(`Name: ${card.name}`);
console.log(`ID: ${card.id}`);
console.log(`URL: ${card.url}`);
} catch (error) {
console.error("Failed to create card:", error.message);
}
}
createCard();
FILE:list_board.js
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '../../../../.env') });
const API_KEY = process.env.TRELLO_API_KEY;
const TOKEN = process.env.TRELLO_TOKEN;
if (!API_KEY || !TOKEN) {
console.error("Error: TRELLO_API_KEY or TRELLO_TOKEN is missing from the .env file.");
process.exit(1);
}
async function listBoards() {
const url = `https://api.trello.com/1/members/me/boards?key=${API_KEY}&token=${TOKEN}&fields=name,url`;
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
const boards = await response.json();
console.log("--- Your Trello Boards ---");
boards.forEach(b => console.log(`Name: ${b.name}\nID: ${b.id}\nURL: ${b.url}\n`));
} catch (error) {
console.error("Failed to fetch boards:", error.message);
}
}
listBoards();
FILE:list_lists.js
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '../../../../.env') });
const API_KEY = process.env.TRELLO_API_KEY;
const TOKEN = process.env.TRELLO_TOKEN;
if (!API_KEY || !TOKEN) {
console.error("Error: TRELLO_API_KEY or TRELLO_TOKEN is missing from the .env file.");
process.exit(1);
}
const boardId = process.argv[2];
if (!boardId) {
console.error("Usage: node list_lists.js <boardId>");
process.exit(1);
}
async function listLists() {
const url = `https://api.trello.com/1/boards/${boardId}/lists?key=${API_KEY}&token=${TOKEN}&fields=name`;
try {
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
const lists = await response.json();
console.log(`--- Lists in Board ${boardId} ---`);
lists.forEach(l => console.log(`Name: "${l.name}"\nID: ${l.id}\n`));
} catch (error) {
console.error("Failed to fetch lists:", error.message);
}
}
listLists();可替换内容
- [Trello 开发者门户(Power-Ups 管理)]
- [2]
- [3]
- [4]
- ["${card_description}"]
分类与标签
办公效率、任务管理、看板查询、卡片创建、办公自动化