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 { frontAuth } from '../common/auth';
import { makeMultipartRequest, makeRequest } from '../common/client';
import { frontAttachments } from '../common/attachments';
import { HttpMethod } from '@activepieces/pieces-common';
import { channelIdDropdown, tagIdsDropdown } from '../common/dropdown';
export const sendMessage = createAction({
auth: frontAuth,
name: 'sendMessage',
displayName: 'Send Message',
description:
'Send a new message (starts a conversation) with subject, recipients, body, attachments, tags, etc.',
audience: 'both',
aiMetadata: {
description:
'Send an outbound message through a Front channel, creating a brand-new conversation. Pick this to initiate first contact with recipients (by handle) rather than answering an existing thread; use "Send Reply" to respond within an existing conversation. Not idempotent: each call sends a new message and starts a new conversation.',
idempotent: false,
},
props: {
channel_id: channelIdDropdown,
to: Property.Array({
displayName: 'To',
description: 'List of recipient handles (email addresses, etc.).',
required: true,
}),
cc: Property.Array({
displayName: 'CC',
description: 'List of CC recipient handles.',
required: false,
}),
bcc: Property.Array({
displayName: 'BCC',
description: 'List of BCC recipient handles.',
required: false,
}),
subject: Property.ShortText({
displayName: 'Subject',
description: 'The subject of the message.',
required: false,
}),
body: Property.LongText({
displayName: 'Body',
description: 'The body of the message.',
required: true,
}),
attachments: frontAttachments.property,
tag_ids: tagIdsDropdown,
},
async run({ auth, propsValue }) {
const { channel_id, to, cc, bcc, subject, body, attachments, tag_ids } =
propsValue;
const requestBody: Record<string, unknown> = {
channel_id,
to,
body,
};
if (cc) requestBody['cc'] = cc;
if (bcc) requestBody['bcc'] = bcc;
if (subject) requestBody['subject'] = subject;
if (tag_ids) requestBody['tag_ids'] = tag_ids;
const files = frontAttachments.resolve(attachments);
if (files.length > 0) {
return await makeMultipartRequest({
auth,
method: HttpMethod.POST,
path: `/channels/${channel_id}/messages`,
form: frontAttachments.buildBody({ fields: requestBody, files }),
});
}
return await makeRequest(
auth,
HttpMethod.POST,
`/channels/${channel_id}/messages`,
requestBody
);
},
});