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.7 KB
Raw Blame
import { meistertaskAuth } from '../auth';
import {  makeRequest, meisterTaskCommon } from '../common/common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';

export const createTask = createAction({
  auth: meistertaskAuth,
  name: 'create_task',
  classification: 'WRITE',
  displayName: 'Create Task',
  description: 'Creates a new task',
  audience: 'both',
  aiMetadata: { description: 'Create a new task within a section of a MeisterTask project, optionally setting notes, an assignee, and a due date. Use to add a to-do item to a board; requires the target section and a task name. Not idempotent — each call creates another task even if the name matches an existing one (use Find or Create Task to avoid duplicates).', idempotent: false },
  props: {
    project: meisterTaskCommon.project,
    section: meisterTaskCommon.section,
    name: Property.ShortText({
      displayName: 'Task Name',
      required: true,
    }),
    notes: Property.LongText({
      displayName: 'Notes',
      required: false,
    }),
    assigned_to: meisterTaskCommon.person,
    due_date: Property.DateTime({
      displayName: 'Due Date',
      required: false,
    }),
  },
  async run(context) {
    const token = context.auth.access_token;
    const { section, name, notes, assigned_to, due_date } = context.propsValue;

    const body: any = {
      name,
      section_id: section,
    };

    if (notes) body.notes = notes;
    if (assigned_to) body.assigned_to_id = assigned_to;
    if (due_date) body.due = due_date;

    const response = await makeRequest(
      HttpMethod.POST,
      '/tasks',
      token,
      body
    );

    return response.body;
  },
});