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.3 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { motionAuth } from '../auth';
import { BASE_URL, taskId, workspaceId } from '../common/props';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';

export const moveTask = createAction({
  auth: motionAuth,
  name: 'moveTask',
  classification: 'WRITE',
  displayName: 'Move Task',
  description: 'Moves a task to a different workspace.',
  audience: 'both',
  aiMetadata: { description: 'Moves an existing Motion task to a different workspace. Use when an agent needs to relocate a known task between workspaces. Requires the task ID and the target workspace ID. Idempotent: moving a task to a workspace it already belongs to leaves it in the same state.', idempotent: true },
  props: {
    workspaceId:workspaceId('Current Workspace'),
    taskId:taskId,
    newWorkspaceId: workspaceId('Target Workspace')
  },
  async run({ auth, propsValue }) {
    const { taskId, newWorkspaceId } = propsValue;
    
    const response = await httpClient.sendRequest({
      method: HttpMethod.PATCH,
      url:`${BASE_URL}/tasks/${taskId}/move`,
      headers: {
        'Content-Type': 'application/json',
        'X-API-Key': auth.secret_text,
      },
      body: {
        workspaceId:newWorkspaceId
      }
    });

    return response.body;
  },
});