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 { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { everhourAuth } from '../auth';
import { everhourApiCall } from '../common/client';

export const createTaskAction = createAction({
    auth: everhourAuth,
    name: 'create-task',
    displayName: 'Create Task',
    description: 'Creates a new task in a project.',
    audience: 'both',
    aiMetadata: { description: 'Creates a new task inside an Everhour project, identified by its project ID, with the given task name. Use when an agent needs to add a trackable work item before logging time or starting a timer against it. Not idempotent: each call creates a separate task even with identical input.', idempotent: false },
    props: {
        projectId: Property.ShortText({
            displayName: 'Project ID',
            description: 'The ID of the project to create the task in.',
            required: true,
        }),
        name: Property.ShortText({
            displayName: 'Task Name',
            description: 'The name of the task.',
            required: true,
        }),
    },
    async run(context) {
        const { projectId, name } = context.propsValue;

        const response = await everhourApiCall({
            apiKey: context.auth.secret_text,
            method: HttpMethod.POST,
            resourceUri: `/projects/${projectId}/tasks`,
            body: {
                name,
            },
        });

        return response;
    },
});