Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.5 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import {
  httpClient,
  HttpRequest,
  HttpMethod,
} from '@activepieces/pieces-common';
import { trelloCommon } from '../../common';
import { TrelloCard } from '../../common/props/card';
import { trelloAuth } from '../../..';
import { getCardActionOutputSchema } from '../../output-schemas';

export const getCard = createAction({
  auth: trelloAuth,
  name: 'get_card',
  classification: 'READ',
  displayName: 'Get Card',
  description: 'Gets a card by ID.',
  audience: 'human',
  outputSchema: getCardActionOutputSchema,
  aiMetadata: { description: 'Retrieves the full details of a single Trello card by its card ID. Use to look up the current name, description, due date, labels, list, and other fields of a card before acting on it. Read-only and idempotent.', idempotent: true },
  props: {
    cardId: Property.ShortText({
      description: "From an earlier step, or the code after /c/ in the card's URL.",
      displayName: 'Card ID',
      placeholder: 'aBcD1234',
      required: true,
    }),
  },

  async run(context) {
    const request: HttpRequest = {
      method: HttpMethod.GET,
      url:
        `${trelloCommon.baseUrl}cards/` +
        context.propsValue['cardId'] +
        `?key=` +
        context.auth.username +
        `&token=` +
        context.auth.password,
      headers: {
        Accept: 'application/json',
      },
    };
    return (await httpClient.sendRequest<TrelloCard>(request)).body;
  },
});