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 { mycaseAuth } from '../auth';
import { createMyCaseApi } from '../common/mycase-api';
export const createLocation = createAction({
auth: mycaseAuth,
name: 'create_location',
displayName: 'Create Location',
description: 'Creates a new location in MyCase',
audience: 'both',
aiMetadata: { description: 'Always inserts a new location with the given name and optional address fields. Not idempotent: calling twice with the same name creates two locations, so use Find or Create Location when you want to avoid duplicates.', idempotent: false },
props: {
name: Property.ShortText({
displayName: 'Location Name',
description: 'The name of the location',
required: true,
}),
address1: Property.ShortText({
displayName: 'Address Line 1',
description: 'Street address line 1',
required: false,
}),
address2: Property.ShortText({
displayName: 'Address Line 2',
description: 'Street address line 2',
required: false,
}),
city: Property.ShortText({
displayName: 'City',
description: 'City',
required: false,
}),
state: Property.ShortText({
displayName: 'State',
description: 'State',
required: false,
}),
zip_code: Property.ShortText({
displayName: 'ZIP Code',
description: 'ZIP/Postal code',
required: false,
}),
country: Property.ShortText({
displayName: 'Country',
description: 'Country',
required: false,
}),
},
async run(context) {
const api = createMyCaseApi(context.auth);
// Build the request body
const requestBody: any = {
name: context.propsValue.name,
};
// Add address if any address fields are provided
const hasAddress = context.propsValue.address1 || context.propsValue.city ||
context.propsValue.state || context.propsValue.zip_code ||
context.propsValue.country;
if (hasAddress) {
requestBody.address = {
address1: context.propsValue.address1 || '',
address2: context.propsValue.address2 || '',
city: context.propsValue.city || '',
state: context.propsValue.state || '',
zip_code: context.propsValue.zip_code || '',
country: context.propsValue.country || '',
};
}
try {
const response = await api.post('/locations', requestBody);
if (response.success) {
return {
success: true,
location: response.data,
message: `Location "${context.propsValue.name}" created successfully`,
};
} else {
return {
success: false,
error: response.error,
details: response.details,
};
}
} catch (error) {
return {
success: false,
error: 'Failed to create location',
details: error instanceof Error ? error.message : String(error),
};
}
},
});