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 { folkAuth } from '../common/auth';
import { folkClient } from '../common/client';
import { folkProps } from '../common/props';
export const updatePerson = createAction({
auth: folkAuth,
name: 'updatePerson',
classification: 'WRITE',
displayName: 'Update Person',
description:
'Update an existing person in your Folk workspace with new information.',
audience: 'both',
aiMetadata: {
description: 'Updates fields on an existing Folk person identified by their person ID; only the fields you supply are changed, and supplied company names that do not yet exist are created. Use when you already know the target person ID (look it up first with List People or Get Person). Not idempotent in general: re-running mutates the record each call and supplied arrays replace prior values, so resubmitting the same input is not guaranteed to be a no-op.',
idempotent: false,
},
props: {
personId: folkProps.person_id(true),
firstName: Property.ShortText({
displayName: 'First Name',
description: 'The first name of the person',
required: false,
}),
lastName: Property.ShortText({
displayName: 'Last Name',
description: 'The last name of the person',
required: false,
}),
fullName: Property.ShortText({
displayName: 'Full Name',
description: 'The full name of the person (alternative to first/last)',
required: false,
}),
description: Property.LongText({
displayName: 'Description',
description: 'A short description of the person',
required: false,
}),
birthday: Property.ShortText({
displayName: 'Birthday',
description: 'The birthday in YYYY-MM-DD format',
required: false,
}),
jobTitle: Property.ShortText({
displayName: 'Job Title',
description: 'The job title of the person',
required: false,
}),
companyIds: folkProps.companyIds(false),
companyNames: Property.Array({
displayName: 'Company Names',
description:
"Company names to create or associate with. Companies will be created if they don't exist.",
required: false,
properties: {
value: Property.ShortText({
displayName: 'Company Name',
required: true,
}),
},
}),
addresses: Property.Array({
displayName: 'Addresses',
description:
'Physical addresses for the person. The first address is primary.',
required: false,
properties: {
value: Property.ShortText({
displayName: 'Address',
required: true,
}),
},
}),
emails: Property.Array({
displayName: 'Emails',
description:
'Email addresses for the person. The first email is primary.',
required: false,
properties: {
value: Property.ShortText({
displayName: 'Email',
required: true,
}),
},
}),
phones: Property.Array({
displayName: 'Phone Numbers',
description: 'Phone numbers for the person. The first phone is primary.',
required: false,
properties: {
value: Property.ShortText({
displayName: 'Phone Number',
required: true,
}),
},
}),
urls: Property.Array({
displayName: 'URLs',
description: 'Website URLs for the person. The first URL is primary.',
required: false,
properties: {
value: Property.ShortText({
displayName: 'URL',
required: true,
}),
},
}),
groupId: folkProps.group_id(false, 'Group ID'),
},
async run(context) {
const {
personId,
firstName,
lastName,
fullName,
description,
birthday,
jobTitle,
companyIds,
companyNames,
addresses,
emails,
phones,
urls,
groupId,
} = context.propsValue;
const personData: any = {};
if (firstName) personData.firstName = firstName;
if (lastName) personData.lastName = lastName;
if (fullName) personData.fullName = fullName;
if (description) personData.description = description;
if (birthday) personData.birthday = birthday;
if (jobTitle) personData.jobTitle = jobTitle;
const companies: any[] = [];
if (companyIds) {
for (const companyId of companyIds) {
companies.push({ id: companyId });
}
}
if (companyNames && Array.isArray(companyNames)) {
companies.push(...companyNames.map((c: any) => ({ name: c.value || c })));
}
if (companies.length > 0) personData.companies = companies;
if (addresses && Array.isArray(addresses) && addresses.length > 0) {
personData.addresses = addresses.map((addr: any) => addr.value || addr);
}
if (emails && Array.isArray(emails) && emails.length > 0) {
personData.emails = emails.map((e: any) => e.value || e);
}
if (phones && Array.isArray(phones) && phones.length > 0) {
personData.phones = phones.map((p: any) => p.value || p);
}
if (urls && Array.isArray(urls) && urls.length > 0) {
personData.urls = urls.map((u: any) => u.value || u);
}
if (groupId) {
personData.groups = [{ id: groupId }];
}
const response = await folkClient.updatePerson({
apiKey: context.auth,
contactId: personId as string,
data: personData,
});
return {
data: response.data,
success: true,
};
},
});