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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod, httpClient, AuthenticationType } from '@activepieces/pieces-common';
import { wrikeAuth } from '../common/auth';
import { wrikeCommon } from '../common/client';
export const uploadAttachment = createAction({
name: 'upload_attachment',
displayName: 'Upload Attachment',
description: 'Upload a file and attach it to a task or folder',
audience: 'both',
aiMetadata: { description: 'Upload a file and attach it to a Wrike task or folder, chosen via the entity type and entity ID, with an optional custom file name. Use when an agent needs to add a document or asset to an item. Each call uploads a new attachment, so it is not idempotent.', idempotent: false },
auth: wrikeAuth,
props: {
entityType: Property.StaticDropdown({
displayName: 'Entity Type',
description: 'Select whether to attach the file to a task or folder',
required: true,
options: {
options: [
{ label: 'Task', value: 'tasks' },
{ label: 'Folder', value: 'folders' },
],
},
}),
entityId: Property.ShortText({
displayName: 'Entity ID',
description: 'The ID of the task or folder to attach the file to',
required: true,
}),
file: Property.File({
displayName: 'File',
description: 'The file to upload and attach',
required: true,
}),
fileName: Property.ShortText({
displayName: 'File Name',
description: 'Optional custom name for the uploaded file',
required: false,
}),
},
async run(context) {
const props = context.propsValue as any;
const { entityType, entityId, file, fileName } = props;
const response = await httpClient.sendRequest({
method: HttpMethod.POST,
url: `${wrikeCommon.baseUrl}/${entityType}/${entityId}/attachments`,
body: file.data,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: context.auth.access_token,
},
headers: {
'Content-Type': 'application/octet-stream',
'X-Requested-With': 'XMLHttpRequest',
'X-File-Name': fileName || file.filename,
},
});
return response.body;
},
});