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
feat(resend): manage broadcast details and content with AI (#15582)
Kishan Parmar59ee769f221b
diff --git a/bun.lock b/bun.lockindex d878d7a1d1a..c6f90fcc698 100644--- a/bun.lock+++ b/bun.lock@@ -7661,7 +7661,7 @@},"packages/pieces/community/resend": {"name": "@activepieces/piece-resend",- "version": "0.5.1",+ "version": "0.5.2","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/packages/pieces/community/resend/package.json b/packages/pieces/community/resend/package.jsonindex 45f05c3660b..cb8c78d8ed4 100644--- a/packages/pieces/community/resend/package.json+++ b/packages/pieces/community/resend/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-resend",- "version": "0.5.1",+ "version": "0.5.2","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/resend/src/index.ts b/packages/pieces/community/resend/src/index.tsindex 4093d19ad75..2a8291f2674 100644--- a/packages/pieces/community/resend/src/index.ts+++ b/packages/pieces/community/resend/src/index.ts@@ -28,6 +28,8 @@ import { listBroadcasts } from './lib/actions/list-broadcasts.action';import { createBroadcast } from './lib/actions/create-broadcast.action';import { sendBroadcast } from './lib/actions/send-broadcast.action';import { deleteBroadcast } from './lib/actions/delete-broadcast.action';+import { getBroadcast } from './lib/actions/get-broadcast.action';+import { updateBroadcast } from './lib/actions/update-broadcast.action';import { getContact } from './lib/actions/get-contact.action';import { addContactToSegment } from './lib/actions/add-contact-to-segment.action';import { removeContactFromSegment } from './lib/actions/remove-contact-from-segment.action';@@ -126,6 +128,8 @@ export const resend = createPiece({createBroadcast,sendBroadcast,deleteBroadcast,+ getBroadcast,+ updateBroadcast,getContact,addContactToSegment,removeContactFromSegment,diff --git a/packages/pieces/community/resend/src/lib/actions/get-broadcast.action.ts b/packages/pieces/community/resend/src/lib/actions/get-broadcast.action.tsnew file mode 100644index 00000000000..9992d6bdfb9--- /dev/null+++ b/packages/pieces/community/resend/src/lib/actions/get-broadcast.action.ts@@ -0,0 +1,23 @@+import { createAction } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { resendAuth } from '../..';+import { resendClient } from '../common/client';+import { resendProps } from '../common/props';+import { getBroadcastOutputSchema } from '../output-schemas';++export const getBroadcast = createAction({+ name: 'get_broadcast',+ classification: 'READ',+ auth: resendAuth,+ displayName: 'Get Broadcast',+ outputSchema: getBroadcastOutputSchema,+ description: 'Retrieve a single broadcast by its ID',+ audience: 'ai',+ aiMetadata: { description: 'Retrieves the full details of a single broadcast (subject, body, status, schedule) by its ID, including whether it has been sent. Use this to inspect a specific broadcast before editing or sending it; use List Broadcasts to find the ID. Read-only and idempotent.', idempotent: true },+ props: {+ broadcast_id: resendProps.broadcastId,+ },+ async run({ auth, propsValue }) {+ return await resendClient.sendRequest({ auth: auth.secret_text, method: HttpMethod.GET, path: `/broadcasts/${propsValue.broadcast_id}` });+ },+});diff --git a/packages/pieces/community/resend/src/lib/actions/update-broadcast.action.ts b/packages/pieces/community/resend/src/lib/actions/update-broadcast.action.tsnew file mode 100644index 00000000000..4a70d4bf005--- /dev/null+++ b/packages/pieces/community/resend/src/lib/actions/update-broadcast.action.ts@@ -0,0 +1,88 @@+import { createAction, Property } from '@activepieces/pieces-framework';+import { HttpMethod } from '@activepieces/pieces-common';+import { resendAuth } from '../..';+import { resendClient } from '../common/client';+import { resendProps } from '../common/props';+import { updateBroadcastOutputSchema } from '../output-schemas';++export const updateBroadcast = createAction({+ name: 'update_broadcast',+ classification: 'WRITE',+ auth: resendAuth,+ displayName: 'Update Broadcast',+ outputSchema: updateBroadcastOutputSchema,+ description: "Update an unsent broadcast's content or targeting",+ audience: 'ai',+ aiMetadata: { description: "Updates the sender, subject, reply-to, body, name, or audience/topic targeting of an existing broadcast that has not been sent yet, identified by broadcast ID. Only supplied fields change; anything left blank keeps its current value. Not usable once the broadcast has been sent. Idempotent — re-applying the same values leaves the broadcast unchanged.", idempotent: true },+ props: {+ broadcast_id: resendProps.broadcastId,+ segment_id: Property.ShortText({+ displayName: 'Segment ID',+ description: "Send to this segment instead of the broadcast's current audience. Obtain from List Segments.",+ required: false,+ }),+ topic_id: Property.ShortText({+ displayName: 'Topic ID',+ description: 'Scope the broadcast to contacts subscribed to this topic. Obtain from List Topics.',+ required: false,+ }),+ from: Property.ShortText({+ displayName: 'From',+ description: 'Sender address. Must be from a verified domain.',+ required: false,+ }),+ subject: Property.ShortText({ displayName: 'Subject', required: false }),+ reply_to: Property.ShortText({+ displayName: 'Reply To',+ description: 'Email address recipients will reply to.',+ required: false,+ }),+ name: Property.ShortText({+ displayName: 'Broadcast Name',+ description: 'Internal label for this broadcast. Not visible to recipients.',+ required: false,+ }),+ content_type: Property.StaticDropdown({+ displayName: 'Content Type',+ description: 'Leave blank to keep the existing body unchanged.',+ required: false,+ options: {+ options: [+ { label: 'HTML', value: 'html' },+ { label: 'Plain Text', value: 'text' },+ ],+ },+ }),+ content: Property.LongText({+ displayName: 'Content',+ description: 'New email body. Requires Content Type to be set.',+ required: false,+ }),+ },+ async run({ auth, propsValue }) {+ const body: Record<string, unknown> = {};+ if (propsValue.segment_id) body['segment_id'] = propsValue.segment_id;+ if (propsValue.topic_id) body['topic_id'] = propsValue.topic_id;+ if (propsValue.from) body['from'] = propsValue.from;+ if (propsValue.subject) body['subject'] = propsValue.subject;+ if (propsValue.reply_to) body['reply_to'] = propsValue.reply_to;+ if (propsValue.name) body['name'] = propsValue.name;+ if (propsValue.content && !propsValue.content_type) {+ throw new Error('Content Type is required when Content is provided.');+ }+ if (propsValue.content_type && !propsValue.content) {+ throw new Error('Content is required when Content Type is provided.');+ }+ if (propsValue.content_type === 'html') {+ body['html'] = propsValue.content;+ } else if (propsValue.content_type === 'text') {+ body['text'] = propsValue.content;+ }++ if (Object.keys(body).length === 0) {+ throw new Error('At least one field must be provided to update the broadcast.');+ }++ return await resendClient.sendRequest<{ object: string; id: string }>({ auth: auth.secret_text, method: HttpMethod.PATCH, path: `/broadcasts/${propsValue.broadcast_id}`, body: body });+ },+});diff --git a/packages/pieces/community/resend/src/lib/output-schemas.ts b/packages/pieces/community/resend/src/lib/output-schemas.tsindex e7254e7ec32..63b60184653 100644--- a/packages/pieces/community/resend/src/lib/output-schemas.ts+++ b/packages/pieces/community/resend/src/lib/output-schemas.ts@@ -211,6 +211,29 @@ export const listBroadcastsOutputSchema: OutputSchema = {],};+export const getBroadcastOutputSchema: OutputSchema = {+ fields: [+ { key: 'id', label: 'Broadcast ID' },+ { key: 'name', label: 'Name' },+ { key: 'segment_id', label: 'Segment ID' },+ { key: 'topic_id', label: 'Topic ID' },+ { key: 'from', label: 'From' },+ { key: 'subject', label: 'Subject' },+ { key: 'reply_to', label: 'Reply To' },+ { key: 'preview_text', label: 'Preview Text' },+ { key: 'html', label: 'HTML Body', format: 'html' },+ { key: 'text', label: 'Text Body' },+ { key: 'status', label: 'Status' },+ { key: 'created_at', label: 'Created At', format: 'datetime' },+ { key: 'scheduled_at', label: 'Scheduled At', format: 'datetime' },+ { key: 'sent_at', label: 'Sent At', format: 'datetime' },+ ],+};++export const updateBroadcastOutputSchema: OutputSchema = {+ fields: [{ key: 'id', label: 'Broadcast ID' }],+};+export const getContactOutputSchema: OutputSchema = {fields: [{ key: 'id', label: 'Contact ID' },