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 { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { talkableAuth } from '../../..';
import { TALKABLE_API_URL } from '../../common/constants';
export const updatePerson = createAction({
name: 'update_person', // Must be a unique across the piece, this shouldn't be changed.
classification: 'WRITE',
auth: talkableAuth,
displayName: 'Update person',
description: 'Update person by email',
audience: 'both',
aiMetadata: { description: 'Update a Talkable person identified by email, setting profile fields such as name, phone, username, customer ID, custom properties, and opt-in/unsubscribe status. Use to keep an existing customer\'s details or subscription state current. Idempotent: it overwrites the same fields to the same values on repeat; the email is required.', idempotent: true },
props: {
email: Property.ShortText({
displayName: 'Person email',
description: undefined,
required: true,
}),
first_name: Property.ShortText({
displayName: 'Person first name',
description: undefined,
required: false,
}),
last_name: Property.ShortText({
displayName: 'Person last name',
description: undefined,
required: false,
}),
phone_number: Property.ShortText({
displayName: 'Person phone number',
description: undefined,
required: false,
}),
username: Property.ShortText({
displayName: 'Person username',
description: undefined,
required: false,
}),
customer_id: Property.Number({
displayName: 'Customer ID',
description: undefined,
required: false,
}),
custom_properties: Property.Object({
displayName: 'Custom properties',
description: undefined,
required: false,
}),
gated_param_subscribed: Property.StaticDropdown({
displayName: 'Opt-in status',
description: 'Opt-in status true/false',
required: false,
options: {
options: [
{
label: 'true',
value: 'true',
},
{
label: 'false',
value: 'false',
},
],
},
}),
unsubscribed: Property.StaticDropdown({
displayName: 'Unsubscribe status',
description: 'Unsubscribe status true/false',
required: false,
options: {
options: [
{
label: 'true',
value: 'true',
},
{
label: 'false',
value: 'false',
},
],
},
}),
unsubscribed_at: Property.DateTime({
displayName: 'Unsubscribed date',
description: undefined,
required: false,
}),
},
async run(context) {
const { site, api_key } = context.auth.props;
const {
email,
first_name,
last_name,
phone_number,
username,
customer_id,
custom_properties,
gated_param_subscribed,
unsubscribed,
unsubscribed_at,
} = context.propsValue;
const personUpdateResponse = await httpClient
.sendRequest<string[]>({
method: HttpMethod.PUT,
url: `${TALKABLE_API_URL}/people/${email}`,
headers: {
Authorization: `Bearer ${api_key}`,
'Content-Type': 'application/json',
},
body: {
site_slug: site,
data: {
first_name,
last_name,
phone_number,
username,
customer_id,
custom_properties,
gated_param_subscribed,
unsubscribed,
unsubscribed_at,
},
},
});
return personUpdateResponse.body;
},
});