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, PiecePropValueSchema } from '@activepieces/pieces-framework';
import { teamworkAuth } from '../common/auth';
import { teamworkRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
export const createExpense = createAction({
name: 'create_expense',
classification: 'WRITE',
displayName: 'Create Expense',
description: 'Log new expense in a project with cost, description, date.',
audience: 'both',
aiMetadata: { description: 'Records an expense against a Teamwork project with a name, cost, and date (and optional description). Use to log a project cost for billing or tracking. Requires the project, name, cost, and date. Not idempotent — each call creates a new expense.', idempotent: false },
auth: teamworkAuth,
props: {
'project-id': Property.Dropdown({
auth: teamworkAuth,
displayName: 'Project',
description: 'The project to log the expense against.',
required: true,
refreshers: [],
options: async ({ auth }) => {
if (!auth) {
return {
disabled: true,
placeholder: 'Please authenticate first.',
options: [],
};
}
const res = await teamworkRequest(auth, {
method: HttpMethod.GET,
path: '/projects/api/v3/projects.json',
});
const options = res.data.projects.map((p: { id: string; name: string }) => ({
label: p.name,
value: p.id,
}));
return {
disabled: false,
options,
};
},
}),
name: Property.ShortText({
displayName: 'Name',
description: 'The name of the expense.',
required: true,
}),
cost: Property.Number({
displayName: 'Cost',
description: 'The cost of the expense.',
required: true,
}),
date: Property.DateTime({
displayName: 'Date',
description: 'The date of the expense.',
required: true,
}),
description: Property.LongText({
displayName: 'Description',
description: 'A description for the expense.',
required: false,
}),
},
async run({ auth, propsValue }) {
const date = new Date(propsValue.date).toISOString().slice(0, 10).replace(/-/g, '');
const body = {
expense: {
'project-id': propsValue['project-id'],
name: propsValue.name,
cost: String(propsValue.cost),
date: date,
description: propsValue.description,
},
};
return await teamworkRequest(auth, {
method: HttpMethod.POST,
path: `/expenses.json`,
body,
});
},
});