首页 全部提示词 Agent Skill

Trello 集成技能

trello-integration-skill

技能 @mertogemini 4,864 字符 在 prompts.chat 查看 译文有问题?

中文译文

Trello 集成技能

Trello 集成技能在 AI 智能体与用户的 Trello 账户之间提供无缝连接。它使智能体能够自主获取现有的看板和列表,并根据用户提示词在特定看板上创建新的任务卡片。

功能

  • 获取看板:检索用户有权访问的所有 Trello 看板列表,包括其名称、ID 和 URL。
  • 获取列表:检索属于特定看板的所有列表(如“待办”、“进行中”、“已完成”等列)。
  • 创建卡片:在指定列表中自动创建带有标题和描述的新卡片。

设置与前提条件

要在本地使用此技能,你需要提供你的 Trello 开发者 API 凭据。

  1. 在 Trello 开发者门户(Power-Ups 管理) 生成你的凭据。
  2. 创建一个 API Key。
  3. 生成一个 Secret Token(读/写权限)。
  4. 将这些凭据添加到项目根目录的 .env 文件中:
# Trello Integration
TRELLO_API_KEY=your_api_key_here
TRELLO_TOKEN=your_token_here

用法与架构

该技能使用位于 .agent/skills/trello_skill/scripts/ 目录中的独立 Node.js 脚本。

1. 列出所有看板

获取已认证用户的所有看板,以确定正确的目标 boardId。

执行:

node .agent/skills/trello_skill/scripts/list_boards.js

2. 获取看板中的列表列(Lists)

获取特定看板内的列表,以找到确切的 listId(例如,获取“To Do”列的 ID)。

执行:

node .agent/skills/trello_skill/scripts/list_lists.js <boardId>

3. 创建新卡片

将新卡片推送到指定列表。

执行:

node .agent/skills/trello_skill/scripts/create_card.js <listId> "<Card Title>" "<Optional Description>"

(始终用双引号包裹卡片标题和描述,以防止 bash 参数拆分)。


AI Agent 工作流

当用户请求管理或向 Trello 添加任务时,自主执行以下步骤:

  1. 确定目标:如果目标 listId 未知,先运行 list_boards.js 确定正确的 boardId,然后执行 list_lists.js <boardId> 获取对应的 listId(例如,对于 "To Do")。
  2. 执行命令:运行 create_card.js <listId> "Task Title" "Task Description" 脚本。
  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("错误:.env 文件中缺少 TRELLO_API_KEY 或 TRELLO_TOKEN。"); 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 错误!状态:${response.status}); const boards = await response.json(); console.log("--- 你的 Trello 看板 ---"); boards.forEach(b => console.log(名称:${b.name}\nID:${b.id}\nURL:${b.url}\n)); } catch (error) { console.error("获取看板失败:", 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("错误:.env 文件中缺少 TRELLO_API_KEY 或 TRELLO_TOKEN。"); process.exit(1); }

const boardId = process.argv[2]; if (!boardId) { console.error("用法:node list_lists.js "); 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 错误!状态:${response.status}); const lists = await response.json(); console.log(--- 看板 ${boardId} 中的列表 ---); lists.forEach(l => console.log(名称:"${l.name}"\nID:${l.id}\n)); } catch (error) { console.error("获取列表失败:", error.message); } } 列出列表();

English original

Trello Integration Skill

The Trello Integration Skill provides a seamless connection between the AI agent and the user's Trello account. It empowers the agent to autonomously fetch existing boards and lists, and create new task cards on specific boards based on user prompts.

Features

  • Fetch Boards: Retrieve a list of all Trello boards the user has access to, including their Name, ID, and URL.
  • Fetch Lists: Retrieve all lists (columns like "To Do", "In Progress", "Done") belonging to a specific board.
  • Create Cards: Automatically create new cards with titles and descriptions in designated lists.

Setup & Prerequisites

To use this skill locally, you need to provide your Trello Developer API credentials.

  1. Generate your credentials at the Trello Developer Portal (Power-Ups Admin).
  2. Create an API Key.
  3. Generate a Secret Token (Read/Write access).
  4. Add these credentials to the project's root .env file:
# Trello Integration
TRELLO_API_KEY=your_api_key_here
TRELLO_TOKEN=your_token_here

Usage & Architecture

The skill utilizes standalone Node.js scripts located in the .agent/skills/trello_skill/scripts/ directory.

1. List All Boards

Fetches all boards for the authenticated user to determine the correct target boardId.

Execution:

node .agent/skills/trello_skill/scripts/list_boards.js

2. List Columns (Lists) in a Board

Fetches the lists inside a specific board to find the exact listId (e.g., retrieving the ID for the "To Do" column).

Execution:

node .agent/skills/trello_skill/scripts/list_lists.js <boardId>

3. Create a New Card

Pushes a new card to the specified list.

Execution:

node .agent/skills/trello_skill/scripts/create_card.js <listId> "<Card Title>" "<Optional Description>"

(Always wrap the card title and description in double quotes to prevent bash argument splitting).


AI Agent Workflow

When the user requests to manage or add a task to Trello, follow these steps autonomously:

  1. Identify the Target: If the target listId is unknown, first run list_boards.js to identify the correct boardId, then execute list_lists.js <boardId> to retrieve the corresponding listId (e.g., for "To Do").
  2. Execute Command: Run the create_card.js <listId> "Task Title" "Task Description" script.
  3. Report Back: Confirm the successful creation with the user and provide the direct URL to the newly created Trello card. 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 "); 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();