Skip to content

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

feat(sender): add AI actions and output schemas (#16674)

Kishan Parmar8ee9d9677b91
diff --git a/bun.lock b/bun.lock
index b171b787852..b135b3e7beb 100644
--- a/bun.lock
+++ b/bun.lock
@@ -8226,7 +8226,7 @@
},
"packages/pieces/community/sender": {
"name": "@activepieces/piece-sender",
- "version": "0.1.7",
+ "version": "0.2.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/sender/package.json b/packages/pieces/community/sender/package.json
index 92ba41f89bf..94e892ec978 100644
--- a/packages/pieces/community/sender/package.json
+++ b/packages/pieces/community/sender/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-sender",
- "version": "0.1.7",
+ "version": "0.2.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/sender/src/i18n/translation.json b/packages/pieces/community/sender/src/i18n/translation.json
index fda67963fc1..9e1159845db 100644
--- a/packages/pieces/community/sender/src/i18n/translation.json
+++ b/packages/pieces/community/sender/src/i18n/translation.json
@@ -1,5 +1,13 @@
{
- "Enter your Sender API Token": "Enter your Sender API Token",
+ "12": "12",
+ "24": "24",
+ "48": "48",
+ "72": "72",
+ "96": "96",
+ "120": "120",
+ "144": "144",
+ "168": "168",
+ "To get your API token:\n1. Sign in to [Sender](https://app.sender.net) and open the [API access tokens](https://app.sender.net/settings/tokens) settings.\n2. Create a new API token.\n3. Copy the token and paste it here. It gives full access to your account, so keep it private.": "To get your API token:\n1. Sign in to [Sender](https://app.sender.net) and open the [API access tokens](https://app.sender.net/settings/tokens) settings.\n2. Create a new API token.\n3. Copy the token and paste it here. It gives full access to your account, so keep it private.",
"Add / Update Subscriber": "Add / Update Subscriber",
"Create Campaign": "Create Campaign",
"Unsubscribe Subscriber": "Unsubscribe Subscriber",
@@ -7,6 +15,57 @@
"Remove Subscriber from Group": "Remove Subscriber from Group",
"Send Campaign": "Send Campaign",
"Update Subscriber": "Update Subscriber",
+ "List Subscribers": "List Subscribers",
+ "Get Subscriber": "Get Subscriber",
+ "Create or Update Subscriber": "Create or Update Subscriber",
+ "Delete Subscribers": "Delete Subscribers",
+ "List Subscriber Events": "List Subscriber Events",
+ "Add Subscribers to Group": "Add Subscribers to Group",
+ "Remove Subscribers from Group": "Remove Subscribers from Group",
+ "Create Custom Event": "Create Custom Event",
+ "List Groups": "List Groups",
+ "Get Group": "Get Group",
+ "Create Group": "Create Group",
+ "Rename Group": "Rename Group",
+ "Delete Group": "Delete Group",
+ "List Group Subscribers": "List Group Subscribers",
+ "List Fields": "List Fields",
+ "Create Field": "Create Field",
+ "Update Field": "Update Field",
+ "Delete Field": "Delete Field",
+ "List Segments": "List Segments",
+ "Get Segment": "Get Segment",
+ "List Segment Subscribers": "List Segment Subscribers",
+ "List Campaigns": "List Campaigns",
+ "Get Campaign": "Get Campaign",
+ "Delete Campaigns": "Delete Campaigns",
+ "Copy Campaign": "Copy Campaign",
+ "Cancel Scheduled Campaign": "Cancel Scheduled Campaign",
+ "Cancel Campaign Follow-up": "Cancel Campaign Follow-up",
+ "List Campaign Errors": "List Campaign Errors",
+ "List Campaign Opens": "List Campaign Opens",
+ "List Campaign Clicks": "List Campaign Clicks",
+ "List Campaign Unsubscribes": "List Campaign Unsubscribes",
+ "List Campaign Hard Bounces": "List Campaign Hard Bounces",
+ "List Campaign Soft Bounces": "List Campaign Soft Bounces",
+ "List Campaign Complaints": "List Campaign Complaints",
+ "List Campaign Sent Emails": "List Campaign Sent Emails",
+ "List Transactional Campaigns": "List Transactional Campaigns",
+ "Get Transactional Campaign": "Get Transactional Campaign",
+ "Create Transactional Campaign": "Create Transactional Campaign",
+ "Update Transactional Campaign": "Update Transactional Campaign",
+ "Delete Transactional Campaigns": "Delete Transactional Campaigns",
+ "Get Transactional Campaign Report": "Get Transactional Campaign Report",
+ "List Transactional Sent Emails": "List Transactional Sent Emails",
+ "List Transactional Opens": "List Transactional Opens",
+ "List Transactional Clicks": "List Transactional Clicks",
+ "List Transactional Bounces": "List Transactional Bounces",
+ "List Transactional Complaints": "List Transactional Complaints",
+ "List Workflows": "List Workflows",
+ "Get Workflow": "Get Workflow",
+ "List Workflow Steps": "List Workflow Steps",
+ "Get Workflow Statistics": "Get Workflow Statistics",
+ "Custom API Call": "Custom API Call",
"Add a new subscriber or update existing subscriber's data": "Add a new subscriber or update existing subscriber's data",
"Creates a draft campaign in Sender": "Creates a draft campaign in Sender",
"Mark an email address as unsubscribed globally or from a group": "Mark an email address as unsubscribed globally or from a group",
@@ -14,6 +73,59 @@
"Remove a subscriber from a specific group": "Remove a subscriber from a specific group",
"Trigger sending of a drafted campaign to its recipient list": "Trigger sending of a drafted campaign to its recipient list",
"Update an existing subscriber's data": "Update an existing subscriber's data",
+ "Lists one page of subscribers in your Sender account.": "Lists one page of subscribers in your Sender account.",
+ "Gets a subscriber by email, phone or ID.": "Gets a subscriber by email, phone or ID.",
+ "Adds a subscriber, or updates the one with the same email.": "Adds a subscriber, or updates the one with the same email.",
+ "Updates a subscriber's details, groups or statuses.": "Updates a subscriber's details, groups or statuses.",
+ "Deletes one or more subscribers.": "Deletes one or more subscribers.",
+ "Lists a subscriber's campaign activity.": "Lists a subscriber's campaign activity.",
+ "Adds subscribers to a group.": "Adds subscribers to a group.",
+ "Removes subscribers from a group.": "Removes subscribers from a group.",
+ "Records a custom event for a subscriber.": "Records a custom event for a subscriber.",
+ "Lists one page of subscriber groups.": "Lists one page of subscriber groups.",
+ "Gets a group by ID.": "Gets a group by ID.",
+ "Creates a subscriber group.": "Creates a subscriber group.",
+ "Renames a group.": "Renames a group.",
+ "Deletes a group.": "Deletes a group.",
+ "Lists one page of the subscribers in a group.": "Lists one page of the subscribers in a group.",
+ "Lists the custom subscriber fields.": "Lists the custom subscriber fields.",
+ "Creates a custom subscriber field.": "Creates a custom subscriber field.",
+ "Renames a custom field or shows or hides it.": "Renames a custom field or shows or hides it.",
+ "Deletes a custom field.": "Deletes a custom field.",
+ "Lists one page of segments.": "Lists one page of segments.",
+ "Gets a segment by ID.": "Gets a segment by ID.",
+ "Lists one page of the subscribers in a segment.": "Lists one page of the subscribers in a segment.",
+ "Lists one page of email campaigns.": "Lists one page of email campaigns.",
+ "Gets an email campaign by ID.": "Gets an email campaign by ID.",
+ "Creates a draft email campaign.": "Creates a draft email campaign.",
+ "Deletes one or more email campaigns.": "Deletes one or more email campaigns.",
+ "Copies an email campaign.": "Copies an email campaign.",
+ "Cancels a scheduled campaign.": "Cancels a scheduled campaign.",
+ "Cancels the automatic follow-up of a campaign.": "Cancels the automatic follow-up of a campaign.",
+ "Lists the errors that block a campaign from sending.": "Lists the errors that block a campaign from sending.",
+ "Lists one page of the subscribers who opened of a campaign.": "Lists one page of the subscribers who opened of a campaign.",
+ "Lists one page of the subscriber clicks of a campaign.": "Lists one page of the subscriber clicks of a campaign.",
+ "Lists one page of the subscribers who unsubscribed of a campaign.": "Lists one page of the subscribers who unsubscribed of a campaign.",
+ "Lists one page of the hard bounces of a campaign.": "Lists one page of the hard bounces of a campaign.",
+ "Lists one page of the soft bounces of a campaign.": "Lists one page of the soft bounces of a campaign.",
+ "Lists one page of the spam complaints of a campaign.": "Lists one page of the spam complaints of a campaign.",
+ "Lists one page of the recipients the campaign was sent to of a campaign.": "Lists one page of the recipients the campaign was sent to of a campaign.",
+ "Lists one page of transactional email templates.": "Lists one page of transactional email templates.",
+ "Gets a transactional campaign by ID.": "Gets a transactional campaign by ID.",
+ "Creates a transactional email template.": "Creates a transactional email template.",
+ "Updates a transactional email template.": "Updates a transactional email template.",
+ "Deletes one or more transactional campaigns.": "Deletes one or more transactional campaigns.",
+ "Gets sent, open, click and bounce totals for a transactional campaign.": "Gets sent, open, click and bounce totals for a transactional campaign.",
+ "Lists one page of the emails sent of a transactional campaign.": "Lists one page of the emails sent of a transactional campaign.",
+ "Lists one page of the opens of a transactional campaign.": "Lists one page of the opens of a transactional campaign.",
+ "Lists one page of the clicks of a transactional campaign.": "Lists one page of the clicks of a transactional campaign.",
+ "Lists one page of the bounces of a transactional campaign.": "Lists one page of the bounces of a transactional campaign.",
+ "Lists one page of the spam complaints of a transactional campaign.": "Lists one page of the spam complaints of a transactional campaign.",
+ "Lists one page of automation workflows.": "Lists one page of automation workflows.",
+ "Gets an automation workflow by ID.": "Gets an automation workflow by ID.",
+ "Lists the steps of an automation workflow.": "Lists the steps of an automation workflow.",
+ "Gets a workflow's email performance.": "Gets a workflow's email performance.",
+ "Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Email": "Email",
"First Name": "First Name",
"Last Name": "Last Name",
@@ -29,6 +141,56 @@
"Subscriber": "Subscriber",
"Subscribers": "Subscribers",
"Campaign": "Campaign",
+ "Page": "Page",
+ "Group IDs": "Group IDs",
+ "Email Status": "Email Status",
+ "SMS Status": "SMS Status",
+ "Transactional Email Status": "Transactional Email Status",
+ "Subscriber Emails": "Subscriber Emails",
+ "Event Types": "Event Types",
+ "Group ID": "Group ID",
+ "Subscriber Email": "Subscriber Email",
+ "Subscriber Phone": "Subscriber Phone",
+ "Subscriber ID": "Subscriber ID",
+ "Event Type": "Event Type",
+ "Value": "Value",
+ "Currency": "Currency",
+ "Properties": "Properties",
+ "Limit": "Limit",
+ "Title": "Title",
+ "Type": "Type",
+ "Field ID": "Field ID",
+ "Show in Dashboard": "Show in Dashboard",
+ "Segment ID": "Segment ID",
+ "Status": "Status",
+ "Campaign ID": "Campaign ID",
+ "Subject": "Subject",
+ "Content": "Content",
+ "Preheader": "Preheader",
+ "Segment IDs": "Segment IDs",
+ "Google Analytics": "Google Analytics",
+ "Auto Follow-up": "Auto Follow-up",
+ "Follow-up Subject": "Follow-up Subject",
+ "Follow-up Delay (hours)": "Follow-up Delay (hours)",
+ "Campaign IDs": "Campaign IDs",
+ "Transactional Campaign ID": "Transactional Campaign ID",
+ "Editor": "Editor",
+ "Transactional Campaign IDs": "Transactional Campaign IDs",
+ "From Date": "From Date",
+ "To Date": "To Date",
+ "Period": "Period",
+ "Sort Direction": "Sort Direction",
+ "Workflow ID": "Workflow ID",
+ "Batch Number": "Batch Number",
+ "Method": "Method",
+ "Headers": "Headers",
+ "Query Parameters": "Query Parameters",
+ "Body Type": "Body Type",
+ "Body": "Body",
+ "Response is Binary": "Response is Binary",
+ "Return Error as Output": "Return Error as Output",
+ "Timeout": "Timeout",
+ "Follow redirects": "Follow redirects",
"Subscriber email address": "Subscriber email address",
"Subscriber first name": "Subscriber first name",
"Subscriber last name": "Subscriber last name",
@@ -49,6 +211,104 @@
"New last name": "New last name",
"New phone number": "New phone number",
"JSON object with custom field keys and values to update": "JSON object with custom field keys and values to update",
+ "Page number to return, starting at 1. Defaults to 1. Use the returned `meta.last_page` or `links.next` to know if more pages exist.": "Page number to return, starting at 1. Defaults to 1. Use the returned `meta.last_page` or `links.next` to know if more pages exist.",
+ "The subscriber's email address, phone number (with country code) or Sender subscriber ID. Use List Subscribers to find it.": "The subscriber's email address, phone number (with country code) or Sender subscriber ID. Use List Subscribers to find it.",
+ "Subscriber email address.": "Subscriber email address.",
+ "Phone number with country code, e.g. \"+37061234567\".": "Phone number with country code, e.g. \"+37061234567\".",
+ "List of Sender group IDs, e.g. [\"eZVD4w\"]. Use List Groups to find them.": "List of Sender group IDs, e.g. [\"eZVD4w\"]. Use List Groups to find them.",
+ "Object of custom field values keyed as {$<name>} with the field name from List Fields (without its braces), e.g. {\"{$company}\": \"Acme\"}. Unknown keys are skipped with a warning in message.warnings.": "Object of custom field values keyed as {$<name>} with the field name from List Fields (without its braces), e.g. {\"{$company}\": \"Acme\"}. Unknown keys are skipped with a warning in message.warnings.",
+ "Whether this change starts matching automation workflows. Sender defaults to Yes when empty.": "Whether this change starts matching automation workflows. Sender defaults to Yes when empty.",
+ "Email campaign status.": "Email campaign status.",
+ "SMS campaign status.": "SMS campaign status.",
+ "Transactional email status.": "Transactional email status.",
+ "Email addresses of the subscribers to delete, e.g. [\"[email protected]\"].": "Email addresses of the subscribers to delete, e.g. [\"[email protected]\"].",
+ "Which kinds of activity to return.": "Which kinds of activity to return.",
+ "Sender group ID, e.g. \"eZVD4w\". Use List Groups to find it.": "Sender group ID, e.g. \"eZVD4w\". Use List Groups to find it.",
+ "List of subscriber email addresses, e.g. [\"[email protected]\"].": "List of subscriber email addresses, e.g. [\"[email protected]\"].",
+ "Phone number with country code.": "Phone number with country code.",
+ "Sender subscriber ID, from Get Subscriber.": "Sender subscriber ID, from Get Subscriber.",
+ "Event name, e.g. \"product_viewed\".": "Event name, e.g. \"product_viewed\".",
+ "Optional numeric value, e.g. an order total.": "Optional numeric value, e.g. an order total.",
+ "ISO 4217 code for Value, e.g. \"USD\".": "ISO 4217 code for Value, e.g. \"USD\".",
+ "Flat object of extra event properties (strings, numbers, dates or booleans; 8KB total).": "Flat object of extra event properties (strings, numbers, dates or booleans; 8KB total).",
+ "How many records to return per page. Sender applies its own default when empty.": "How many records to return per page. Sender applies its own default when empty.",
+ "Name of the new group.": "Name of the new group.",
+ "New name for the group.": "New name for the group.",
+ "Also delete the subscribers in this group. Defaults to No.": "Also delete the subscribers in this group. Defaults to No.",
+ "Name of the new field.": "Name of the new field.",
+ "Value type of the field.": "Value type of the field.",
+ "Sender custom field ID. Use List Fields to find it.": "Sender custom field ID. Use List Fields to find it.",
+ "New field name.": "New field name.",
+ "Show the field as a filter in the subscribers dashboard.": "Show the field as a filter in the subscribers dashboard.",
+ "Sender segment ID. Use List Segments to find it.": "Sender segment ID. Use List Segments to find it.",
+ "Only return campaigns with this status.": "Only return campaigns with this status.",
+ "Sender campaign ID, e.g. \"eE0x14\". Use List Campaigns to find it.": "Sender campaign ID, e.g. \"eE0x14\". Use List Campaigns to find it.",
+ "Internal name shown in reports.": "Internal name shown in reports.",
+ "Sender name shown to subscribers.": "Sender name shown to subscribers.",
+ "Sender email address, on a verified domain in the account.": "Sender email address, on a verified domain in the account.",
+ "html or text to pass Content here; editor creates a drag-and-drop draft to finish in Sender.": "html or text to pass Content here; editor creates a drag-and-drop draft to finish in Sender.",
+ "Email body as HTML or plain text, matching Content Type.": "Email body as HTML or plain text, matching Content Type.",
+ "Preview text shown after the subject in inboxes.": "Preview text shown after the subject in inboxes.",
+ "Group IDs to send to, e.g. [\"eZVD4w\"]. Use List Groups.": "Group IDs to send to, e.g. [\"eZVD4w\"]. Use List Groups.",
+ "Segment IDs to send to. Use List Segments.": "Segment IDs to send to. Use List Segments.",
+ "Add Google Analytics tracking to links.": "Add Google Analytics tracking to links.",
+ "Resend automatically to subscribers who did not open.": "Resend automatically to subscribers who did not open.",
+ "Hours to wait before the follow-up.": "Hours to wait before the follow-up.",
+ "IDs of the campaigns to delete. Use List Campaigns.": "IDs of the campaigns to delete. Use List Campaigns.",
+ "Sender transactional campaign ID. Use List Transactional Campaigns to find it.": "Sender transactional campaign ID. Use List Transactional Campaigns to find it.",
+ "Sender name shown to recipients.": "Sender name shown to recipients.",
+ "html or plain to pass Content; builder creates a drag-and-drop template to finish in Sender.": "html or plain to pass Content; builder creates a drag-and-drop template to finish in Sender.",
+ "Email body as HTML or plain text, matching Editor.": "Email body as HTML or plain text, matching Editor.",
+ "IDs of the transactional campaigns to delete. Use List Transactional Campaigns.": "IDs of the transactional campaigns to delete. Use List Transactional Campaigns.",
+ "Start date, YYYY-MM-DD.": "Start date, YYYY-MM-DD.",
+ "End date, YYYY-MM-DD.": "End date, YYYY-MM-DD.",
+ "How to group the totals.": "How to group the totals.",
+ "Sort by date, newest first (desc) or oldest first (asc).": "Sort by date, newest first (desc) or oldest first (asc).",
+ "Workflows per page, 1 to 100. Defaults to 10.": "Workflows per page, 1 to 100. Defaults to 10.",
+ "Only return workflows with this status.": "Only return workflows with this status.",
+ "Only return the workflow with exactly this title, e.g. \"Welcome (Ecommerce)\".": "Only return the workflow with exactly this title, e.g. \"Welcome (Ecommerce)\".",
+ "Sender workflow ID. Use List Workflows to find it.": "Sender workflow ID. Use List Workflows to find it.",
+ "Zero-based batch to return. Defaults to 0.": "Zero-based batch to return. Defaults to 0.",
+ "Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
+ "Appended to the URL as ?key=value.": "Appended to the URL as ?key=value.",
+ "Enable for files like PDFs, images, etc.": "Enable for files like PDFs, images, etc.",
+ "On a failed request, output the error instead of failing the step.": "On a failed request, output the error instead of failing the step.",
+ "Seconds to wait for a response. Empty: up to the flow limit (10 min).": "Seconds to wait for a response. Empty: up to the flow limit (10 min).",
+ "Follow 3xx redirects instead of returning them as the response.": "Follow 3xx redirects instead of returning them as the response.",
+ "Yes": "Yes",
+ "No": "No",
+ "Active": "Active",
+ "Unsubscribed": "Unsubscribed",
+ "Bounced": "Bounced",
+ "Spam reported": "Spam reported",
+ "Received": "Received",
+ "Opened": "Opened",
+ "Clicked": "Clicked",
+ "Text": "Text",
+ "Number": "Number",
+ "Date and time": "Date and time",
+ "Draft": "Draft",
+ "Scheduled": "Scheduled",
+ "Sending": "Sending",
+ "Sent": "Sent",
+ "HTML": "HTML",
+ "Plain text": "Plain text",
+ "Builder": "Builder",
+ "Day": "Day",
+ "Week": "Week",
+ "Month": "Month",
+ "Year": "Year",
+ "Newest first": "Newest first",
+ "Oldest first": "Oldest first",
+ "Paused": "Paused",
+ "GET": "GET",
+ "POST": "POST",
+ "PATCH": "PATCH",
+ "PUT": "PUT",
+ "DELETE": "DELETE",
+ "HEAD": "HEAD",
+ "Request": "Request",
+ "Data to send": "Data to send",
"New Campaign": "New Campaign",
"New Group": "New Group",
"New Subscriber": "New Subscriber",
@@ -63,6 +323,5 @@
"Fires when a subscriber's data (fields) is updated": "Fires when a subscriber's data (fields) is updated",
"Fires when someone unsubscribes globally": "Fires when someone unsubscribes globally",
"Fires when a subscriber is removed/unsubscribed from a specific group": "Fires when a subscriber is removed/unsubscribed from a specific group",
- "Group ID": "Group ID",
"The ID of the group to monitor": "The ID of the group to monitor"
}
\ No newline at end of file
diff --git a/packages/pieces/community/sender/src/index.ts b/packages/pieces/community/sender/src/index.ts
index fd37afb00ec..d2632117527 100644
--- a/packages/pieces/community/sender/src/index.ts
+++ b/packages/pieces/community/sender/src/index.ts
@@ -1,6 +1,8 @@
-import { createPiece} from '@activepieces/pieces-framework';
-import { PieceCategory } from '@activepieces/pieces-framework';
-import { senderAuth } from './lib/common/common';
+import { createCustomApiCallAction } from '@activepieces/pieces-common';
+import { createPiece, PieceCategory } from '@activepieces/pieces-framework';
+import { senderAuth } from './lib/auth';
+import { senderClient } from './lib/common/client';
+import { senderAiActions } from './lib/actions/ai';
import { addUpdateSubscriberAction } from './lib/actions/add-subscriber';
import { createCampaignAction } from './lib/actions/create-campaign';
import { unsubscribeSubscriberAction } from './lib/actions/unsubscribe-subscriber';
@@ -19,7 +21,7 @@ import { updateSubscriberAction } from './lib/actions/update-subscriber';
export const sender = createPiece({
displayName: 'Sender',
auth: senderAuth,
- minimumSupportedRelease: '0.30.0',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/sender.png',
authors: ['Ani-4x','sanket-a11y'],
categories: [PieceCategory.MARKETING],
@@ -30,7 +32,15 @@ export const sender = createPiece({
addSubscriberToGroupAction,
removeSubscriberFromGroupAction,
sendCampaignAction,
- updateSubscriberAction
+ updateSubscriberAction,
+ ...senderAiActions,
+ createCustomApiCallAction({
+ auth: senderAuth,
+ baseUrl: () => senderClient.baseUrl(),
+ authMapping: async (auth) => ({
+ Authorization: `Bearer ${auth.secret_text}`,
+ }),
+ }),
],
triggers: [
newCampaignTrigger,
diff --git a/packages/pieces/community/sender/src/lib/actions/add-subscriber-to-group.ts b/packages/pieces/community/sender/src/lib/actions/add-subscriber-to-group.ts
index d1b0a0810a8..b613e98df21 100644
--- a/packages/pieces/community/sender/src/lib/actions/add-subscriber-to-group.ts
+++ b/packages/pieces/community/sender/src/lib/actions/add-subscriber-to-group.ts
@@ -1,35 +1,27 @@
-import { createAction, Property } from '@activepieces/pieces-framework';
-import {
- groupIdsDropdown,
- makeSenderRequest,
- senderAuth,
- subscriberDropdownSingle,
-} from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
+import { senderSubscriberWriteOutputSchema } from '../output-schemas';
export const addSubscriberToGroupAction = createAction({
auth: senderAuth,
name: 'add_subscriber_to_group',
+ outputSchema: senderSubscriberWriteOutputSchema,
classification: 'WRITE',
displayName: 'Add Subscriber to Group',
description: 'Add an existing or new subscriber into one or more groups',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Assigns a single subscriber to one or more groups/lists in a Sender account, identified by their subscriber ID. Use to segment a contact for targeted campaigns. Idempotent: adding a contact already in a group leaves membership unchanged.', idempotent: true },
props: {
- subscriber: subscriberDropdownSingle,
- groups: groupIdsDropdown,
+ subscriber: senderProps.subscriber({ required: true }),
+ groups: senderProps.groupIds({ required: false }),
},
async run(context) {
- const subscriberData: any = {
+ return await senderApi.updateSubscriber({
+ auth: context.auth,
+ subscriberId: context.propsValue.subscriber,
groups: context.propsValue.groups,
- };
- const response = await makeSenderRequest(
- context.auth.secret_text,
- `/subscribers/${context.propsValue.subscriber}`,
- HttpMethod.PATCH,
- subscriberData
- );
-
- return response.body;
+ });
},
});
diff --git a/packages/pieces/community/sender/src/lib/actions/add-subscriber.ts b/packages/pieces/community/sender/src/lib/actions/add-subscriber.ts
index d4b25f0d458..04e42751409 100644
--- a/packages/pieces/community/sender/src/lib/actions/add-subscriber.ts
+++ b/packages/pieces/community/sender/src/lib/actions/add-subscriber.ts
@@ -1,16 +1,17 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { groupIdsDropdown, makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
-import { group } from 'console';
-
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
+import { senderSubscriberWriteOutputSchema } from '../output-schemas';
export const addUpdateSubscriberAction = createAction({
auth: senderAuth,
name: 'add_update_subscriber',
+ outputSchema: senderSubscriberWriteOutputSchema,
classification: 'WRITE',
displayName: 'Add / Update Subscriber',
description: 'Add a new subscriber or update existing subscriber\'s data',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Upserts a subscriber in a Sender account by email: creates the contact if the email is new, otherwise updates its name, phone, group membership, and custom fields. Use to ensure a contact exists with given details before campaigns or grouping. Keyed on email, so repeating the same call is idempotent (no duplicate contact); note the optional flag that triggers automation workflows on the subscriber.', idempotent: true },
props: {
email: Property.ShortText({
@@ -33,7 +34,7 @@ export const addUpdateSubscriberAction = createAction({
description: 'Subscriber phone number',
required: false,
}),
- groups: groupIdsDropdown,
+ groups: senderProps.groupIds({ required: false }),
customFields: Property.Json({
displayName: 'Custom Fields',
description: 'JSON object with custom field keys and values',
@@ -47,36 +48,15 @@ export const addUpdateSubscriberAction = createAction({
}),
},
async run(context) {
- const subscriberData: any = {
+ return await senderApi.upsertSubscriber({
+ auth: context.auth,
email: context.propsValue.email,
- };
-
- if (context.propsValue.firstname) {
- subscriberData.firstname = context.propsValue.firstname;
- }
- if (context.propsValue.lastname) {
- subscriberData.lastname = context.propsValue.lastname;
- }
- if (context.propsValue.phone) {
- subscriberData.phone = context.propsValue.phone;
- }
- if (context.propsValue.groups) {
- subscriberData.groups = context.propsValue.groups;
- }
- if (context.propsValue.customFields) {
- subscriberData.fields = context.propsValue.customFields;
- }
- if (context.propsValue.triggerAutomation) {
- subscriberData.trigger_automation = true;
- }
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/subscribers',
- HttpMethod.POST,
- subscriberData
- );
-
- return response.body;
+ firstname: context.propsValue.firstname,
+ lastname: context.propsValue.lastname,
+ phone: context.propsValue.phone,
+ groups: context.propsValue.groups,
+ customFields: context.propsValue.customFields,
+ triggerAutomation: context.propsValue.triggerAutomation ? true : undefined,
+ });
},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/add-subscribers-to-group.ts b/packages/pieces/community/sender/src/lib/actions/ai/add-subscribers-to-group.ts
new file mode 100644
index 00000000000..cb3bf28b7fe
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/add-subscribers-to-group.ts
@@ -0,0 +1,39 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderAddSubscribersToGroupOutputSchema } from '../../output-schemas';
+
+export const senderAddSubscribersToGroupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_add_subscribers_to_group',
+ outputSchema: senderAddSubscribersToGroupOutputSchema,
+ displayName: 'Add Subscribers to Group',
+ description: 'Adds subscribers to a group.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds existing subscribers, by email, to one group without touching their other groups. The response lists emails that were added and emails that do not exist in the account; create those with Create or Update Subscriber first. Repeating it leaves membership unchanged.',
+ idempotent: true,
+ },
+ props: {
+ groupId: senderAiProps.groupId({ required: true }),
+ subscribers: senderAiProps.subscribers({ required: true }),
+ triggerAutomation: senderAiProps.triggerAutomation({ required: false }),
+ },
+ async run(context) {
+ const { groupId, subscribers, triggerAutomation } = context.propsValue;
+ return await senderApi.addSubscribersToGroup({
+ auth: context.auth,
+ groupId,
+ subscribers: senderUtils.requiredStringList({
+ value: subscribers,
+ propName: 'Subscriber Emails',
+ }),
+ triggerAutomation: senderUtils.yesNoToBoolean(triggerAutomation),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/cancel-campaign-followup.ts b/packages/pieces/community/sender/src/lib/actions/ai/cancel-campaign-followup.ts
new file mode 100644
index 00000000000..661dac0abfa
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/cancel-campaign-followup.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderCancelCampaignFollowupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_cancel_campaign_followup',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Cancel Campaign Follow-up',
+ description: 'Cancels the automatic follow-up of a campaign.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Cancels the automatic follow-up email (resent to subscribers who did not open) of a sent campaign that has auto follow-up turned on.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.cancelCampaignFollowup({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/cancel-scheduled-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/cancel-scheduled-campaign.ts
new file mode 100644
index 00000000000..467dd6c1922
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/cancel-scheduled-campaign.ts
@@ -0,0 +1,26 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderCancelScheduledCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_cancel_scheduled_campaign',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Cancel Scheduled Campaign',
+ description: 'Cancels a scheduled campaign.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description: 'Cancels the schedule of a campaign that has not sent yet, returning it to draft.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.cancelCampaignSchedule({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/copy-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/copy-campaign.ts
new file mode 100644
index 00000000000..c42c1c7fc65
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/copy-campaign.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderCampaignWriteOutputSchema } from '../../output-schemas';
+
+export const senderCopyCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_copy_campaign',
+ outputSchema: senderCampaignWriteOutputSchema,
+ displayName: 'Copy Campaign',
+ description: 'Copies an email campaign.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a new draft that copies an existing campaign, and returns the copy with its new ID. Each call makes another copy.',
+ idempotent: false,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.copyCampaign({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/create-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/create-campaign.ts
new file mode 100644
index 00000000000..05824688e11
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/create-campaign.ts
@@ -0,0 +1,126 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderCampaignWriteOutputSchema } from '../../output-schemas';
+
+const UNSUBSCRIBE_FOOTER = '<p><a href="{{unsubscribe_link}}">{{unsubscribe_text}}</a></p>';
+
+export const senderCreateCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_create_campaign',
+ outputSchema: senderCampaignWriteOutputSchema,
+ displayName: 'Create Campaign',
+ description: 'Creates a draft email campaign.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a draft email campaign for the given groups and/or segments, with subject, sender name, reply-to email and HTML or plain-text content. Nothing is sent: follow with Send Campaign. Reply To must be on a sending domain with SPF and DKIM set up in Sender. HTML content gets the unsubscribe link Sender requires appended automatically. Each call creates a separate draft.',
+ idempotent: false,
+ },
+ props: {
+ title: Property.ShortText({
+ displayName: 'Campaign Name',
+ description: 'Internal name shown in reports.',
+ required: false,
+ }),
+ subject: Property.ShortText({ displayName: 'Subject', required: true }),
+ from: Property.ShortText({
+ displayName: 'From Name',
+ description: 'Sender name shown to subscribers.',
+ required: true,
+ }),
+ replyTo: Property.ShortText({
+ displayName: 'Reply To',
+ description: 'Sender email address, on a verified domain in the account.',
+ required: true,
+ }),
+ contentType: Property.StaticDropdown({
+ displayName: 'Content Type',
+ description:
+ 'html or text to pass Content here; editor creates a drag-and-drop draft to finish in Sender.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'HTML', value: 'html' },
+ { label: 'Plain text', value: 'text' },
+ { label: 'Editor', value: 'editor' },
+ ],
+ },
+ }),
+ content: Property.LongText({
+ displayName: 'Content',
+ description: 'Email body as HTML or plain text, matching Content Type.',
+ required: false,
+ }),
+ preheader: Property.ShortText({
+ displayName: 'Preheader',
+ description: 'Preview text shown after the subject in inboxes.',
+ required: false,
+ }),
+ groups: senderAiProps.groups({
+ required: false,
+ description: 'Group IDs to send to, e.g. ["eZVD4w"]. Use List Groups.',
+ }),
+ segments: Property.Array({
+ displayName: 'Segment IDs',
+ description: 'Segment IDs to send to. Use List Segments.',
+ required: false,
+ }),
+ googleAnalytics: senderAiProps.yesNo({
+ required: false,
+ displayName: 'Google Analytics',
+ description: 'Add Google Analytics tracking to links.',
+ }),
+ autoFollowupActive: senderAiProps.yesNo({
+ required: false,
+ displayName: 'Auto Follow-up',
+ description: 'Resend automatically to subscribers who did not open.',
+ }),
+ autoFollowupSubject: Property.ShortText({ displayName: 'Follow-up Subject', required: false }),
+ autoFollowupDelay: Property.StaticDropdown<number>({
+ displayName: 'Follow-up Delay (hours)',
+ description: 'Hours to wait before the follow-up.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [12, 24, 48, 72, 96, 120, 144, 168].map((hours) => ({
+ label: String(hours),
+ value: hours,
+ })),
+ },
+ }),
+ },
+ async run(context) {
+ const {
+ googleAnalytics,
+ autoFollowupActive,
+ groups,
+ segments,
+ contentType,
+ content,
+ ...props
+ } = context.propsValue;
+ const analytics = senderUtils.yesNoToBoolean(googleAnalytics);
+ return await senderApi.createCampaign({
+ auth: context.auth,
+ ...props,
+ contentType,
+ content: contentType === 'html' && content ? withUnsubscribeLink({ html: content }) : content,
+ groups: senderUtils.optionalStringList({ value: groups, propName: 'Group IDs' }),
+ segments: senderUtils.optionalStringList({ value: segments, propName: 'Segment IDs' }),
+ googleAnalytics: analytics === undefined ? undefined : Number(analytics),
+ autoFollowupActive: senderUtils.yesNoToBoolean(autoFollowupActive),
+ });
+ },
+});
+
+function withUnsubscribeLink({ html }: { html: string }): string {
+ return html.includes('</body>')
+ ? html.replace('</body>', `${UNSUBSCRIBE_FOOTER}</body>`)
+ : `${html}${UNSUBSCRIBE_FOOTER}`;
+}
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/create-custom-event.ts b/packages/pieces/community/sender/src/lib/actions/ai/create-custom-event.ts
new file mode 100644
index 00000000000..a9489781b34
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/create-custom-event.ts
@@ -0,0 +1,76 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderApi } from '../../common/api';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderCreateCustomEventAction = createAction({
+ auth: senderAuth,
+ name: 'sender_create_custom_event',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Create Custom Event',
+ description: 'Records a custom event for a subscriber.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Records a custom event (e.g. "product_viewed", "order_placed") against a subscriber, identified by at least one of email, phone or subscriber ID, with an optional value and properties. Events can start automation workflows. Each call records a new event.',
+ idempotent: false,
+ },
+ props: {
+ subscriberEmail: Property.ShortText({ displayName: 'Subscriber Email', required: false }),
+ subscriberPhone: Property.ShortText({
+ displayName: 'Subscriber Phone',
+ description: 'Phone number with country code.',
+ required: false,
+ }),
+ subscriberId: Property.ShortText({
+ displayName: 'Subscriber ID',
+ description: 'Sender subscriber ID, from Get Subscriber.',
+ required: false,
+ }),
+ type: Property.ShortText({
+ displayName: 'Event Type',
+ description: 'Event name, e.g. "product_viewed".',
+ required: true,
+ }),
+ value: Property.Number({
+ displayName: 'Value',
+ description: 'Optional numeric value, e.g. an order total.',
+ required: false,
+ }),
+ valueCurrency: Property.ShortText({
+ displayName: 'Currency',
+ description: 'ISO 4217 code for Value, e.g. "USD".',
+ required: false,
+ }),
+ properties: Property.Json({
+ displayName: 'Properties',
+ description:
+ 'Flat object of extra event properties (strings, numbers, dates or booleans; 8KB total).',
+ required: false,
+ }),
+ },
+ async run(context) {
+ const {
+ subscriberEmail,
+ subscriberPhone,
+ subscriberId,
+ type,
+ value,
+ valueCurrency,
+ properties,
+ } = context.propsValue;
+ if (!subscriberEmail && !subscriberPhone && !subscriberId) {
+ throw new Error('Set at least one of Subscriber Email, Subscriber Phone or Subscriber ID.');
+ }
+ return await senderApi.createCustomEvent({
+ auth: context.auth,
+ subscriber: { id: subscriberId, email: subscriberEmail, phone: subscriberPhone },
+ type,
+ value,
+ valueCurrency,
+ properties,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/create-field.ts b/packages/pieces/community/sender/src/lib/actions/ai/create-field.ts
new file mode 100644
index 00000000000..b8de5a39bf3
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/create-field.ts
@@ -0,0 +1,43 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderApi } from '../../common/api';
+import { senderFieldWriteOutputSchema } from '../../output-schemas';
+
+export const senderCreateFieldAction = createAction({
+ auth: senderAuth,
+ name: 'sender_create_field',
+ outputSchema: senderFieldWriteOutputSchema,
+ displayName: 'Create Field',
+ description: 'Creates a custom subscriber field.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a custom subscriber field of type text, number or datetime and returns it with its ID and field_name. Each call creates a separate field.',
+ idempotent: false,
+ },
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Name of the new field.',
+ required: true,
+ }),
+ type: Property.StaticDropdown({
+ displayName: 'Type',
+ description: 'Value type of the field.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Text', value: 'text' },
+ { label: 'Number', value: 'number' },
+ { label: 'Date and time', value: 'datetime' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ return await senderApi.createField({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/create-group.ts b/packages/pieces/community/sender/src/lib/actions/ai/create-group.ts
new file mode 100644
index 00000000000..0d80338cf60
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/create-group.ts
@@ -0,0 +1,30 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderApi } from '../../common/api';
+import { senderGroupWriteOutputSchema } from '../../output-schemas';
+
+export const senderCreateGroupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_create_group',
+ outputSchema: senderGroupWriteOutputSchema,
+ displayName: 'Create Group',
+ description: 'Creates a subscriber group.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a new, empty subscriber group with the given title and returns it with its ID. Each call creates a separate group, even with the same title.',
+ idempotent: false,
+ },
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Name of the new group.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await senderApi.createGroup({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/create-or-update-subscriber.ts b/packages/pieces/community/sender/src/lib/actions/ai/create-or-update-subscriber.ts
new file mode 100644
index 00000000000..5467735c437
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/create-or-update-subscriber.ts
@@ -0,0 +1,58 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderSubscriberUpsertOutputSchema } from '../../output-schemas';
+
+export const senderCreateOrUpdateSubscriberAction = createAction({
+ auth: senderAuth,
+ name: 'sender_create_or_update_subscriber',
+ outputSchema: senderSubscriberUpsertOutputSchema,
+ displayName: 'Create or Update Subscriber',
+ description: 'Adds a subscriber, or updates the one with the same email.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds a subscriber to the Sender account by email, or updates the existing subscriber with that email (name, phone, groups and custom fields). To change statuses or edit by ID use Update Subscriber. Keyed on email, so repeating the call does not create a duplicate.',
+ idempotent: true,
+ },
+ props: {
+ email: Property.ShortText({
+ displayName: 'Email',
+ description: 'Subscriber email address.',
+ required: true,
+ }),
+ firstname: Property.ShortText({ displayName: 'First Name', required: false }),
+ lastname: Property.ShortText({ displayName: 'Last Name', required: false }),
+ phone: Property.ShortText({
+ displayName: 'Phone',
+ description: 'Phone number with country code, e.g. "+37061234567".',
+ required: false,
+ }),
+ groups: senderAiProps.groups({ required: false }),
+ fields: Property.Json({
+ displayName: 'Custom Fields',
+ description:
+ 'Object of custom field values keyed as {$<name>} with the field name from List Fields (without its braces), e.g. {"{$company}": "Acme"}. Unknown keys are skipped with a warning in message.warnings.',
+ required: false,
+ }),
+ triggerAutomation: senderAiProps.triggerAutomation({ required: false }),
+ },
+ async run(context) {
+ const { email, firstname, lastname, phone, groups, fields, triggerAutomation } =
+ context.propsValue;
+ return await senderApi.upsertSubscriber({
+ auth: context.auth,
+ email,
+ firstname,
+ lastname,
+ phone,
+ groups: senderUtils.optionalStringList({ value: groups, propName: 'Group IDs' }),
+ customFields: fields,
+ triggerAutomation: senderUtils.yesNoToBoolean(triggerAutomation),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/create-transactional-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/create-transactional-campaign.ts
new file mode 100644
index 00000000000..5f729377206
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/create-transactional-campaign.ts
@@ -0,0 +1,68 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderApi } from '../../common/api';
+import { senderTransactionalCampaignWriteOutputSchema } from '../../output-schemas';
+
+export const senderCreateTransactionalCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_create_transactional_campaign',
+ outputSchema: senderTransactionalCampaignWriteOutputSchema,
+ displayName: 'Create Transactional Campaign',
+ description: 'Creates a transactional email template.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a transactional campaign: a reusable email template with subject, sender and HTML or plain-text content. Reply To must be on a verified sending domain. Each call creates a separate template.',
+ idempotent: false,
+ },
+ props: {
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Internal name shown in reports.',
+ required: false,
+ }),
+ subject: Property.ShortText({ displayName: 'Subject', required: true }),
+ from: Property.ShortText({
+ displayName: 'From Name',
+ description: 'Sender name shown to recipients.',
+ required: true,
+ }),
+ replyTo: Property.ShortText({
+ displayName: 'Reply To',
+ description: 'Sender email address, on a verified domain in the account.',
+ required: true,
+ }),
+ editor: Property.StaticDropdown({
+ displayName: 'Editor',
+ description:
+ 'html or plain to pass Content; builder creates a drag-and-drop template to finish in Sender.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'HTML', value: 'html' },
+ { label: 'Plain text', value: 'plain' },
+ { label: 'Builder', value: 'builder' },
+ ],
+ },
+ }),
+ content: Property.LongText({
+ displayName: 'Content',
+ description: 'Email body as HTML or plain text, matching Editor.',
+ required: false,
+ }),
+ preheader: Property.ShortText({
+ displayName: 'Preheader',
+ description: 'Preview text shown after the subject in inboxes.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ return await senderApi.createTransactionalCampaign({
+ auth: context.auth,
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/delete-campaigns.ts b/packages/pieces/community/sender/src/lib/actions/ai/delete-campaigns.ts
new file mode 100644
index 00000000000..75f20fe1868
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/delete-campaigns.ts
@@ -0,0 +1,36 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderDeleteCampaignsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_delete_campaigns',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Delete Campaigns',
+ description: 'Deletes one or more email campaigns.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description: 'Deletes the listed email campaigns, with their reports. Cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ campaignIds: Property.Array({
+ displayName: 'Campaign IDs',
+ description: 'IDs of the campaigns to delete. Use List Campaigns.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await senderApi.deleteCampaigns({
+ auth: context.auth,
+ campaignIds: senderUtils.requiredStringList({
+ value: context.propsValue.campaignIds,
+ propName: 'Campaign IDs',
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/delete-field.ts b/packages/pieces/community/sender/src/lib/actions/ai/delete-field.ts
new file mode 100644
index 00000000000..a71a57a50fe
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/delete-field.ts
@@ -0,0 +1,26 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderDeleteFieldAction = createAction({
+ auth: senderAuth,
+ name: 'sender_delete_field',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Delete Field',
+ description: 'Deletes a custom field.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description: 'Deletes a custom subscriber field and the values stored in it. Cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ fieldId: senderAiProps.fieldId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.deleteField({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/delete-group.ts b/packages/pieces/community/sender/src/lib/actions/ai/delete-group.ts
new file mode 100644
index 00000000000..43405ffcc4d
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/delete-group.ts
@@ -0,0 +1,37 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderDeleteGroupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_delete_group',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Delete Group',
+ description: 'Deletes a group.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes a subscriber group. Its subscribers stay in the account unless Delete Subscribers is Yes, which also deletes every subscriber in the group. Cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ groupId: senderAiProps.groupId({ required: true }),
+ deleteSubscribers: senderAiProps.yesNo({
+ required: false,
+ displayName: 'Delete Subscribers',
+ description: 'Also delete the subscribers in this group. Defaults to No.',
+ }),
+ },
+ async run(context) {
+ return await senderApi.deleteGroup({
+ auth: context.auth,
+ groupId: context.propsValue.groupId,
+ deleteSubscribers: senderUtils.yesNoToBoolean(context.propsValue.deleteSubscribers),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/delete-subscribers.ts b/packages/pieces/community/sender/src/lib/actions/ai/delete-subscribers.ts
new file mode 100644
index 00000000000..1e840021b81
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/delete-subscribers.ts
@@ -0,0 +1,37 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderDeleteSubscribersOutputSchema } from '../../output-schemas';
+
+export const senderDeleteSubscribersAction = createAction({
+ auth: senderAuth,
+ name: 'sender_delete_subscribers',
+ outputSchema: senderDeleteSubscribersOutputSchema,
+ displayName: 'Delete Subscribers',
+ description: 'Deletes one or more subscribers.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes the listed subscribers from the Sender account, removing them from every group. To stop emails but keep the contact, use Update Subscriber with Email Status set to Unsubscribed instead.',
+ idempotent: false,
+ },
+ props: {
+ subscribers: senderAiProps.subscribers({
+ required: true,
+ description: 'Email addresses of the subscribers to delete, e.g. ["[email protected]"].',
+ }),
+ },
+ async run(context) {
+ return await senderApi.deleteSubscribers({
+ auth: context.auth,
+ subscribers: senderUtils.requiredStringList({
+ value: context.propsValue.subscribers,
+ propName: 'Subscriber Emails',
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/delete-transactional-campaigns.ts b/packages/pieces/community/sender/src/lib/actions/ai/delete-transactional-campaigns.ts
new file mode 100644
index 00000000000..5137bfbdf83
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/delete-transactional-campaigns.ts
@@ -0,0 +1,38 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderDeleteTransactionalCampaignsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_delete_transactional_campaigns',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Delete Transactional Campaigns',
+ description: 'Deletes one or more transactional campaigns.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Deletes the listed transactional campaigns. Integrations that still send them will fail. Cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ campaignIds: Property.Array({
+ displayName: 'Transactional Campaign IDs',
+ description:
+ 'IDs of the transactional campaigns to delete. Use List Transactional Campaigns.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await senderApi.deleteTransactionalCampaigns({
+ auth: context.auth,
+ campaignIds: senderUtils.requiredStringList({
+ value: context.propsValue.campaignIds,
+ propName: 'Transactional Campaign IDs',
+ }),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-campaign.ts
new file mode 100644
index 00000000000..9ca4ce7cf6a
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-campaign.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetCampaignOutputSchema } from '../../output-schemas';
+
+export const senderGetCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_campaign',
+ outputSchema: senderGetCampaignOutputSchema,
+ displayName: 'Get Campaign',
+ description: 'Gets an email campaign by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one email campaign by ID: subject, sender, status, schedule, content and open, click and bounce counts.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getCampaign({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-group.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-group.ts
new file mode 100644
index 00000000000..9a83c207a1f
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-group.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetGroupOutputSchema } from '../../output-schemas';
+
+export const senderGetGroupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_group',
+ outputSchema: senderGetGroupOutputSchema,
+ displayName: 'Get Group',
+ description: 'Gets a group by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one subscriber group by ID, with its title and active, unsubscribed, bounced and phone subscriber counts.',
+ idempotent: true,
+ },
+ props: {
+ groupId: senderAiProps.groupId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getGroup({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-segment.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-segment.ts
new file mode 100644
index 00000000000..20e357f0654
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-segment.ts
@@ -0,0 +1,26 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetSegmentOutputSchema } from '../../output-schemas';
+
+export const senderGetSegmentAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_segment',
+ outputSchema: senderGetSegmentOutputSchema,
+ displayName: 'Get Segment',
+ description: 'Gets a segment by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description: 'Gets one segment by ID, with its conditions and subscriber counts.',
+ idempotent: true,
+ },
+ props: {
+ segmentId: senderAiProps.segmentId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getSegment({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-subscriber.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-subscriber.ts
new file mode 100644
index 00000000000..e56a5b05da6
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-subscriber.ts
@@ -0,0 +1,30 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetSubscriberOutputSchema } from '../../output-schemas';
+
+export const senderGetSubscriberAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_subscriber',
+ outputSchema: senderGetSubscriberOutputSchema,
+ displayName: 'Get Subscriber',
+ description: 'Gets a subscriber by email, phone or ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Gets one subscriber's profile (name, phone, statuses, groups and custom field values) by email address, phone number or subscriber ID. Fails with a not-found error when no such subscriber exists.",
+ idempotent: true,
+ },
+ props: {
+ subscriberId: senderAiProps.subscriberId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getSubscriber({
+ auth: context.auth,
+ subscriberId: context.propsValue.subscriberId,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-transactional-campaign-report.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-transactional-campaign-report.ts
new file mode 100644
index 00000000000..189149b3f1a
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-transactional-campaign-report.ts
@@ -0,0 +1,54 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetTransactionalCampaignReportOutputSchema } from '../../output-schemas';
+
+export const senderGetTransactionalCampaignReportAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_transactional_campaign_report',
+ outputSchema: senderGetTransactionalCampaignReportOutputSchema,
+ displayName: 'Get Transactional Campaign Report',
+ description: 'Gets sent, open, click and bounce totals for a transactional campaign.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Gets a transactional campaign's sent, open, click, bounce, complaint and unsubscribe totals between two dates, broken down by day, week, month or year.",
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ from: Property.ShortText({
+ displayName: 'From Date',
+ description: 'Start date, YYYY-MM-DD.',
+ required: true,
+ }),
+ to: Property.ShortText({
+ displayName: 'To Date',
+ description: 'End date, YYYY-MM-DD.',
+ required: true,
+ }),
+ period: Property.StaticDropdown({
+ displayName: 'Period',
+ description: 'How to group the totals.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Day', value: 'day' },
+ { label: 'Week', value: 'week' },
+ { label: 'Month', value: 'month' },
+ { label: 'Year', value: 'year' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ return await senderApi.getTransactionalCampaignReport({
+ auth: context.auth,
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-transactional-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-transactional-campaign.ts
new file mode 100644
index 00000000000..eb044f19c57
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-transactional-campaign.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetTransactionalCampaignOutputSchema } from '../../output-schemas';
+
+export const senderGetTransactionalCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_transactional_campaign',
+ outputSchema: senderGetTransactionalCampaignOutputSchema,
+ displayName: 'Get Transactional Campaign',
+ description: 'Gets a transactional campaign by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one transactional campaign by ID: subject, sender, editor type, HTML and send stats.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getTransactionalCampaign({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-workflow-statistics.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-workflow-statistics.ts
new file mode 100644
index 00000000000..a6291aca4ce
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-workflow-statistics.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetWorkflowStatisticsOutputSchema } from '../../output-schemas';
+
+export const senderGetWorkflowStatisticsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_workflow_statistics',
+ outputSchema: senderGetWorkflowStatisticsOutputSchema,
+ displayName: 'Get Workflow Statistics',
+ description: "Gets a workflow's email performance.",
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ "Gets an automation workflow's average email performance: sent, opened, clicked, bounced and unsubscribed counts and rates.",
+ idempotent: true,
+ },
+ props: {
+ workflowId: senderAiProps.workflowId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getWorkflowStatistics({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/get-workflow.ts b/packages/pieces/community/sender/src/lib/actions/ai/get-workflow.ts
new file mode 100644
index 00000000000..78397d9ff1a
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/get-workflow.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderGetWorkflowOutputSchema } from '../../output-schemas';
+
+export const senderGetWorkflowAction = createAction({
+ auth: senderAuth,
+ name: 'sender_get_workflow',
+ outputSchema: senderGetWorkflowOutputSchema,
+ displayName: 'Get Workflow',
+ description: 'Gets an automation workflow by ID.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one automation workflow by ID, with its status, description and email performance.',
+ idempotent: true,
+ },
+ props: {
+ workflowId: senderAiProps.workflowId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.getWorkflow({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/index.ts b/packages/pieces/community/sender/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..d55923fc6c2
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/index.ts
@@ -0,0 +1,107 @@
+import { senderAddSubscribersToGroupAction } from './add-subscribers-to-group';
+import { senderCancelCampaignFollowupAction } from './cancel-campaign-followup';
+import { senderCancelScheduledCampaignAction } from './cancel-scheduled-campaign';
+import { senderCopyCampaignAction } from './copy-campaign';
+import { senderCreateCampaignAction } from './create-campaign';
+import { senderCreateCustomEventAction } from './create-custom-event';
+import { senderCreateFieldAction } from './create-field';
+import { senderCreateGroupAction } from './create-group';
+import { senderCreateOrUpdateSubscriberAction } from './create-or-update-subscriber';
+import { senderCreateTransactionalCampaignAction } from './create-transactional-campaign';
+import { senderDeleteCampaignsAction } from './delete-campaigns';
+import { senderDeleteFieldAction } from './delete-field';
+import { senderDeleteGroupAction } from './delete-group';
+import { senderDeleteSubscribersAction } from './delete-subscribers';
+import { senderDeleteTransactionalCampaignsAction } from './delete-transactional-campaigns';
+import { senderGetCampaignAction } from './get-campaign';
+import { senderGetGroupAction } from './get-group';
+import { senderGetSegmentAction } from './get-segment';
+import { senderGetSubscriberAction } from './get-subscriber';
+import { senderGetTransactionalCampaignAction } from './get-transactional-campaign';
+import { senderGetTransactionalCampaignReportAction } from './get-transactional-campaign-report';
+import { senderGetWorkflowAction } from './get-workflow';
+import { senderGetWorkflowStatisticsAction } from './get-workflow-statistics';
+import { senderListCampaignClicksAction } from './list-campaign-clicks';
+import { senderListCampaignComplaintsAction } from './list-campaign-complaints';
+import { senderListCampaignErrorsAction } from './list-campaign-errors';
+import { senderListCampaignHardBouncesAction } from './list-campaign-hard-bounces';
+import { senderListCampaignOpensAction } from './list-campaign-opens';
+import { senderListCampaignSentEmailsAction } from './list-campaign-sent-emails';
+import { senderListCampaignSoftBouncesAction } from './list-campaign-soft-bounces';
+import { senderListCampaignUnsubscribesAction } from './list-campaign-unsubscribes';
+import { senderListCampaignsAction } from './list-campaigns';
+import { senderListFieldsAction } from './list-fields';
+import { senderListGroupSubscribersAction } from './list-group-subscribers';
+import { senderListGroupsAction } from './list-groups';
+import { senderListSegmentSubscribersAction } from './list-segment-subscribers';
+import { senderListSegmentsAction } from './list-segments';
+import { senderListSubscriberEventsAction } from './list-subscriber-events';
+import { senderListSubscribersAction } from './list-subscribers';
+import { senderListTransactionalBouncesAction } from './list-transactional-bounces';
+import { senderListTransactionalCampaignsAction } from './list-transactional-campaigns';
+import { senderListTransactionalClicksAction } from './list-transactional-clicks';
+import { senderListTransactionalComplaintsAction } from './list-transactional-complaints';
+import { senderListTransactionalOpensAction } from './list-transactional-opens';
+import { senderListTransactionalSentEmailsAction } from './list-transactional-sent-emails';
+import { senderListWorkflowStepsAction } from './list-workflow-steps';
+import { senderListWorkflowsAction } from './list-workflows';
+import { senderRemoveSubscribersFromGroupAction } from './remove-subscribers-from-group';
+import { senderRenameGroupAction } from './rename-group';
+import { senderUpdateFieldAction } from './update-field';
+import { senderUpdateSubscriberAction } from './update-subscriber';
+import { senderUpdateTransactionalCampaignAction } from './update-transactional-campaign';
+
+export const senderAiActions = [
+ senderListSubscribersAction,
+ senderGetSubscriberAction,
+ senderCreateOrUpdateSubscriberAction,
+ senderUpdateSubscriberAction,
+ senderDeleteSubscribersAction,
+ senderListSubscriberEventsAction,
+ senderAddSubscribersToGroupAction,
+ senderRemoveSubscribersFromGroupAction,
+ senderCreateCustomEventAction,
+ senderListGroupsAction,
+ senderGetGroupAction,
+ senderCreateGroupAction,
+ senderRenameGroupAction,
+ senderDeleteGroupAction,
+ senderListGroupSubscribersAction,
+ senderListFieldsAction,
+ senderCreateFieldAction,
+ senderUpdateFieldAction,
+ senderDeleteFieldAction,
+ senderListSegmentsAction,
+ senderGetSegmentAction,
+ senderListSegmentSubscribersAction,
+ senderListCampaignsAction,
+ senderGetCampaignAction,
+ senderCreateCampaignAction,
+ senderDeleteCampaignsAction,
+ senderCopyCampaignAction,
+ senderCancelScheduledCampaignAction,
+ senderCancelCampaignFollowupAction,
+ senderListCampaignErrorsAction,
+ senderListCampaignOpensAction,
+ senderListCampaignClicksAction,
+ senderListCampaignUnsubscribesAction,
+ senderListCampaignHardBouncesAction,
+ senderListCampaignSoftBouncesAction,
+ senderListCampaignComplaintsAction,
+ senderListCampaignSentEmailsAction,
+ senderListTransactionalCampaignsAction,
+ senderGetTransactionalCampaignAction,
+ senderCreateTransactionalCampaignAction,
+ senderUpdateTransactionalCampaignAction,
+ senderDeleteTransactionalCampaignsAction,
+ senderGetTransactionalCampaignReportAction,
+ senderListTransactionalSentEmailsAction,
+ senderListTransactionalOpensAction,
+ senderListTransactionalClicksAction,
+ senderListTransactionalBouncesAction,
+ senderListTransactionalComplaintsAction,
+ senderListWorkflowsAction,
+ senderGetWorkflowAction,
+ senderListWorkflowStepsAction,
+ senderGetWorkflowStatisticsAction,
+];
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-clicks.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-clicks.ts
new file mode 100644
index 00000000000..0193cbedbcd
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-clicks.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignClicksAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_clicks',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Clicks',
+ description: 'Lists one page of the subscriber clicks of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who clicked a link in the campaign, with the link URL and time. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'clicks',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-complaints.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-complaints.ts
new file mode 100644
index 00000000000..a068e0b6b25
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-complaints.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignComplaintsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_complaints',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Complaints',
+ description: 'Lists one page of the spam complaints of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who reported the campaign as spam. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'complaints',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-errors.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-errors.ts
new file mode 100644
index 00000000000..15c8f302bed
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-errors.ts
@@ -0,0 +1,27 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListCampaignErrorsOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignErrorsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_errors',
+ outputSchema: senderListCampaignErrorsOutputSchema,
+ displayName: 'List Campaign Errors',
+ description: 'Lists the errors that block a campaign from sending.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Lists the errors and warnings that stop a campaign from being sent, such as a missing subject, unverified sender domain or empty recipient list. Check it when Send Campaign fails.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignErrors({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-hard-bounces.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-hard-bounces.ts
new file mode 100644
index 00000000000..c64256cdce5
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-hard-bounces.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignHardBouncesAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_hard_bounces',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Hard Bounces',
+ description: 'Lists one page of the hard bounces of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who hard-bounced (permanent delivery failure), with the reason. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'hard_bounces',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-opens.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-opens.ts
new file mode 100644
index 00000000000..98640d6618f
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-opens.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignOpensAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_opens',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Opens',
+ description: 'Lists one page of the subscribers who opened of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who opened the campaign, with the time. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'opens',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-sent-emails.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-sent-emails.ts
new file mode 100644
index 00000000000..d333a6894ef
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-sent-emails.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignSentEmailsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_sent_emails',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Sent Emails',
+ description: 'Lists one page of the recipients the campaign was sent to of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who were sent the campaign. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'emails-sent',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-soft-bounces.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-soft-bounces.ts
new file mode 100644
index 00000000000..9140b5b920f
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-soft-bounces.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignSoftBouncesAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_soft_bounces',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Soft Bounces',
+ description: 'Lists one page of the soft bounces of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who soft-bounced (temporary delivery failure), with the reason. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'soft_bounces',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-unsubscribes.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-unsubscribes.ts
new file mode 100644
index 00000000000..a66e4eeee10
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaign-unsubscribes.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignUnsubscribesAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaign_unsubscribes',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Campaign Unsubscribes',
+ description: 'Lists one page of the subscribers who unsubscribed of a campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers who unsubscribed from the campaign. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.campaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listCampaignReport({
+ auth: context.auth,
+ report: 'unsubscribes',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-campaigns.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-campaigns.ts
new file mode 100644
index 00000000000..ccd92ad04ea
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-campaigns.ts
@@ -0,0 +1,42 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListCampaignsOutputSchema } from '../../output-schemas';
+
+export const senderListCampaignsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_campaigns',
+ outputSchema: senderListCampaignsOutputSchema,
+ displayName: 'List Campaigns',
+ description: 'Lists one page of email campaigns.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of email campaigns with their ID, title, subject, status, schedule and send stats, optionally filtered by status. Use it to find a campaign ID. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ description: 'Only return campaigns with this status.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Draft', value: 'DRAFT' },
+ { label: 'Scheduled', value: 'SCHEDULED' },
+ { label: 'Sending', value: 'SENDING' },
+ { label: 'Sent', value: 'SENT' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ return await senderApi.listCampaigns({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-fields.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-fields.ts
new file mode 100644
index 00000000000..13881b2e52a
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-fields.ts
@@ -0,0 +1,28 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListFieldsOutputSchema } from '../../output-schemas';
+
+export const senderListFieldsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_fields',
+ outputSchema: senderListFieldsOutputSchema,
+ displayName: 'List Fields',
+ description: 'Lists the custom subscriber fields.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the subscriber fields in the account, default and custom, with their ID, title, type and name. To set a value with Create or Update Subscriber or Update Subscriber, key it as {$<name>}: a field named "{{company}}" takes the key "{$company}".',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listFields({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-group-subscribers.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-group-subscribers.ts
new file mode 100644
index 00000000000..00c3a48886b
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-group-subscribers.ts
@@ -0,0 +1,29 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListMembersOutputSchema } from '../../output-schemas';
+
+export const senderListGroupSubscribersAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_group_subscribers',
+ outputSchema: senderListMembersOutputSchema,
+ displayName: 'List Group Subscribers',
+ description: 'Lists one page of the subscribers in a group.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers in one group, with their ID, email, name and statuses. Page through with Page and Limit using the returned meta. Sender answers an empty group with the error "This group has no active subscribers".',
+ idempotent: true,
+ },
+ props: {
+ groupId: senderAiProps.groupId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listGroupSubscribers({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-groups.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-groups.ts
new file mode 100644
index 00000000000..abd18c65c1a
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-groups.ts
@@ -0,0 +1,28 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListGroupsOutputSchema } from '../../output-schemas';
+
+export const senderListGroupsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_groups',
+ outputSchema: senderListGroupsOutputSchema,
+ displayName: 'List Groups',
+ description: 'Lists one page of subscriber groups.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of subscriber groups (lists) with their ID, title and subscriber counts. Use it to find a group ID for the group and subscriber actions. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listGroups({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-segment-subscribers.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-segment-subscribers.ts
new file mode 100644
index 00000000000..b10d9fe61bf
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-segment-subscribers.ts
@@ -0,0 +1,29 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListMembersOutputSchema } from '../../output-schemas';
+
+export const senderListSegmentSubscribersAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_segment_subscribers',
+ outputSchema: senderListMembersOutputSchema,
+ displayName: 'List Segment Subscribers',
+ description: 'Lists one page of the subscribers in a segment.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of the subscribers matching one segment, with their ID, email, name and statuses. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ segmentId: senderAiProps.segmentId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listSegmentSubscribers({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-segments.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-segments.ts
new file mode 100644
index 00000000000..def38054dca
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-segments.ts
@@ -0,0 +1,28 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListSegmentsOutputSchema } from '../../output-schemas';
+
+export const senderListSegmentsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_segments',
+ outputSchema: senderListSegmentsOutputSchema,
+ displayName: 'List Segments',
+ description: 'Lists one page of segments.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of segments (saved subscriber filters) with their ID, name, conditions and subscriber counts. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listSegments({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-subscriber-events.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-subscriber-events.ts
new file mode 100644
index 00000000000..5d88ad3bb24
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-subscriber-events.ts
@@ -0,0 +1,43 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListSubscriberEventsOutputSchema } from '../../output-schemas';
+
+export const senderListSubscriberEventsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_subscriber_events',
+ outputSchema: senderListSubscriberEventsOutputSchema,
+ displayName: 'List Subscriber Events',
+ description: "Lists a subscriber's campaign activity.",
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the campaign activity of one subscriber, found by email, phone or ID: emails received, opened, clicked, bounced and unsubscribed, with the campaign each came from.',
+ idempotent: true,
+ },
+ props: {
+ subscriberId: senderAiProps.subscriberId({ required: true }),
+ actions: Property.StaticMultiSelectDropdown({
+ displayName: 'Event Types',
+ description: 'Which kinds of activity to return.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Received', value: 'got' },
+ { label: 'Opened', value: 'opened' },
+ { label: 'Clicked', value: 'clicked' },
+ { label: 'Bounced', value: 'bounced' },
+ { label: 'Unsubscribed', value: 'unsubscribed' },
+ ],
+ },
+ }),
+ },
+ async run(context) {
+ const { subscriberId, actions } = context.propsValue;
+ return await senderApi.listSubscriberEvents({ auth: context.auth, subscriberId, actions });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-subscribers.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-subscribers.ts
new file mode 100644
index 00000000000..a41136a224d
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-subscribers.ts
@@ -0,0 +1,28 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListSubscribersOutputSchema } from '../../output-schemas';
+
+export const senderListSubscribersAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_subscribers',
+ outputSchema: senderListSubscribersOutputSchema,
+ displayName: 'List Subscribers',
+ description: 'Lists one page of subscribers in your Sender account.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of subscribers in the Sender account with their ID, email, name, phone, status per channel and groups. Use it to find a subscriber ID; to look up one known email use Get Subscriber. Returns 10 subscribers per page; page through with Page using the returned meta.last_page.',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ },
+ async run(context) {
+ const { page } = context.propsValue;
+ return await senderApi.listSubscribers({ auth: context.auth, page });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-bounces.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-bounces.ts
new file mode 100644
index 00000000000..acc37c1dbfd
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-bounces.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListTransactionalBouncesAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_transactional_bounces',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Transactional Bounces',
+ description: 'Lists one page of the bounces of a transactional campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of bounced emails sent from the campaign, with the bounce type and reason. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ direction: senderAiProps.direction({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listTransactionalReport({
+ auth: context.auth,
+ report: 'bounces',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-campaigns.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-campaigns.ts
new file mode 100644
index 00000000000..32d50d7b42e
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-campaigns.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListTransactionalCampaignsOutputSchema } from '../../output-schemas';
+
+export const senderListTransactionalCampaignsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_transactional_campaigns',
+ outputSchema: senderListTransactionalCampaignsOutputSchema,
+ displayName: 'List Transactional Campaigns',
+ description: 'Lists one page of transactional email templates.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of transactional campaigns (reusable email templates sent one recipient at a time) with their ID, subject, sender and send stats. Use it to find a transactional campaign ID. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listTransactionalCampaigns({
+ auth: context.auth,
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-clicks.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-clicks.ts
new file mode 100644
index 00000000000..34426fdf3d3
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-clicks.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListTransactionalClicksAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_transactional_clicks',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Transactional Clicks',
+ description: 'Lists one page of the clicks of a transactional campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of link clicks in emails sent from the campaign, with the URL. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ direction: senderAiProps.direction({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listTransactionalReport({
+ auth: context.auth,
+ report: 'clicks',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-complaints.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-complaints.ts
new file mode 100644
index 00000000000..7a9bbdd0221
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-complaints.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListTransactionalComplaintsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_transactional_complaints',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Transactional Complaints',
+ description: 'Lists one page of the spam complaints of a transactional campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of spam complaints about emails sent from the campaign. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ direction: senderAiProps.direction({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listTransactionalReport({
+ auth: context.auth,
+ report: 'complaints',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-opens.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-opens.ts
new file mode 100644
index 00000000000..49d68e87622
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-opens.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListTransactionalOpensAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_transactional_opens',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Transactional Opens',
+ description: 'Lists one page of the opens of a transactional campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of opens of emails sent from the campaign. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ direction: senderAiProps.direction({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listTransactionalReport({
+ auth: context.auth,
+ report: 'opens',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-sent-emails.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-sent-emails.ts
new file mode 100644
index 00000000000..40eb1447a67
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-transactional-sent-emails.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderReportPageOutputSchema } from '../../output-schemas';
+
+export const senderListTransactionalSentEmailsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_transactional_sent_emails',
+ outputSchema: senderReportPageOutputSchema,
+ displayName: 'List Transactional Sent Emails',
+ description: 'Lists one page of the emails sent of a transactional campaign.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of emails sent from the campaign, with recipient and email ID. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({ required: false }),
+ direction: senderAiProps.direction({ required: false }),
+ },
+ async run(context) {
+ return await senderApi.listTransactionalReport({
+ auth: context.auth,
+ report: 'sent',
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-workflow-steps.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-workflow-steps.ts
new file mode 100644
index 00000000000..76ab4818e16
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-workflow-steps.ts
@@ -0,0 +1,32 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListWorkflowStepsOutputSchema } from '../../output-schemas';
+
+export const senderListWorkflowStepsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_workflow_steps',
+ outputSchema: senderListWorkflowStepsOutputSchema,
+ displayName: 'List Workflow Steps',
+ description: 'Lists the steps of an automation workflow.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the steps of an automation workflow (trigger, delays, conditions, emails) as a tree. Large workflows come in batches: when the response includes next_batch, pass it as Batch Number to get the next one.',
+ idempotent: true,
+ },
+ props: {
+ workflowId: senderAiProps.workflowId({ required: true }),
+ batchNo: Property.Number({
+ displayName: 'Batch Number',
+ description: 'Zero-based batch to return. Defaults to 0.',
+ required: false,
+ }),
+ },
+ async run(context) {
+ return await senderApi.listWorkflowSteps({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/list-workflows.ts b/packages/pieces/community/sender/src/lib/actions/ai/list-workflows.ts
new file mode 100644
index 00000000000..bc338ec7ef7
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/list-workflows.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderListWorkflowsOutputSchema } from '../../output-schemas';
+
+export const senderListWorkflowsAction = createAction({
+ auth: senderAuth,
+ name: 'sender_list_workflows',
+ outputSchema: senderListWorkflowsOutputSchema,
+ displayName: 'List Workflows',
+ description: 'Lists one page of automation workflows.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists one page of automation workflows with their ID, title, status and email stats, optionally filtered by status or an exact title (the title filter matches the full title only, not part of it). Use it to find a workflow ID. Page through with Page and Limit using the returned meta.',
+ idempotent: true,
+ },
+ props: {
+ page: senderAiProps.page({ required: false }),
+ limit: senderAiProps.limit({
+ required: false,
+ description: 'Workflows per page, 1 to 100. Defaults to 10.',
+ }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ description: 'Only return workflows with this status.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Draft', value: 'DRAFT' },
+ { label: 'Active', value: 'ACTIVE' },
+ { label: 'Paused', value: 'PAUSED' },
+ ],
+ },
+ }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'Only return the workflow with exactly this title, e.g. "Welcome (Ecommerce)".',
+ required: false,
+ }),
+ },
+ async run(context) {
+ return await senderApi.listWorkflows({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/remove-subscribers-from-group.ts b/packages/pieces/community/sender/src/lib/actions/ai/remove-subscribers-from-group.ts
new file mode 100644
index 00000000000..a55bb74ff85
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/remove-subscribers-from-group.ts
@@ -0,0 +1,39 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderRemoveSubscribersFromGroupOutputSchema } from '../../output-schemas';
+
+export const senderRemoveSubscribersFromGroupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_remove_subscribers_from_group',
+ outputSchema: senderRemoveSubscribersFromGroupOutputSchema,
+ displayName: 'Remove Subscribers from Group',
+ description: 'Removes subscribers from a group.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Removes subscribers, by email, from one group. They stay in the account and in their other groups; to unsubscribe them use Update Subscriber. Repeating it leaves membership unchanged.',
+ idempotent: true,
+ },
+ props: {
+ groupId: senderAiProps.groupId({ required: true }),
+ subscribers: senderAiProps.subscribers({ required: true }),
+ triggerAutomation: senderAiProps.triggerAutomation({ required: false }),
+ },
+ async run(context) {
+ const { groupId, subscribers, triggerAutomation } = context.propsValue;
+ return await senderApi.removeSubscribersFromGroup({
+ auth: context.auth,
+ groupId,
+ subscribers: senderUtils.requiredStringList({
+ value: subscribers,
+ propName: 'Subscriber Emails',
+ }),
+ triggerAutomation: senderUtils.yesNoToBoolean(triggerAutomation),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/rename-group.ts b/packages/pieces/community/sender/src/lib/actions/ai/rename-group.ts
new file mode 100644
index 00000000000..e6fe60a19f8
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/rename-group.ts
@@ -0,0 +1,31 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderRenameGroupAction = createAction({
+ auth: senderAuth,
+ name: 'sender_rename_group',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Rename Group',
+ description: 'Renames a group.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description: 'Changes the title of an existing subscriber group. Membership is not affected.',
+ idempotent: true,
+ },
+ props: {
+ groupId: senderAiProps.groupId({ required: true }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New name for the group.',
+ required: true,
+ }),
+ },
+ async run(context) {
+ return await senderApi.renameGroup({ auth: context.auth, ...context.propsValue });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/update-field.ts b/packages/pieces/community/sender/src/lib/actions/ai/update-field.ts
new file mode 100644
index 00000000000..e29070096e2
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/update-field.ts
@@ -0,0 +1,44 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderSuccessOutputSchema } from '../../output-schemas';
+
+export const senderUpdateFieldAction = createAction({
+ auth: senderAuth,
+ name: 'sender_update_field',
+ outputSchema: senderSuccessOutputSchema,
+ displayName: 'Update Field',
+ description: 'Renames a custom field or shows or hides it.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Renames a custom subscriber field and/or sets whether it shows as a filter in the subscribers dashboard. Only the values you set change; the field type cannot be changed. Renaming also changes the key used to write values ("Company size" becomes "{$company_size}"), so read it again with List Fields before writing values.',
+ idempotent: true,
+ },
+ props: {
+ fieldId: senderAiProps.fieldId({ required: true }),
+ title: Property.ShortText({
+ displayName: 'Title',
+ description: 'New field name.',
+ required: false,
+ }),
+ show: senderAiProps.yesNo({
+ required: false,
+ displayName: 'Show in Dashboard',
+ description: 'Show the field as a filter in the subscribers dashboard.',
+ }),
+ },
+ async run(context) {
+ const { fieldId, title, show } = context.propsValue;
+ return await senderApi.updateField({
+ auth: context.auth,
+ fieldId,
+ title,
+ show: senderUtils.yesNoToBoolean(show),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/update-subscriber.ts b/packages/pieces/community/sender/src/lib/actions/ai/update-subscriber.ts
new file mode 100644
index 00000000000..2ab701b5c41
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/update-subscriber.ts
@@ -0,0 +1,93 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderUtils } from '../../common/utils';
+import { senderSubscriberUpsertOutputSchema } from '../../output-schemas';
+
+const STATUS_OPTIONS = [
+ { label: 'Active', value: 'ACTIVE' },
+ { label: 'Unsubscribed', value: 'UNSUBSCRIBED' },
+ { label: 'Bounced', value: 'BOUNCED' },
+ { label: 'Spam reported', value: 'SPAM_REPORTED' },
+];
+
+export const senderUpdateSubscriberAction = createAction({
+ auth: senderAuth,
+ name: 'sender_update_subscriber',
+ outputSchema: senderSubscriberUpsertOutputSchema,
+ displayName: 'Update Subscriber',
+ description: "Updates a subscriber's details, groups or statuses.",
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ "Updates an existing subscriber, found by email, phone or ID: name, phone, groups, custom fields, and the email, SMS and transactional-email statuses. Set Email Status to Unsubscribed to unsubscribe someone without deleting them. Only the fields you set change: it reads the subscriber first and re-sends the current first and last name, which Sender would otherwise clear. Not safe against a concurrent edit of the same subscriber. Groups replaces the subscriber's group list; to add or remove single memberships use Add Subscribers to Group or Remove Subscribers from Group.",
+ idempotent: true,
+ },
+ props: {
+ subscriberId: senderAiProps.subscriberId({ required: true }),
+ firstname: Property.ShortText({ displayName: 'First Name', required: false }),
+ lastname: Property.ShortText({ displayName: 'Last Name', required: false }),
+ phone: Property.ShortText({
+ displayName: 'Phone',
+ description: 'Phone number with country code, e.g. "+37061234567".',
+ required: false,
+ }),
+ groups: senderAiProps.groups({ required: false }),
+ fields: Property.Json({
+ displayName: 'Custom Fields',
+ description:
+ 'Object of custom field values keyed as {$<name>} with the field name from List Fields (without its braces), e.g. {"{$company}": "Acme"}. Unknown keys are skipped with a warning in message.warnings.',
+ required: false,
+ }),
+ subscriberStatus: Property.StaticDropdown({
+ displayName: 'Email Status',
+ description: 'Email campaign status.',
+ required: false,
+ options: { disabled: false, options: STATUS_OPTIONS },
+ }),
+ smsStatus: Property.StaticDropdown({
+ displayName: 'SMS Status',
+ description: 'SMS campaign status.',
+ required: false,
+ options: { disabled: false, options: STATUS_OPTIONS },
+ }),
+ transactionalEmailStatus: Property.StaticDropdown({
+ displayName: 'Transactional Email Status',
+ description: 'Transactional email status.',
+ required: false,
+ options: { disabled: false, options: STATUS_OPTIONS },
+ }),
+ triggerAutomation: senderAiProps.triggerAutomation({ required: false }),
+ },
+ async run(context) {
+ const {
+ subscriberId,
+ firstname,
+ lastname,
+ phone,
+ groups,
+ fields,
+ subscriberStatus,
+ smsStatus,
+ transactionalEmailStatus,
+ triggerAutomation,
+ } = context.propsValue;
+ const current = await senderApi.getSubscriber({ auth: context.auth, subscriberId });
+ return await senderApi.updateSubscriber({
+ auth: context.auth,
+ subscriberId,
+ firstname: firstname ?? current.firstname ?? undefined,
+ lastname: lastname ?? current.lastname ?? undefined,
+ phone,
+ groups: senderUtils.optionalStringList({ value: groups, propName: 'Group IDs' }),
+ customFields: fields,
+ subscriberStatus,
+ smsStatus,
+ transactionalEmailStatus,
+ triggerAutomation: senderUtils.yesNoToBoolean(triggerAutomation),
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/ai/update-transactional-campaign.ts b/packages/pieces/community/sender/src/lib/actions/ai/update-transactional-campaign.ts
new file mode 100644
index 00000000000..8810cffa491
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/actions/ai/update-transactional-campaign.ts
@@ -0,0 +1,53 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../../auth';
+import { senderAiProps } from '../../common/ai-props';
+import { senderApi } from '../../common/api';
+import { senderTransactionalCampaignWriteOutputSchema } from '../../output-schemas';
+
+export const senderUpdateTransactionalCampaignAction = createAction({
+ auth: senderAuth,
+ name: 'sender_update_transactional_campaign',
+ outputSchema: senderTransactionalCampaignWriteOutputSchema,
+ displayName: 'Update Transactional Campaign',
+ description: 'Updates a transactional email template.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Updates the title, subject, sender, reply-to, editor type or preheader of a transactional campaign. Only the values you set change. Reply To must be on a verified sending domain.',
+ idempotent: true,
+ },
+ props: {
+ campaignId: senderAiProps.transactionalCampaignId({ required: true }),
+ title: Property.ShortText({ displayName: 'Title', required: false }),
+ subject: Property.ShortText({ displayName: 'Subject', required: false }),
+ from: Property.ShortText({ displayName: 'From Name', required: false }),
+ replyTo: Property.ShortText({
+ displayName: 'Reply To',
+ description: 'Sender email address, on a verified domain in the account.',
+ required: false,
+ }),
+ editor: Property.StaticDropdown({
+ displayName: 'Editor',
+ description:
+ 'html or plain to pass Content; builder creates a drag-and-drop template to finish in Sender.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'HTML', value: 'html' },
+ { label: 'Plain text', value: 'plain' },
+ { label: 'Builder', value: 'builder' },
+ ],
+ },
+ }),
+ preheader: Property.ShortText({ displayName: 'Preheader', required: false }),
+ },
+ async run(context) {
+ return await senderApi.updateTransactionalCampaign({
+ auth: context.auth,
+ ...context.propsValue,
+ });
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/create-campaign.ts b/packages/pieces/community/sender/src/lib/actions/create-campaign.ts
index 481e7309b22..aeb47a5921e 100644
--- a/packages/pieces/community/sender/src/lib/actions/create-campaign.ts
+++ b/packages/pieces/community/sender/src/lib/actions/create-campaign.ts
@@ -1,16 +1,17 @@
import { createAction, Property } from '@activepieces/pieces-framework';
-import { groupIdsDropdown, makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
-import { group } from 'console';
-
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
+import { senderCampaignWriteOutputSchema } from '../output-schemas';
export const createCampaignAction = createAction({
auth: senderAuth,
name: 'create_campaign',
+ outputSchema: senderCampaignWriteOutputSchema,
classification: 'WRITE',
displayName: 'Create Campaign',
description: 'Creates a draft campaign in Sender',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Creates a new draft email campaign in a Sender account targeting one or more subscriber groups, with subject, sender name, reply-to, and content type. Use to set up a campaign for later sending (it is not sent here). Not idempotent: each call creates a separate draft, so repeating produces duplicates. Content type must be one of "editor", "html", or "text".', idempotent: false },
props: {
title: Property.ShortText({
@@ -38,28 +39,17 @@ export const createCampaignAction = createAction({
description: 'The value must be one of "editor", "html", or "text"',
required: true,
}),
- groups: groupIdsDropdown,
+ groups: senderProps.groupIds({ required: false }),
},
async run(context) {
- const campaignData: any = {
+ return await senderApi.createCampaign({
+ auth: context.auth,
title: context.propsValue.title,
subject: context.propsValue.subject,
from: context.propsValue.from,
- content_type: context.propsValue.content_type,
+ replyTo: context.propsValue.reply_to,
+ contentType: context.propsValue.content_type,
groups: context.propsValue.groups,
- };
-
- if (context.propsValue.reply_to) {
- campaignData.reply_to = context.propsValue.reply_to;
- }
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/campaigns',
- HttpMethod.POST,
- campaignData
- );
-
- return response.body;
+ });
},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/actions/remove-subscriber-from-group.ts b/packages/pieces/community/sender/src/lib/actions/remove-subscriber-from-group.ts
index a148341f9d1..965555538ca 100644
--- a/packages/pieces/community/sender/src/lib/actions/remove-subscriber-from-group.ts
+++ b/packages/pieces/community/sender/src/lib/actions/remove-subscriber-from-group.ts
@@ -1,45 +1,35 @@
-import { createAction, Property } from '@activepieces/pieces-framework';
-import {
- groupIdDropdown,
- makeSenderRequest,
- senderAuth,
- subscribersDropdown,
-} from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { createAction } from '@activepieces/pieces-framework';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
+import { senderRemoveSubscriberFromGroupOutputSchema } from '../output-schemas';
export const removeSubscriberFromGroupAction = createAction({
auth: senderAuth,
name: 'remove_subscriber_from_group',
+ outputSchema: senderRemoveSubscriberFromGroupOutputSchema,
classification: 'WRITE',
displayName: 'Remove Subscriber from Group',
description: 'Remove a subscriber from a specific group',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Removes one or more subscribers from a specific group/list in a Sender account, identified by group ID and subscriber IDs. Use to unsegment contacts without unsubscribing them globally. Idempotent: removing contacts no longer in the group leaves the group unchanged.', idempotent: true },
props: {
- subscribers: subscribersDropdown,
- groupId: groupIdDropdown,
+ subscribers: senderProps.subscribers({ required: true }),
+ groupId: senderProps.groupId({ required: false }),
},
async run(context) {
- const subscribers = context.propsValue.subscribers;
- const groupId = context.propsValue.groupId;
-
- const requestBody = {
- subscribers: subscribers,
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- `/subscribers/groups/${groupId}`,
- HttpMethod.DELETE,
- requestBody
- );
-
+ const { subscribers, groupId } = context.propsValue;
+ const response = await senderApi.removeSubscribersFromGroup({
+ auth: context.auth,
+ groupId,
+ subscribers,
+ });
return {
success: true,
subscribers,
groupId,
removedAt: new Date().toISOString(),
- response: response.body,
+ response,
};
},
});
diff --git a/packages/pieces/community/sender/src/lib/actions/send-campaign.ts b/packages/pieces/community/sender/src/lib/actions/send-campaign.ts
index c933a7db0fb..0bf6feec035 100644
--- a/packages/pieces/community/sender/src/lib/actions/send-campaign.ts
+++ b/packages/pieces/community/sender/src/lib/actions/send-campaign.ts
@@ -1,10 +1,7 @@
import { createAction } from '@activepieces/pieces-framework';
-import {
- campaignDropdown,
- makeSenderRequest,
- senderAuth,
-} from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
export const sendCampaignAction = createAction({
auth: senderAuth,
@@ -15,17 +12,12 @@ export const sendCampaignAction = createAction({
audience: 'both',
aiMetadata: { description: 'Sends an existing draft campaign in a Sender account to its configured recipient groups, identified by campaign ID. Use only after a campaign draft is created and ready to deliver. Not idempotent: this dispatches email to recipients, so re-running may re-send or error; call once.', idempotent: false },
props: {
- campaignId: campaignDropdown,
+ campaignId: senderProps.campaignId({ required: true }),
},
async run(context) {
- const campaignId = context.propsValue.campaignId;
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- `/campaigns/${campaignId}/send`,
- HttpMethod.POST,
- );
-
- return response.body;
+ return await senderApi.sendCampaign({
+ auth: context.auth,
+ campaignId: context.propsValue.campaignId,
+ });
},
});
diff --git a/packages/pieces/community/sender/src/lib/actions/unsubscribe-subscriber.ts b/packages/pieces/community/sender/src/lib/actions/unsubscribe-subscriber.ts
index 5287d59f6fc..8980d78e503 100644
--- a/packages/pieces/community/sender/src/lib/actions/unsubscribe-subscriber.ts
+++ b/packages/pieces/community/sender/src/lib/actions/unsubscribe-subscriber.ts
@@ -1,37 +1,25 @@
-import { createAction, Property } from '@activepieces/pieces-framework';
-import {
- makeSenderRequest,
- senderAuth,
- subscriberDropdownSingle,
-} from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
-import { subscribe } from 'diagnostics_channel';
+import { createAction } from '@activepieces/pieces-framework';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
+import { senderDeleteSubscribersOutputSchema } from '../output-schemas';
export const unsubscribeSubscriberAction = createAction({
auth: senderAuth,
name: 'unsubscribe_subscriber',
+ outputSchema: senderDeleteSubscribersOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Unsubscribe Subscriber',
description: 'Mark an email address as unsubscribed globally or from a group',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: 'Marks a subscriber as unsubscribed in a Sender account so they stop receiving campaigns. Use to honor an opt-out or suppress a contact. Identify the subscriber by their Sender subscriber ID. Idempotent: re-running on an already-unsubscribed contact leaves them unsubscribed with no further effect.', idempotent: true },
props: {
- subscriber: subscriberDropdownSingle,
+ subscriber: senderProps.subscriber({ required: true }),
},
async run(context) {
- const subscriber = context.propsValue.subscriber;
- const subscriberId = subscriber;
-
- const requestBody = {
- subscribers: [subscriberId],
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- `/subscribers`,
- HttpMethod.DELETE,
- requestBody
- );
- return response.body;
+ return await senderApi.deleteSubscribers({
+ auth: context.auth,
+ subscribers: [context.propsValue.subscriber],
+ });
},
});
diff --git a/packages/pieces/community/sender/src/lib/actions/update-subscriber.ts b/packages/pieces/community/sender/src/lib/actions/update-subscriber.ts
index c6936c1d668..a8ec619faae 100644
--- a/packages/pieces/community/sender/src/lib/actions/update-subscriber.ts
+++ b/packages/pieces/community/sender/src/lib/actions/update-subscriber.ts
@@ -1,19 +1,20 @@
-import { createAction, Property} from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth, subscriberDropdownSingle } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
-import { subscribe } from 'diagnostics_channel';
-
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderProps } from '../common/props';
+import { senderSubscriberWriteOutputSchema } from '../output-schemas';
export const updateSubscriberAction = createAction({
auth: senderAuth,
name: 'update_subscriber',
+ outputSchema: senderSubscriberWriteOutputSchema,
classification: 'WRITE',
displayName: 'Update Subscriber',
description: 'Update an existing subscriber\'s data',
- audience: 'both',
+ audience: 'human',
aiMetadata: { description: "Updates an existing subscriber's name, phone, or custom fields in a Sender account, identified by subscriber ID. Use when the contact already exists and you only need to change attributes; to create-or-update by email use Add / Update Subscriber instead. Idempotent: applying the same values repeatedly yields the same result.", idempotent: true },
props: {
- subscriber: subscriberDropdownSingle,
+ subscriber: senderProps.subscriber({ required: true }),
email: Property.ShortText({
displayName: 'Email',
description: 'Subscriber email address to update',
@@ -41,33 +42,13 @@ export const updateSubscriberAction = createAction({
}),
},
async run(context) {
- const email = context.propsValue.email;
- const phone = context.propsValue.phone;
- const {subscriber}= context.propsValue;
-
- const subscriberId = subscriber;
- const updateData: any = {};
-
- if (context.propsValue.firstname) {
- updateData.firstname = context.propsValue.firstname;
- }
- if (context.propsValue.lastname) {
- updateData.lastname = context.propsValue.lastname;
- }
- if (context.propsValue.phone) {
- updateData.phone = context.propsValue.phone;
- }
- if (context.propsValue.customFields) {
- updateData.fields = context.propsValue.customFields;
- }
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- `/subscribers/${subscriberId}`,
- HttpMethod.PATCH,
- updateData
- );
-
- return response.body;
+ return await senderApi.updateSubscriber({
+ auth: context.auth,
+ subscriberId: context.propsValue.subscriber,
+ firstname: context.propsValue.firstname,
+ lastname: context.propsValue.lastname,
+ phone: context.propsValue.phone,
+ customFields: context.propsValue.customFields,
+ });
},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/auth.ts b/packages/pieces/community/sender/src/lib/auth.ts
new file mode 100644
index 00000000000..be1b9582b48
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/auth.ts
@@ -0,0 +1,32 @@
+import { AppConnectionType, PieceAuth, tryCatch } from '@activepieces/pieces-framework';
+
+import { senderApi } from './common/api';
+
+export const senderAuth = PieceAuth.SecretText({
+ displayName: 'API Token',
+ description: `To get your API token:
+1. Sign in to [Sender](https://app.sender.net) and open the [API access tokens](https://app.sender.net/settings/tokens) settings.
+2. Create a new API token.
+3. Copy the token and paste it here. It gives full access to your account, so keep it private.`,
+ required: true,
+ validate: async ({ auth }) => {
+ const { error } = await tryCatch(() =>
+ senderApi.listGroups({
+ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth },
+ limit: 1,
+ }),
+ );
+ return error
+ ? {
+ valid: false,
+ error: 'Invalid API token. Check that it is copied in full and has not expired.',
+ }
+ : { valid: true };
+ },
+ getConnectionIdentifier: async ({ auth }) => {
+ const { data } = await tryCatch(() =>
+ senderApi.getMe({ auth: { type: AppConnectionType.SECRET_TEXT, secret_text: auth } }),
+ );
+ return data?.email ?? data?.username;
+ },
+});
diff --git a/packages/pieces/community/sender/src/lib/common/ai-props.ts b/packages/pieces/community/sender/src/lib/common/ai-props.ts
new file mode 100644
index 00000000000..2d6ab7af387
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/common/ai-props.ts
@@ -0,0 +1,154 @@
+import { Property } from '@activepieces/pieces-framework';
+
+import type { PropParams } from './props';
+
+function page<R extends boolean>({
+ required,
+ displayName = 'Page',
+ description = 'Page number to return, starting at 1. Defaults to 1. Use the returned `meta.last_page` or `links.next` to know if more pages exist.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function limit<R extends boolean>({
+ required,
+ displayName = 'Limit',
+ description = 'How many records to return per page. Sender applies its own default when empty.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function subscriberId<R extends boolean>({
+ required,
+ displayName = 'Subscriber',
+ description = "The subscriber's email address, phone number (with country code) or Sender subscriber ID. Use List Subscribers to find it.",
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function subscribers<R extends boolean>({
+ required,
+ displayName = 'Subscriber Emails',
+ description = 'List of subscriber email addresses, e.g. ["[email protected]"].',
+}: PropParams<R>) {
+ return Property.Array({ displayName, description, required });
+}
+
+function groupId<R extends boolean>({
+ required,
+ displayName = 'Group ID',
+ description = 'Sender group ID, e.g. "eZVD4w". Use List Groups to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function groups<R extends boolean>({
+ required,
+ displayName = 'Group IDs',
+ description = 'List of Sender group IDs, e.g. ["eZVD4w"]. Use List Groups to find them.',
+}: PropParams<R>) {
+ return Property.Array({ displayName, description, required });
+}
+
+function campaignId<R extends boolean>({
+ required,
+ displayName = 'Campaign ID',
+ description = 'Sender campaign ID, e.g. "eE0x14". Use List Campaigns to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function transactionalCampaignId<R extends boolean>({
+ required,
+ displayName = 'Transactional Campaign ID',
+ description = 'Sender transactional campaign ID. Use List Transactional Campaigns to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function workflowId<R extends boolean>({
+ required,
+ displayName = 'Workflow ID',
+ description = 'Sender workflow ID. Use List Workflows to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function fieldId<R extends boolean>({
+ required,
+ displayName = 'Field ID',
+ description = 'Sender custom field ID. Use List Fields to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function segmentId<R extends boolean>({
+ required,
+ displayName = 'Segment ID',
+ description = 'Sender segment ID. Use List Segments to find it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function yesNo<R extends boolean>({
+ required,
+ displayName,
+ description,
+}: PropParams<R> & { displayName: string }) {
+ return Property.StaticDropdown<string, R>({
+ displayName,
+ description,
+ required,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Yes', value: 'yes' },
+ { label: 'No', value: 'no' },
+ ],
+ },
+ });
+}
+
+function triggerAutomation<R extends boolean>({
+ required,
+ displayName = 'Trigger Automation',
+ description = 'Whether this change starts matching automation workflows. Sender defaults to Yes when empty.',
+}: PropParams<R>) {
+ return yesNo({ required, displayName, description });
+}
+
+function direction<R extends boolean>({
+ required,
+ displayName = 'Sort Direction',
+ description = 'Sort by date, newest first (desc) or oldest first (asc).',
+}: PropParams<R>) {
+ return Property.StaticDropdown<string, R>({
+ displayName,
+ description,
+ required,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Newest first', value: 'desc' },
+ { label: 'Oldest first', value: 'asc' },
+ ],
+ },
+ });
+}
+
+export const senderAiProps = {
+ page,
+ limit,
+ subscriberId,
+ subscribers,
+ groupId,
+ groups,
+ campaignId,
+ transactionalCampaignId,
+ workflowId,
+ fieldId,
+ segmentId,
+ yesNo,
+ triggerAutomation,
+ direction,
+};
diff --git a/packages/pieces/community/sender/src/lib/common/api.ts b/packages/pieces/community/sender/src/lib/common/api.ts
new file mode 100644
index 00000000000..6b587f19c68
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/common/api.ts
@@ -0,0 +1,898 @@
+import { HttpMethod, QueryParams } from '@activepieces/pieces-common';
+
+import { senderClient } from './client';
+
+import type {
+ SenderAuthValue,
+ SenderCampaign,
+ SenderCampaignReport,
+ SenderGroup,
+ SenderPage,
+ SenderRecord,
+ SenderSubscriber,
+ SenderTransactionalReport,
+ SenderUser,
+ SenderWebhook,
+} from './types';
+
+async function getMe({ auth }: { auth: SenderAuthValue }): Promise<SenderUser> {
+ const response = await senderClient.request<{ data: SenderUser }>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/me',
+ });
+ return response.data;
+}
+
+async function listSubscribers({
+ auth,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue }): Promise<SenderPage<SenderSubscriber>> {
+ return await senderClient.request<SenderPage<SenderSubscriber>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/subscribers',
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function getSubscriber({
+ auth,
+ subscriberId,
+}: {
+ auth: SenderAuthValue;
+ subscriberId: string;
+}): Promise<SenderSubscriber & SenderRecord> {
+ const response = await senderClient.request<{ data: SenderSubscriber & SenderRecord }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/subscribers/${encodeURIComponent(subscriberId)}`,
+ });
+ return response.data;
+}
+
+async function upsertSubscriber({
+ auth,
+ email,
+ firstname,
+ lastname,
+ phone,
+ groups,
+ customFields,
+ triggerAutomation,
+}: UpsertSubscriberParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/subscribers',
+ body: {
+ email,
+ firstname,
+ lastname,
+ phone,
+ groups,
+ fields: customFields,
+ trigger_automation: triggerAutomation,
+ },
+ });
+}
+
+async function updateSubscriber({
+ auth,
+ subscriberId,
+ firstname,
+ lastname,
+ phone,
+ groups,
+ customFields,
+ subscriberStatus,
+ smsStatus,
+ transactionalEmailStatus,
+ triggerAutomation,
+}: UpdateSubscriberParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.PATCH,
+ path: `/subscribers/${encodeURIComponent(subscriberId)}`,
+ body: {
+ groups,
+ firstname,
+ lastname,
+ phone,
+ fields: customFields,
+ subscriber_status: subscriberStatus,
+ sms_status: smsStatus,
+ transactional_email_status: transactionalEmailStatus,
+ trigger_automation: triggerAutomation,
+ },
+ });
+}
+
+async function deleteSubscribers({
+ auth,
+ subscribers,
+}: {
+ auth: SenderAuthValue;
+ subscribers: string[];
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: '/subscribers',
+ body: { subscribers },
+ });
+}
+
+async function listSubscriberEvents({
+ auth,
+ subscriberId,
+ actions,
+}: {
+ auth: SenderAuthValue;
+ subscriberId: string;
+ actions: string[];
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/subscribers/${encodeURIComponent(subscriberId)}/events`,
+ query: { actions: JSON.stringify(actions) },
+ });
+}
+
+async function addSubscribersToGroup({
+ auth,
+ groupId,
+ subscribers,
+ triggerAutomation,
+}: GroupMembershipParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: `/subscribers/groups/${groupId}`,
+ body: { subscribers, trigger_automation: triggerAutomation },
+ });
+}
+
+async function removeSubscribersFromGroup({
+ auth,
+ groupId,
+ subscribers,
+ triggerAutomation,
+}: GroupMembershipParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `/subscribers/groups/${groupId}`,
+ body: { subscribers, trigger_automation: triggerAutomation },
+ });
+}
+
+async function createCustomEvent({
+ auth,
+ subscriber,
+ type,
+ value,
+ valueCurrency,
+ properties,
+}: CreateCustomEventParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/events',
+ body: { subscriber, type, value, value_currency: valueCurrency, properties },
+ });
+}
+
+async function listGroups({
+ auth,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue }): Promise<SenderPage<SenderGroup>> {
+ return await senderClient.request<SenderPage<SenderGroup>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/groups',
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function getGroup({
+ auth,
+ groupId,
+}: {
+ auth: SenderAuthValue;
+ groupId: string;
+}): Promise<SenderRecord> {
+ const response = await senderClient.request<{ data: SenderRecord }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/groups/${groupId}`,
+ });
+ return response.data;
+}
+
+async function createGroup({
+ auth,
+ title,
+}: {
+ auth: SenderAuthValue;
+ title: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/groups',
+ body: { title },
+ });
+}
+
+async function renameGroup({
+ auth,
+ groupId,
+ title,
+}: {
+ auth: SenderAuthValue;
+ groupId: string;
+ title: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.PATCH,
+ path: `/groups/${groupId}`,
+ body: { title },
+ });
+}
+
+async function deleteGroup({
+ auth,
+ groupId,
+ deleteSubscribers,
+}: {
+ auth: SenderAuthValue;
+ groupId: string;
+ deleteSubscribers?: boolean;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `/groups/${groupId}`,
+ body: { delete_subscribers: deleteSubscribers },
+ });
+}
+
+async function listGroupSubscribers({
+ auth,
+ groupId,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue; groupId: string }): Promise<SenderPage<SenderSubscriber>> {
+ return await senderClient.request<SenderPage<SenderSubscriber>>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/groups/${groupId}/subscribers`,
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function listFields({
+ auth,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue }): Promise<SenderPage<SenderRecord>> {
+ return await senderClient.request<SenderPage<SenderRecord>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/fields',
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function createField({
+ auth,
+ title,
+ type,
+}: {
+ auth: SenderAuthValue;
+ title: string;
+ type: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/fields',
+ body: { title, type },
+ });
+}
+
+async function updateField({
+ auth,
+ fieldId,
+ title,
+ show,
+}: {
+ auth: SenderAuthValue;
+ fieldId: string;
+ title?: string;
+ show?: boolean;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.PATCH,
+ path: `/fields/${fieldId}`,
+ body: { title, show },
+ });
+}
+
+async function deleteField({
+ auth,
+ fieldId,
+}: {
+ auth: SenderAuthValue;
+ fieldId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `/fields/${fieldId}`,
+ });
+}
+
+async function listSegments({
+ auth,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue }): Promise<SenderPage<SenderRecord>> {
+ return await senderClient.request<SenderPage<SenderRecord>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/segments',
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function getSegment({
+ auth,
+ segmentId,
+}: {
+ auth: SenderAuthValue;
+ segmentId: string;
+}): Promise<SenderRecord> {
+ const response = await senderClient.request<{ data: SenderRecord }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/segments/${segmentId}`,
+ });
+ return response.data;
+}
+
+async function listSegmentSubscribers({
+ auth,
+ segmentId,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue; segmentId: string }): Promise<
+ SenderPage<SenderSubscriber>
+> {
+ return await senderClient.request<SenderPage<SenderSubscriber>>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/segments/${segmentId}/subscribers`,
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function listCampaigns({
+ auth,
+ page,
+ limit,
+ status,
+}: PageParams & { auth: SenderAuthValue; status?: string }): Promise<SenderPage<SenderCampaign>> {
+ return await senderClient.request<SenderPage<SenderCampaign>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/campaigns',
+ query: toQuery({ limit, page, status }),
+ });
+}
+
+async function getCampaign({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ const response = await senderClient.request<{ data: SenderRecord }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/campaigns/${campaignId}`,
+ });
+ return response.data;
+}
+
+async function createCampaign({
+ auth,
+ title,
+ subject,
+ from,
+ replyTo,
+ contentType,
+ groups,
+ segments,
+ preheader,
+ content,
+ googleAnalytics,
+ autoFollowupActive,
+ autoFollowupSubject,
+ autoFollowupDelay,
+}: CreateCampaignParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/campaigns',
+ body: {
+ title,
+ subject,
+ from,
+ content_type: contentType,
+ groups,
+ ...(replyTo ? { reply_to: replyTo } : {}),
+ segments,
+ preheader,
+ content,
+ google_analytics: googleAnalytics,
+ auto_followup_active: autoFollowupActive,
+ auto_followup_subject: autoFollowupSubject,
+ auto_followup_delay: autoFollowupDelay,
+ },
+ });
+}
+
+async function deleteCampaigns({
+ auth,
+ campaignIds,
+}: {
+ auth: SenderAuthValue;
+ campaignIds: string[];
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: '/campaigns',
+ query: { ids: `[${campaignIds.join(',')}]` },
+ });
+}
+
+async function copyCampaign({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: `/campaigns/${campaignId}/copy`,
+ });
+}
+
+async function sendCampaign({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: `/campaigns/${campaignId}/send`,
+ });
+}
+
+async function cancelCampaignSchedule({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `/campaigns/${campaignId}/schedule`,
+ });
+}
+
+async function cancelCampaignFollowup({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: `/campaigns/${campaignId}/cancel_followup`,
+ });
+}
+
+async function listCampaignErrors({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/campaigns/${campaignId}/errors`,
+ });
+}
+
+async function listCampaignReport({
+ auth,
+ campaignId,
+ report,
+ page,
+ limit,
+}: PageParams & {
+ auth: SenderAuthValue;
+ campaignId: string;
+ report: SenderCampaignReport;
+}): Promise<SenderPage<SenderRecord>> {
+ return await senderClient.request<SenderPage<SenderRecord>>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/campaigns/${campaignId}/${report}`,
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function listTransactionalCampaigns({
+ auth,
+ page,
+ limit,
+}: PageParams & { auth: SenderAuthValue }): Promise<SenderPage<SenderRecord>> {
+ return await senderClient.request<SenderPage<SenderRecord>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/transactional',
+ query: toQuery({ page, limit }),
+ });
+}
+
+async function getTransactionalCampaign({
+ auth,
+ campaignId,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ const response = await senderClient.request<{ data: SenderRecord }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/transactional/${campaignId}`,
+ });
+ return response.data;
+}
+
+async function createTransactionalCampaign({
+ auth,
+ title,
+ subject,
+ from,
+ replyTo,
+ editor,
+ preheader,
+ content,
+}: TransactionalCampaignParams & { auth: SenderAuthValue }): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/transactional',
+ body: { title, subject, from, reply_to: replyTo, editor, preheader, content },
+ });
+}
+
+async function updateTransactionalCampaign({
+ auth,
+ campaignId,
+ title,
+ subject,
+ from,
+ replyTo,
+ editor,
+ preheader,
+}: Partial<TransactionalCampaignParams> & {
+ auth: SenderAuthValue;
+ campaignId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.PATCH,
+ path: `/transactional/${campaignId}`,
+ body: { title, subject, from, reply_to: replyTo, editor, preheader },
+ });
+}
+
+async function deleteTransactionalCampaigns({
+ auth,
+ campaignIds,
+}: {
+ auth: SenderAuthValue;
+ campaignIds: string[];
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: '/transactional',
+ query: { ids: `[${campaignIds.join(',')}]` },
+ });
+}
+
+async function getTransactionalCampaignReport({
+ auth,
+ campaignId,
+ from,
+ to,
+ period,
+}: {
+ auth: SenderAuthValue;
+ campaignId: string;
+ from: string;
+ to: string;
+ period: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/transactional/${campaignId}/report`,
+ query: { from, to, period },
+ });
+}
+
+async function listTransactionalReport({
+ auth,
+ campaignId,
+ report,
+ page,
+ limit,
+ direction,
+}: PageParams & {
+ auth: SenderAuthValue;
+ campaignId: string;
+ report: SenderTransactionalReport;
+ direction?: string;
+}): Promise<SenderPage<SenderRecord>> {
+ return await senderClient.request<SenderPage<SenderRecord>>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/transactional/${campaignId}/${report}`,
+ query: toQuery({ page, limit, direction }),
+ });
+}
+
+async function listWorkflows({
+ auth,
+ page,
+ limit,
+ status,
+ title,
+}: PageParams & { auth: SenderAuthValue; status?: string; title?: string }): Promise<
+ SenderPage<SenderRecord>
+> {
+ return await senderClient.request<SenderPage<SenderRecord>>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/workflows',
+ query: toQuery({ page, limit, status, title }),
+ });
+}
+
+async function getWorkflow({
+ auth,
+ workflowId,
+}: {
+ auth: SenderAuthValue;
+ workflowId: string;
+}): Promise<SenderRecord> {
+ const response = await senderClient.request<{ data: SenderRecord }>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/workflows/${workflowId}`,
+ });
+ return response.data;
+}
+
+async function listWorkflowSteps({
+ auth,
+ workflowId,
+ batchNo,
+}: {
+ auth: SenderAuthValue;
+ workflowId: string;
+ batchNo?: number;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/workflows/${workflowId}/steps`,
+ query: toQuery({ batch_no: batchNo }),
+ });
+}
+
+async function getWorkflowStatistics({
+ auth,
+ workflowId,
+}: {
+ auth: SenderAuthValue;
+ workflowId: string;
+}): Promise<SenderRecord> {
+ return await senderClient.request<SenderRecord>({
+ auth,
+ method: HttpMethod.GET,
+ path: `/workflows/${workflowId}/average_report`,
+ });
+}
+
+async function createWebhook({
+ auth,
+ url,
+ topic,
+ relationId,
+}: {
+ auth: SenderAuthValue;
+ url: string;
+ topic: string;
+ relationId?: string;
+}): Promise<SenderWebhook> {
+ const response = await senderClient.request<{ data: SenderWebhook }>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/account/webhooks',
+ body: { url, topic, ...(relationId ? { relation_id: relationId } : {}) },
+ });
+ return response.data;
+}
+
+async function deleteWebhook({
+ auth,
+ webhookId,
+}: {
+ auth: SenderAuthValue;
+ webhookId: string;
+}): Promise<void> {
+ await senderClient.request<unknown>({
+ auth,
+ method: HttpMethod.DELETE,
+ path: `/account/webhooks/${webhookId}`,
+ });
+}
+
+function toQuery(params: Record<string, string | number | undefined>): QueryParams {
+ return Object.fromEntries(
+ Object.entries(params).flatMap(([key, value]) =>
+ value === undefined ? [] : [[key, String(value)]],
+ ),
+ );
+}
+
+export const senderApi = {
+ getMe,
+ listSubscribers,
+ getSubscriber,
+ upsertSubscriber,
+ updateSubscriber,
+ deleteSubscribers,
+ listSubscriberEvents,
+ addSubscribersToGroup,
+ removeSubscribersFromGroup,
+ createCustomEvent,
+ listGroups,
+ getGroup,
+ createGroup,
+ renameGroup,
+ deleteGroup,
+ listGroupSubscribers,
+ listFields,
+ createField,
+ updateField,
+ deleteField,
+ listSegments,
+ getSegment,
+ listSegmentSubscribers,
+ listCampaigns,
+ getCampaign,
+ createCampaign,
+ deleteCampaigns,
+ copyCampaign,
+ sendCampaign,
+ cancelCampaignSchedule,
+ cancelCampaignFollowup,
+ listCampaignErrors,
+ listCampaignReport,
+ listTransactionalCampaigns,
+ getTransactionalCampaign,
+ createTransactionalCampaign,
+ updateTransactionalCampaign,
+ deleteTransactionalCampaigns,
+ getTransactionalCampaignReport,
+ listTransactionalReport,
+ listWorkflows,
+ getWorkflow,
+ listWorkflowSteps,
+ getWorkflowStatistics,
+ createWebhook,
+ deleteWebhook,
+};
+
+type PageParams = { page?: number; limit?: number };
+
+type UpsertSubscriberParams = {
+ email: string;
+ firstname?: string;
+ lastname?: string;
+ phone?: string;
+ groups?: string[];
+ customFields?: unknown;
+ triggerAutomation?: boolean;
+};
+
+type UpdateSubscriberParams = {
+ subscriberId: string;
+ firstname?: string;
+ lastname?: string;
+ phone?: string;
+ groups?: string[];
+ customFields?: unknown;
+ subscriberStatus?: string;
+ smsStatus?: string;
+ transactionalEmailStatus?: string;
+ triggerAutomation?: boolean;
+};
+
+type GroupMembershipParams = {
+ groupId: string | undefined;
+ subscribers: string[];
+ triggerAutomation?: boolean;
+};
+
+type CreateCustomEventParams = {
+ subscriber: { id?: string; email?: string; phone?: string };
+ type: string;
+ value?: number;
+ valueCurrency?: string;
+ properties?: unknown;
+};
+
+type CreateCampaignParams = {
+ title?: string;
+ subject: string;
+ from: string;
+ replyTo: string;
+ contentType: string;
+ groups?: string[];
+ segments?: string[];
+ preheader?: string;
+ content?: string;
+ googleAnalytics?: number;
+ autoFollowupActive?: boolean;
+ autoFollowupSubject?: string;
+ autoFollowupDelay?: number;
+};
+
+type TransactionalCampaignParams = {
+ title?: string;
+ subject: string;
+ from: string;
+ replyTo: string;
+ editor: string;
+ preheader?: string;
+ content?: string;
+};
diff --git a/packages/pieces/community/sender/src/lib/common/client.ts b/packages/pieces/community/sender/src/lib/common/client.ts
new file mode 100644
index 00000000000..3cefcb52888
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/common/client.ts
@@ -0,0 +1,34 @@
+import { HttpMethod, httpClient, QueryParams } from '@activepieces/pieces-common';
+
+import type { SenderAuthValue } from './types';
+
+function baseUrl(): string {
+ return BASE_URL;
+}
+
+async function request<T>({
+ auth,
+ method,
+ path,
+ query,
+ body,
+}: RequestParams & { auth: SenderAuthValue }): Promise<T> {
+ const response = await httpClient.sendRequest<T>({
+ method,
+ url: `${BASE_URL}${path}`,
+ headers: {
+ Authorization: `Bearer ${auth.secret_text}`,
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ },
+ queryParams: query,
+ body,
+ });
+ return response.body;
+}
+
+export const senderClient = { baseUrl, request };
+
+const BASE_URL = 'https://api.sender.net/v2';
+
+type RequestParams = { method: HttpMethod; path: string; query?: QueryParams; body?: unknown };
diff --git a/packages/pieces/community/sender/src/lib/common/common.ts b/packages/pieces/community/sender/src/lib/common/common.ts
deleted file mode 100644
index 56ec7682014..00000000000
--- a/packages/pieces/community/sender/src/lib/common/common.ts
+++ /dev/null
@@ -1,231 +0,0 @@
-import {
- httpClient,
- HttpMethod,
- AuthenticationType,
-} from '@activepieces/pieces-common';
-import { PieceAuth, Property } from '@activepieces/pieces-framework';
-
-export const senderAuth = PieceAuth.SecretText({
- displayName: 'API Token',
- description: 'Enter your Sender API Token',
- required: true,
-});
-
-const SENDER_API_BASE_URL = 'https://api.sender.net/v2';
-
-export async function makeSenderRequest(
- auth: string,
- endpoint: string,
- method: HttpMethod = HttpMethod.GET,
- body?: any
-) {
- return await httpClient.sendRequest({
- method,
- url: `${SENDER_API_BASE_URL}${endpoint}`,
- headers: {
- Authorization: `Bearer ${auth}`,
- 'Content-Type': 'application/json',
- Accept: 'application/json',
- },
- body,
- });
-}
-export const groupIdDropdown = Property.Dropdown({
- auth: senderAuth,
- displayName: 'Groups',
- description: 'Select one or more groups',
- required: false,
- refreshers: [],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Please connect your Sender account first',
- };
- }
-
- try {
- const response: any = await makeSenderRequest(
- auth.secret_text,
- '/groups',
- HttpMethod.GET
- );
- const groups = response.body.data || [];
-
- return {
- disabled: false,
- options: groups.map((group: any) => ({
- label: group.title,
- value: group.id,
- })),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Error loading groups',
- };
- }
- },
-});
-
-export const groupIdsDropdown = Property.MultiSelectDropdown({
- auth: senderAuth,
- displayName: 'Groups',
- description: 'Select one or more groups',
- required: false,
- refreshers: [],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Please connect your Sender account first',
- };
- }
-
- try {
- const response: any = await makeSenderRequest(
- auth.secret_text,
- '/groups',
- HttpMethod.GET
- );
- const groups = response.body.data || [];
-
- return {
- disabled: false,
- options: groups.map((group: any) => ({
- label: group.title,
- value: group.id,
- })),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Error loading groups',
- };
- }
- },
-});
-
-export const subscribersDropdown = Property.MultiSelectDropdown<string, true, typeof senderAuth>({
- auth: senderAuth,
- displayName: 'Subscribers',
- description: 'Select one or more subscribers to delete',
- required: true,
- refreshers: [],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Please connect your Sender account first',
- };
- }
-
- try {
- const response: any = await makeSenderRequest(
- auth.secret_text,
- '/subscribers?limit=50',
- HttpMethod.GET
- );
- const subscribers = response.body.data || [];
-
- return {
- disabled: false,
- options: subscribers.map((sub: any) => ({
- label: sub.email,
- value: sub.email,
- })),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Error loading subscribers',
- };
- }
- },
-});
-
-export const subscriberDropdownSingle = Property.Dropdown<string, true, typeof senderAuth>({
- auth: senderAuth,
- displayName: 'Subscriber',
- description: 'Select a subscriber',
- required: true,
- refreshers: [],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Please connect your Sender account first',
- };
- }
-
- try {
- const response: any = await makeSenderRequest(
- auth.secret_text,
- '/subscribers?limit=50',
- HttpMethod.GET
- );
- const subscribers = response.body.data || [];
-
- return {
- disabled: false,
- options: subscribers.map((sub: any) => ({
- label: sub.email,
- value: sub.email,
- })),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Error loading subscribers',
- };
- }
- },
-});
-
-export const campaignDropdown = Property.Dropdown({
- auth: senderAuth,
- displayName: 'Campaign',
- description: 'Select a campaign',
- required: true,
- refreshers: [],
- options: async ({ auth }) => {
- if (!auth) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Please connect your Sender account first',
- };
- }
-
- try {
- const response: any = await makeSenderRequest(
- auth.secret_text,
- `/campaigns?limit=50&status=DRAFT`,
- HttpMethod.GET
- );
- const campaigns = response.body.data || [];
-
- return {
- disabled: false,
- options: campaigns.map((c: any) => ({
- label: c.title || c.subject || c.id,
- value: c.id,
- })),
- };
- } catch (error) {
- return {
- disabled: true,
- options: [],
- placeholder: 'Error loading campaigns',
- };
- }
- },
-});
diff --git a/packages/pieces/community/sender/src/lib/common/props.ts b/packages/pieces/community/sender/src/lib/common/props.ts
new file mode 100644
index 00000000000..bad60d76122
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/common/props.ts
@@ -0,0 +1,162 @@
+import { DropdownState, Property } from '@activepieces/pieces-framework';
+
+import { senderAuth } from '../auth';
+import { senderApi } from './api';
+
+function groupId<R extends boolean>({
+ required,
+ displayName = 'Groups',
+ description = 'Select one or more groups',
+}: PropParams<R>) {
+ return Property.Dropdown<string, R, typeof senderAuth>({
+ auth: senderAuth,
+ displayName,
+ description,
+ required,
+ refreshers: [],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ try {
+ const { data: groups = [] } = await senderApi.listGroups({ auth });
+ return {
+ disabled: false,
+ options: groups.map((group) => ({ label: group.title, value: group.id })),
+ };
+ } catch (error) {
+ return disabledOptions({ placeholder: 'Error loading groups' });
+ }
+ },
+ });
+}
+
+function groupIds<R extends boolean>({
+ required,
+ displayName = 'Groups',
+ description = 'Select one or more groups',
+}: PropParams<R>) {
+ return Property.MultiSelectDropdown<string, R, typeof senderAuth>({
+ auth: senderAuth,
+ displayName,
+ description,
+ required,
+ refreshers: [],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ try {
+ const { data: groups = [] } = await senderApi.listGroups({ auth });
+ return {
+ disabled: false,
+ options: groups.map((group) => ({ label: group.title, value: group.id })),
+ };
+ } catch (error) {
+ return disabledOptions({ placeholder: 'Error loading groups' });
+ }
+ },
+ });
+}
+
+function subscriber<R extends boolean>({
+ required,
+ displayName = 'Subscriber',
+ description = 'Select a subscriber',
+}: PropParams<R>) {
+ return Property.Dropdown<string, R, typeof senderAuth>({
+ auth: senderAuth,
+ displayName,
+ description,
+ required,
+ refreshers: [],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ try {
+ const { data: subscribers = [] } = await senderApi.listSubscribers({ auth, limit: 50 });
+ return {
+ disabled: false,
+ options: subscribers.map((sub) => ({ label: sub.email, value: sub.email })),
+ };
+ } catch (error) {
+ return disabledOptions({ placeholder: 'Error loading subscribers' });
+ }
+ },
+ });
+}
+
+function subscribers<R extends boolean>({
+ required,
+ displayName = 'Subscribers',
+ description = 'Select one or more subscribers to delete',
+}: PropParams<R>) {
+ return Property.MultiSelectDropdown<string, R, typeof senderAuth>({
+ auth: senderAuth,
+ displayName,
+ description,
+ required,
+ refreshers: [],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ try {
+ const { data: subscribers = [] } = await senderApi.listSubscribers({ auth, limit: 50 });
+ return {
+ disabled: false,
+ options: subscribers.map((sub) => ({ label: sub.email, value: sub.email })),
+ };
+ } catch (error) {
+ return disabledOptions({ placeholder: 'Error loading subscribers' });
+ }
+ },
+ });
+}
+
+function campaignId<R extends boolean>({
+ required,
+ displayName = 'Campaign',
+ description = 'Select a campaign',
+}: PropParams<R>) {
+ return Property.Dropdown<string, R, typeof senderAuth>({
+ auth: senderAuth,
+ displayName,
+ description,
+ required,
+ refreshers: [],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ try {
+ const { data: campaigns = [] } = await senderApi.listCampaigns({
+ auth,
+ limit: 50,
+ status: 'DRAFT',
+ });
+ return {
+ disabled: false,
+ options: campaigns.map((c) => ({ label: c.title || c.subject || c.id, value: c.id })),
+ };
+ } catch (error) {
+ return disabledOptions({ placeholder: 'Error loading campaigns' });
+ }
+ },
+ });
+}
+
+function disabledOptions({ placeholder }: { placeholder: string }): DropdownState<never> {
+ return { disabled: true, options: [], placeholder };
+}
+
+export const senderProps = { groupId, groupIds, subscriber, subscribers, campaignId };
+
+const NOT_CONNECTED = 'Please connect your Sender account first';
+
+export type PropParams<R extends boolean> = {
+ required: R;
+ displayName?: string;
+ description?: string;
+};
diff --git a/packages/pieces/community/sender/src/lib/common/types.ts b/packages/pieces/community/sender/src/lib/common/types.ts
new file mode 100644
index 00000000000..9855afa523b
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/common/types.ts
@@ -0,0 +1,36 @@
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+export type SenderAuthValue = { type: AppConnectionType.SECRET_TEXT; secret_text: string };
+
+export type SenderGroup = { id: string; title: string };
+export type SenderSubscriber = {
+ id?: string;
+ email: string;
+ firstname?: string | null;
+ lastname?: string | null;
+};
+export type SenderCampaign = { id: string; title?: string; subject?: string };
+export type SenderWebhook = { id: string };
+export type SenderUser = {
+ id: string;
+ email?: string;
+ username?: string;
+ name?: string;
+ surname?: string;
+};
+export type SenderRecord = Record<string, unknown>;
+export type SenderPage<T> = {
+ data?: T[];
+ links?: Record<string, string | null>;
+ meta?: SenderRecord;
+ has_more_resources?: boolean;
+};
+export type SenderCampaignReport =
+ | 'opens'
+ | 'clicks'
+ | 'unsubscribes'
+ | 'hard_bounces'
+ | 'soft_bounces'
+ | 'complaints'
+ | 'emails-sent';
+export type SenderTransactionalReport = 'sent' | 'opens' | 'clicks' | 'bounces' | 'complaints';
diff --git a/packages/pieces/community/sender/src/lib/common/utils.ts b/packages/pieces/community/sender/src/lib/common/utils.ts
new file mode 100644
index 00000000000..ef5ecc912da
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/common/utils.ts
@@ -0,0 +1,38 @@
+function optionalStringList({
+ value,
+ propName,
+}: {
+ value: unknown[] | undefined;
+ propName: string;
+}): string[] | undefined {
+ if (value === undefined) {
+ return undefined;
+ }
+ if (!value.every((item): item is string => typeof item === 'string' && item !== '')) {
+ throw new Error(`${propName} must be a list of non-empty strings.`);
+ }
+ return value;
+}
+
+function requiredStringList({
+ value,
+ propName,
+}: {
+ value: unknown[] | undefined;
+ propName: string;
+}): string[] {
+ const list = optionalStringList({ value, propName });
+ if (list === undefined || list.length === 0) {
+ throw new Error(`${propName} must contain at least one item.`);
+ }
+ return list;
+}
+
+function yesNoToBoolean(value: string | undefined): boolean | undefined {
+ if (value !== 'yes' && value !== 'no') {
+ return undefined;
+ }
+ return value === 'yes';
+}
+
+export const senderUtils = { optionalStringList, requiredStringList, yesNoToBoolean };
diff --git a/packages/pieces/community/sender/src/lib/output-schemas.ts b/packages/pieces/community/sender/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..dc8c7f68b16
--- /dev/null
+++ b/packages/pieces/community/sender/src/lib/output-schemas.ts
@@ -0,0 +1,806 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const pageLinksField: OutputSchema['fields'][number] = {
+ key: 'links',
+ label: 'Page Links',
+ children: [
+ { key: 'first', label: 'First Page URL', format: 'url' },
+ { key: 'last', label: 'Last Page URL', format: 'url' },
+ { key: 'prev', label: 'Previous Page URL', format: 'url' },
+ { key: 'next', label: 'Next Page URL', format: 'url' },
+ ],
+};
+
+const pageMetaField: OutputSchema['fields'][number] = {
+ key: 'meta',
+ label: 'Pagination',
+ children: [
+ { key: 'current_page', label: 'Current Page', format: 'number' },
+ { key: 'last_page', label: 'Last Page', format: 'number' },
+ { key: 'per_page', label: 'Per Page', format: 'number' },
+ { key: 'from', label: 'From Item', format: 'number' },
+ { key: 'to', label: 'To Item', format: 'number' },
+ { key: 'total', label: 'Total', format: 'number' },
+ ],
+};
+
+const hasMoreField: OutputSchema['fields'][number] = {
+ key: 'has_more_resources',
+ label: 'Has More Pages',
+ format: 'boolean',
+};
+
+const subscriberStatusField: OutputSchema['fields'][number] = {
+ key: 'status',
+ label: 'Status',
+ children: [
+ { key: 'email', label: 'Email Status' },
+ { key: 'temail', label: 'Transactional Email Status' },
+ { key: 'sms', label: 'SMS Status' },
+ { key: 'tsms', label: 'Transactional SMS Status' },
+ ],
+};
+
+const subscriberGroupsField: OutputSchema['fields'][number] = {
+ key: 'subscriber_tags',
+ label: 'Groups',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Group ID' },
+ { key: 'title', label: 'Group Title' },
+ ],
+};
+
+const subscriberFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Subscriber ID' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'firstname', label: 'First Name' },
+ { key: 'lastname', label: 'Last Name' },
+ { key: 'phone', label: 'Phone' },
+ {
+ key: 'phone_country',
+ label: 'Phone Country',
+ children: [
+ { key: 'country_code', label: 'Country Code' },
+ { key: 'phone_code', label: 'Phone Code', format: 'number' },
+ ],
+ },
+ subscriberStatusField,
+ subscriberGroupsField,
+ {
+ key: 'columns',
+ label: 'Fields',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Field ID' },
+ { key: 'title', label: 'Field Title' },
+ { key: 'type', label: 'Field Type' },
+ { key: 'value', label: 'Value' },
+ ],
+ },
+ { key: 'source', label: 'Source' },
+ { key: 'ip_address', label: 'IP Address' },
+ { key: 'location', label: 'Location' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'created_utc', label: 'Created (UTC)', format: 'datetime' },
+ { key: 'bounced_at', label: 'Bounced At', format: 'datetime' },
+ { key: 'bounced_at_utc', label: 'Bounced At (UTC)', format: 'datetime' },
+ { key: 'unsubscribed_at', label: 'Unsubscribed At', format: 'datetime' },
+ { key: 'unsubscribed_at_utc', label: 'Unsubscribed At (UTC)', format: 'datetime' },
+];
+
+const memberFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Subscriber ID' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'firstname', label: 'First Name' },
+ { key: 'lastname', label: 'Last Name' },
+ { key: 'phone', label: 'Phone' },
+ {
+ key: 'phone_country',
+ label: 'Phone Country',
+ children: [
+ { key: 'code', label: 'Country Code' },
+ { key: 'name', label: 'Country' },
+ { key: 'phone_code', label: 'Phone Code', format: 'number' },
+ ],
+ },
+ subscriberStatusField,
+ subscriberGroupsField,
+ {
+ key: 'columns',
+ label: 'Fields',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Field ID' },
+ { key: 'title', label: 'Field Title' },
+ { key: 'type', label: 'Field Type' },
+ { key: 'default', label: 'Default Field', format: 'boolean' },
+ { key: 'value', label: 'Value' },
+ ],
+ },
+ { key: 'source', label: 'Source' },
+ { key: 'ip_address', label: 'IP Address' },
+ { key: 'location', label: 'Location' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'bounced_at', label: 'Bounced At', format: 'datetime' },
+ { key: 'unsubscribed_at', label: 'Unsubscribed At', format: 'datetime' },
+];
+
+const webhookSubscriberFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Subscriber ID' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'firstname', label: 'First Name' },
+ { key: 'lastname', label: 'Last Name' },
+ { key: 'phone', label: 'Phone' },
+ { key: 'phone_country', label: 'Phone Country' },
+ {
+ key: 'status',
+ label: 'Status',
+ children: [
+ { key: 'email', label: 'Email Status' },
+ { key: 'temail', label: 'Transactional Email Status' },
+ ],
+ },
+ subscriberGroupsField,
+ {
+ key: 'columns',
+ label: 'Fields',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Field ID' },
+ { key: 'title', label: 'Field Title' },
+ { key: 'type', label: 'Field Type' },
+ { key: 'default', label: 'Default Field', format: 'boolean' },
+ { key: 'value', label: 'Value' },
+ ],
+ },
+ { key: 'source', label: 'Source' },
+ { key: 'ip_address', label: 'IP Address' },
+ { key: 'location', label: 'Location' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'bounced_at', label: 'Bounced At', format: 'datetime' },
+ { key: 'unsubscribed_at', label: 'Unsubscribed At', format: 'datetime' },
+];
+
+const groupFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Group ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'recipient_count', label: 'Recipient Count', format: 'number' },
+ { key: 'active_subscribers', label: 'Active Subscribers', format: 'number' },
+ { key: 'unsubscribed_count', label: 'Unsubscribed Count', format: 'number' },
+ { key: 'bounced_count', label: 'Bounced Count', format: 'number' },
+ { key: 'phone_count', label: 'Phone Count', format: 'number' },
+ { key: 'active_phone_count', label: 'Active Phone Count', format: 'number' },
+ { key: 'is_recalculating_subscribers', label: 'Recalculating Subscribers', format: 'boolean' },
+ { key: 'is_favourite', label: 'Favourite', format: 'boolean' },
+ { key: 'used_in_integration', label: 'Used in Integration', format: 'boolean' },
+ { key: 'account_id', label: 'Account ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+];
+
+const fieldFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Field ID' },
+ { key: 'title', label: 'Title' },
+ {
+ key: 'name',
+ label: 'Name',
+ description: 'Merge name like {{company}}; write values with the key {$company}.',
+ },
+ { key: 'type', label: 'Type' },
+ { key: 'show', label: 'Shown in Dashboard', format: 'boolean' },
+ { key: 'default', label: 'Default Field', format: 'boolean' },
+ { key: 'default_value', label: 'Default Value' },
+ { key: 'position', label: 'Position', format: 'number' },
+ { key: 'options', label: 'Options' },
+ { key: 'account_id', label: 'Account ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+];
+
+const segmentFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Segment ID' },
+ { key: 'name', label: 'Name' },
+ {
+ key: 'conditions',
+ label: 'Conditions',
+ children: [
+ { key: 'match', label: 'Match' },
+ {
+ key: 'condition_sets',
+ label: 'Condition Sets',
+ listItems: [
+ { key: 'match', label: 'Match' },
+ {
+ key: 'conditions',
+ label: 'Conditions',
+ listItems: [
+ { key: 'type', label: 'Type' },
+ { key: 'operator', label: 'Operator' },
+ { key: 'value', label: 'Value' },
+ ],
+ },
+ ],
+ },
+ ],
+ },
+ { key: 'recipient_count', label: 'Recipient Count', format: 'number' },
+ { key: 'active_subscribers', label: 'Active Subscribers', format: 'number' },
+ { key: 'unsubscribed_count', label: 'Unsubscribed Count', format: 'number' },
+ { key: 'bounced_count', label: 'Bounced Count', format: 'number' },
+ { key: 'phone_count', label: 'Phone Count', format: 'number' },
+ { key: 'active_phone_count', label: 'Active Phone Count', format: 'number' },
+ { key: 'subscribers', label: 'Subscribers' },
+ { key: 'counter_calculated_at', label: 'Counts Calculated At', format: 'datetime' },
+ { key: 'is_recalculating_subscribers', label: 'Recalculating Subscribers', format: 'boolean' },
+ { key: 'is_favourite', label: 'Favourite', format: 'boolean' },
+ { key: 'account_id', label: 'Account ID' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+];
+
+const campaignHtmlField: OutputSchema['fields'][number] = {
+ key: 'html',
+ label: 'Content',
+ children: [
+ { key: 'id', label: 'Content ID' },
+ { key: 'html_content', label: 'HTML', format: 'html' },
+ { key: 'html_body', label: 'HTML Body', format: 'html' },
+ { key: 'thumbnail_url', label: 'Thumbnail', format: 'image' },
+ { key: 'has_preview', label: 'Has Preview', format: 'boolean' },
+ { key: 'has_snapshots', label: 'Has Snapshots', format: 'boolean' },
+ { key: 'version', label: 'Version', format: 'number' },
+ ],
+};
+
+const campaignFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Campaign ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'subject', label: 'Subject' },
+ { key: 'from', label: 'From Name' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ { key: 'preheader', label: 'Preheader' },
+ { key: 'status', label: 'Status' },
+ { key: 'editor', label: 'Editor' },
+ { key: 'language', label: 'Language' },
+ { key: 'last_action', label: 'Last Action' },
+ { key: 'schedule_time', label: 'Scheduled For', format: 'datetime' },
+ { key: 'sent_time', label: 'Sent At', format: 'datetime' },
+ { key: 'recipient_count', label: 'Recipient Count', format: 'number' },
+ { key: 'sent_count', label: 'Sent Count', format: 'number' },
+ { key: 'opens', label: 'Opens', format: 'number' },
+ { key: 'clicks', label: 'Clicks', format: 'number' },
+ { key: 'bounces_count', label: 'Bounces', format: 'number' },
+ {
+ key: 'reports',
+ label: 'Rates',
+ children: [
+ { key: 'spam_percentage', label: 'Spam %', format: 'number' },
+ { key: 'hard_bounce_percentage', label: 'Hard Bounce %', format: 'number' },
+ { key: 'unsubscribe_percentage', label: 'Unsubscribe %', format: 'number' },
+ ],
+ },
+ { key: 'campaign_groups', label: 'Group IDs' },
+ { key: 'segments', label: 'Segment IDs' },
+ { key: 'send_to_all', label: 'Send to All', format: 'number' },
+ { key: 'auto_followup_active', label: 'Auto Follow-up Active' },
+ { key: 'auto_followup_subject', label: 'Auto Follow-up Subject' },
+ { key: 'auto_followup_delay', label: 'Auto Follow-up Delay (hours)' },
+ { key: 'ecommerce_tracking_enabled', label: 'Ecommerce Tracking' },
+ { key: 'experiment_id', label: 'Experiment ID' },
+ { key: 'domain_id', label: 'Domain ID' },
+ campaignHtmlField,
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+];
+
+const transactionalCampaignFields: OutputSchema['fields'] = [
+ { key: 'id', label: 'Transactional Campaign ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'subject', label: 'Subject' },
+ { key: 'from', label: 'From Name' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ { key: 'preheader', label: 'Preheader' },
+ { key: 'type', label: 'Type' },
+ { key: 'editor', label: 'Editor' },
+ { key: 'last_action', label: 'Last Action' },
+ { key: 'disable_click_tracking', label: 'Click Tracking Disabled', format: 'boolean' },
+ {
+ key: 'html',
+ label: 'Content',
+ children: [
+ { key: 'id', label: 'Content ID' },
+ { key: 'thumbnail_url', label: 'Thumbnail', format: 'image' },
+ { key: 'has_preview', label: 'Has Preview', format: 'boolean' },
+ { key: 'has_snapshots', label: 'Has Snapshots', format: 'boolean' },
+ { key: 'styles', label: 'Styles' },
+ ],
+ },
+ { key: 'domain_id', label: 'Domain ID' },
+ { key: 'account_id', label: 'Account ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+];
+
+const transactionalStatsFields: OutputSchema['fields'] = [
+ { key: 'sent', label: 'Sent', format: 'number' },
+ { key: 'opens', label: 'Opens', format: 'number' },
+ { key: 'clicks', label: 'Clicks', format: 'number' },
+ { key: 'bounced', label: 'Bounced', format: 'number' },
+ { key: 'unsubscribeCount', label: 'Unsubscribes', format: 'number' },
+];
+
+const channelStatusField: OutputSchema['fields'][number] = {
+ key: 'channel_status',
+ label: 'Status Changes',
+ labelKey: 'type',
+ listItems: [
+ { key: 'type', label: 'Change' },
+ { key: 'source', label: 'Source' },
+ { key: 'user', label: 'Changed By', format: 'email' },
+ { key: 'created_at', label: 'Changed At', format: 'datetime' },
+ ],
+};
+
+const removeResultField: OutputSchema['fields'][number] = {
+ key: 'message',
+ label: 'Result',
+ children: [
+ { key: 'subscribers_remove_tag_group', label: 'Removed' },
+ { key: 'subscribers_without_group_already', label: 'Not in Group' },
+ { key: 'non_existing_subscribers', label: 'Not Found' },
+ { key: 'invalid_emails', label: 'Invalid Emails' },
+ ],
+};
+
+export const senderSuccessOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'message', label: 'Message' },
+ ],
+};
+
+export const senderSubscriberWriteOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'message', label: 'Message', children: [{ key: 'text', label: 'Text' }] },
+ { key: 'data', label: 'Subscriber', children: subscriberFields },
+ ],
+};
+
+export const senderSubscriberUpsertOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ {
+ key: 'message',
+ label: 'Message',
+ children: [
+ { key: 'text', label: 'Text' },
+ {
+ key: 'warnings',
+ label: 'Warnings',
+ dynamicKey: true,
+ description: 'Per-field warnings, e.g. a custom field key that does not exist.',
+ },
+ ],
+ },
+ { key: 'data', label: 'Subscriber', children: subscriberFields },
+ ],
+};
+
+export const senderGetSubscriberOutputSchema: OutputSchema = {
+ fields: subscriberFields,
+};
+
+export const senderListSubscribersOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Subscribers', labelKey: 'email', listItems: subscriberFields },
+ pageMetaField,
+ ],
+};
+
+export const senderDeleteSubscribersOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'message', label: 'Message' },
+ { key: 'delete_instance', label: 'Delete Job' },
+ ],
+};
+
+export const senderAddSubscribersToGroupOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ {
+ key: 'message',
+ label: 'Result',
+ children: [
+ { key: 'subscribers_add_tag_group', label: 'Added' },
+ { key: 'subscribers_with_group_already', label: 'Already in Group' },
+ { key: 'non_existing_subscribers', label: 'Not Found' },
+ { key: 'invalid_emails', label: 'Invalid Emails' },
+ ],
+ },
+ ],
+};
+
+export const senderRemoveSubscribersFromGroupOutputSchema: OutputSchema = {
+ fields: [{ key: 'success', label: 'Success', format: 'boolean' }, removeResultField],
+};
+
+export const senderRemoveSubscriberFromGroupOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'subscribers', label: 'Subscribers' },
+ { key: 'groupId', label: 'Group ID' },
+ { key: 'removedAt', label: 'Removed At', format: 'datetime' },
+ {
+ key: 'response',
+ label: 'Response',
+ children: [{ key: 'success', label: 'Success', format: 'boolean' }, removeResultField],
+ },
+ ],
+};
+
+export const senderListSubscriberEventsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'email',
+ label: 'Email Campaigns',
+ children: [
+ { key: 'got', label: 'Received' },
+ { key: 'opened', label: 'Opened' },
+ { key: 'clicked', label: 'Clicked' },
+ { key: 'bounced', label: 'Bounced' },
+ { key: 'unsubscribed', label: 'Unsubscribed' },
+ channelStatusField,
+ ],
+ },
+ {
+ key: 'temail',
+ label: 'Transactional Email',
+ children: [
+ { key: 'got', label: 'Received' },
+ { key: 'opened', label: 'Opened' },
+ { key: 'clicked', label: 'Clicked' },
+ { key: 'bounced', label: 'Bounced' },
+ { key: 'unsubscribed', label: 'Unsubscribed' },
+ channelStatusField,
+ ],
+ },
+ {
+ key: 'sms',
+ label: 'SMS',
+ children: [
+ { key: 'clicked', label: 'Clicked' },
+ { key: 'unsubscribed', label: 'Unsubscribed' },
+ channelStatusField,
+ ],
+ },
+ {
+ key: 'tsms',
+ label: 'Transactional SMS',
+ children: [
+ { key: 'clicked', label: 'Clicked' },
+ { key: 'unsubscribed', label: 'Unsubscribed' },
+ channelStatusField,
+ ],
+ },
+ {
+ key: 'email_campaign',
+ label: 'Email Totals',
+ children: [
+ { key: 'sent_count', label: 'Sent', format: 'number' },
+ { key: 'opened_count', label: 'Opened', format: 'number' },
+ { key: 'clicked_count', label: 'Clicked', format: 'number' },
+ { key: 'bounced', label: 'Bounced', format: 'number' },
+ { key: 'spam_reported', label: 'Spam Reported', format: 'number' },
+ { key: 'unsubscribed', label: 'Unsubscribed', format: 'number' },
+ { key: 'unsubscribed_at', label: 'Unsubscribed At', format: 'datetime' },
+ ],
+ },
+ {
+ key: 'sms_campaign',
+ label: 'SMS Totals',
+ children: [
+ { key: 'sent_count', label: 'Sent', format: 'number' },
+ { key: 'delivered_count', label: 'Delivered', format: 'number' },
+ { key: 'failed_count', label: 'Failed', format: 'number' },
+ { key: 'clicked_count', label: 'Clicked', format: 'number' },
+ { key: 'unsubscribed', label: 'Unsubscribed', format: 'number' },
+ { key: 'unsubscribed_at', label: 'Unsubscribed At', format: 'datetime' },
+ ],
+ },
+ { key: 'custom_events', label: 'Custom Events' },
+ { key: 'store', label: 'Store Activity' },
+ { key: 'site_visits', label: 'Site Visits' },
+ { key: 'subscriber_changes', label: 'Profile Changes' },
+ ],
+};
+
+export const senderSubscriberTriggerOutputSchema: OutputSchema = {
+ fields: webhookSubscriberFields,
+};
+
+export const senderGroupWriteOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'message', label: 'Message' },
+ { key: 'data', label: 'Group', children: groupFields },
+ ],
+};
+
+export const senderGetGroupOutputSchema: OutputSchema = {
+ fields: groupFields,
+};
+
+export const senderListGroupsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Groups', labelKey: 'title', listItems: groupFields },
+ pageLinksField,
+ pageMetaField,
+ ],
+};
+
+export const senderListMembersOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Subscribers', labelKey: 'email', listItems: memberFields },
+ pageLinksField,
+ pageMetaField,
+ ],
+};
+
+export const senderFieldWriteOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'message', label: 'Message' },
+ { key: 'data', label: 'Field', children: fieldFields },
+ ],
+};
+
+export const senderListFieldsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Fields', labelKey: 'title', listItems: fieldFields },
+ pageLinksField,
+ pageMetaField,
+ ],
+};
+
+export const senderGetSegmentOutputSchema: OutputSchema = {
+ fields: segmentFields,
+};
+
+export const senderListSegmentsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Segments', labelKey: 'name', listItems: segmentFields },
+ pageLinksField,
+ pageMetaField,
+ ],
+};
+
+export const senderCampaignWriteOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'success', label: 'Success', format: 'boolean' },
+ { key: 'message', label: 'Message' },
+ { key: 'data', label: 'Campaign', children: campaignFields },
+ ],
+};
+
+export const senderGetCampaignOutputSchema: OutputSchema = {
+ fields: campaignFields,
+};
+
+export const senderListCampaignsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'data', label: 'Campaigns', labelKey: 'title', listItems: campaignFields },
+ pageLinksField,
+ pageMetaField,
+ hasMoreField,
+ ],
+};
+
+export const senderListCampaignErrorsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'errors',
+ label: 'Errors',
+ labelKey: 'title',
+ listItems: [
+ { key: 'title', label: 'Title' },
+ { key: 'details', label: 'Details' },
+ { key: 'route', label: 'Where to Fix' },
+ ],
+ },
+ { key: 'warnings', label: 'Warnings' },
+ ],
+};
+
+export const senderReportPageOutputSchema: OutputSchema = {
+ fields: [{ key: 'data', label: 'Records' }, pageLinksField, pageMetaField],
+};
+
+export const senderTransactionalCampaignWriteOutputSchema: OutputSchema = {
+ fields: [{ key: 'data', label: 'Transactional Campaign', children: transactionalCampaignFields }],
+};
+
+export const senderGetTransactionalCampaignOutputSchema: OutputSchema = {
+ fields: [...transactionalCampaignFields, ...transactionalStatsFields],
+};
+
+export const senderListTransactionalCampaignsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'data',
+ label: 'Transactional Campaigns',
+ labelKey: 'title',
+ listItems: [...transactionalCampaignFields, ...transactionalStatsFields],
+ },
+ pageLinksField,
+ pageMetaField,
+ hasMoreField,
+ ],
+};
+
+export const senderGetTransactionalCampaignReportOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'totals',
+ label: 'Totals',
+ children: [
+ { key: 'sent_total', label: 'Sent', format: 'number' },
+ { key: 'opens_total', label: 'Opens', format: 'number' },
+ { key: 'clicks_total', label: 'Clicks', format: 'number' },
+ { key: 'bounces_total', label: 'Bounces', format: 'number' },
+ { key: 'soft_bounces_total', label: 'Soft Bounces', format: 'number' },
+ { key: 'hard_bounces_total', label: 'Hard Bounces', format: 'number' },
+ { key: 'unsubscribes_total', label: 'Unsubscribes', format: 'number' },
+ { key: 'complaints_total', label: 'Complaints', format: 'number' },
+ ],
+ },
+ { key: 'sent', label: 'Sent per Period' },
+ { key: 'opens', label: 'Opens per Period' },
+ { key: 'clicks', label: 'Clicks per Period' },
+ { key: 'bounces', label: 'Bounces per Period' },
+ { key: 'soft_bounces', label: 'Soft Bounces per Period' },
+ { key: 'hard_bounces', label: 'Hard Bounces per Period' },
+ { key: 'unsubscribes', label: 'Unsubscribes per Period' },
+ { key: 'complaints', label: 'Complaints per Period' },
+ ],
+};
+
+export const senderGetWorkflowOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'id', label: 'Workflow ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'description', label: 'Description' },
+ { key: 'status', label: 'Status' },
+ { key: 'type', label: 'Type' },
+ { key: 'emails_sent', label: 'Emails Sent', format: 'number' },
+ {
+ key: 'report',
+ label: 'Report',
+ children: [
+ { key: 'sent_count', label: 'Sent', format: 'number' },
+ { key: 'finished_recipient_count', label: 'Finished Recipients', format: 'number' },
+ ],
+ },
+ { key: 'index_report', label: 'Summary' },
+ { key: 'thumbnail', label: 'Thumbnail', format: 'image' },
+ { key: 'workflow_category_id', label: 'Category ID' },
+ { key: 'account_id', label: 'Account ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+ ],
+};
+
+export const senderListWorkflowsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'data',
+ label: 'Workflows',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Workflow ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'description', label: 'Description' },
+ { key: 'status', label: 'Status' },
+ { key: 'type', label: 'Type' },
+ { key: 'emails_sent', label: 'Emails Sent', format: 'number' },
+ {
+ key: 'index_report',
+ label: 'Summary',
+ children: [
+ { key: 'emails_sent', label: 'Emails Sent', format: 'number' },
+ { key: 'opens', label: 'Opens', format: 'number' },
+ { key: 'clicks', label: 'Clicks', format: 'number' },
+ ],
+ },
+ { key: 'report', label: 'Report' },
+ { key: 'thumbnail', label: 'Thumbnail', format: 'image' },
+ { key: 'workflow_category_id', label: 'Category ID' },
+ { key: 'account_id', label: 'Account ID' },
+ { key: 'user_id', label: 'User ID' },
+ { key: 'created', label: 'Created', format: 'datetime' },
+ { key: 'modified', label: 'Modified', format: 'datetime' },
+ ],
+ },
+ pageLinksField,
+ pageMetaField,
+ hasMoreField,
+ ],
+};
+
+export const senderGetWorkflowStatisticsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'subscribers_in_workflow', label: 'Subscribers in Workflow', format: 'number' },
+ { key: 'completed_count', label: 'Completed', format: 'number' },
+ { key: 'total_emails_sent', label: 'Emails Sent', format: 'number' },
+ { key: 'average_open_rate', label: 'Average Open Rate', format: 'number' },
+ { key: 'average_click_rate', label: 'Average Click Rate', format: 'number' },
+ { key: 'average_unsub_rate', label: 'Average Unsubscribe Rate', format: 'number' },
+ { key: 'average_bounce_rate', label: 'Average Bounce Rate', format: 'number' },
+ { key: 'average_complaints_rate', label: 'Average Complaint Rate', format: 'number' },
+ ],
+};
+
+export const senderListWorkflowStepsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'data',
+ label: 'Steps',
+ labelKey: 'title',
+ listItems: [
+ { key: 'id', label: 'Step ID' },
+ { key: 'parent_id', label: 'Parent Step ID' },
+ { key: 'workflow_id', label: 'Workflow ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'type', label: 'Type' },
+ { key: 'trigger_type', label: 'Trigger Type' },
+ { key: 'trigger_time', label: 'Trigger Time' },
+ {
+ key: 'trigger_definition',
+ label: 'Trigger',
+ children: [
+ { key: 'triggerType', label: 'Trigger Type' },
+ { key: 'listId', label: 'Group ID' },
+ { key: 'listTitle', label: 'Group Title' },
+ ],
+ },
+ { key: 'delay_amount', label: 'Delay Amount', format: 'number' },
+ { key: 'delay_type', label: 'Delay Unit' },
+ { key: 'delay_definition', label: 'Delay' },
+ { key: 'condition_definition', label: 'Condition' },
+ { key: 'condition_path', label: 'Condition Path' },
+ { key: 'action_definition', label: 'Action' },
+ { key: 'transactional_campaign_id', label: 'Email ID' },
+ {
+ key: 'transactional_campaign',
+ label: 'Email',
+ children: [
+ { key: 'id', label: 'Email ID' },
+ { key: 'title', label: 'Title' },
+ { key: 'subject', label: 'Subject' },
+ { key: 'from', label: 'From Name' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ { key: 'preheader', label: 'Preheader' },
+ { key: 'editor', label: 'Editor' },
+ { key: 'type', label: 'Type' },
+ { key: 'language', label: 'Language' },
+ { key: 'used_variables', label: 'Used Variables' },
+ ],
+ },
+ { key: 'sms_campaign_id', label: 'SMS ID' },
+ { key: 'sms_campaign', label: 'SMS' },
+ { key: 'emails_sent', label: 'Emails Sent', format: 'number' },
+ { key: 'active_subscribers_count', label: 'Active Subscribers', format: 'number' },
+ { key: 'complete', label: 'Complete', format: 'number' },
+ { key: 'thumbnail_url', label: 'Thumbnail', format: 'image' },
+ { key: 'created_at_utc', label: 'Created (UTC)', format: 'datetime' },
+ { key: 'updated_at_utc', label: 'Updated (UTC)', format: 'datetime' },
+ ],
+ },
+ ],
+};
diff --git a/packages/pieces/community/sender/src/lib/triggers/new-campaign.ts b/packages/pieces/community/sender/src/lib/triggers/new-campaign.ts
index dd85687dae0..7a12ed2d074 100644
--- a/packages/pieces/community/sender/src/lib/triggers/new-campaign.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/new-campaign.ts
@@ -1,7 +1,9 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+const TOPIC = 'campaigns/new';
+const STORE_KEY = 'webhookId';
export const newCampaignTrigger = createTrigger({
auth: senderAuth,
@@ -15,45 +17,26 @@ export const newCampaignTrigger = createTrigger({
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
- const webhookData = {
- url: webhookUrl,
- topic : 'campaigns/new',
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
async test(context) {
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/campaigns?limit=1',
- HttpMethod.GET
- );
- return response.body.data || [];
+ const page = await senderApi.listCampaigns({ auth: context.auth, limit: 1 });
+ return page.data ?? [];
},
sampleData: {},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/triggers/new-group.ts b/packages/pieces/community/sender/src/lib/triggers/new-group.ts
index 56ff7746b24..ffbdf79b560 100644
--- a/packages/pieces/community/sender/src/lib/triggers/new-group.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/new-group.ts
@@ -1,7 +1,9 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+const TOPIC = 'groups/new';
+const STORE_KEY = 'webhookId';
export const newGroupTrigger = createTrigger({
auth: senderAuth,
@@ -15,45 +17,26 @@ export const newGroupTrigger = createTrigger({
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
-
- const webhookData = {
- url: webhookUrl,
- topic : 'groups/new',
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
async test(context) {
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/groups?limit=1',
- HttpMethod.GET
- );
- return response.body.data || [];
+ const page = await senderApi.listGroups({ auth: context.auth, limit: 1 });
+ return page.data ?? [];
},
sampleData: {},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/triggers/new-subscriber-in-group.ts b/packages/pieces/community/sender/src/lib/triggers/new-subscriber-in-group.ts
index f508d33d261..6590f682230 100644
--- a/packages/pieces/community/sender/src/lib/triggers/new-subscriber-in-group.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/new-subscriber-in-group.ts
@@ -1,11 +1,15 @@
import { createTrigger, Property, TriggerStrategy } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderSubscriberTriggerOutputSchema } from '../output-schemas';
+const TOPIC = 'groups/new-subscriber';
+const STORE_KEY = 'webhookId';
export const newSubscriberInGroupTrigger = createTrigger({
auth: senderAuth,
name: 'new_subscriber_in_group',
+ outputSchema: senderSubscriberTriggerOutputSchema,
classification: 'READ',
displayName: 'New Subscriber in Group',
description: 'Fires when a subscriber is added to a specific group/list',
@@ -21,47 +25,27 @@ export const newSubscriberInGroupTrigger = createTrigger({
}),
},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
- const groupId = context.propsValue.groupId;
-
- const webhookData = {
- url: webhookUrl,
- topic : 'groups/new-subscriber',
- relation_id : groupId,
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ relationId: context.propsValue.groupId,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
async test(context) {
- const groupId = context.propsValue.groupId;
- const response = await makeSenderRequest(
- context.auth.secret_text,
- `/groups/${groupId}/subscribers?limit=1`
- );
- return response.body.data || [];
+ const page = await senderApi.listGroupSubscribers({ auth: context.auth, groupId: context.propsValue.groupId, limit: 1 });
+ return page.data ?? [];
},
sampleData: {},
});
diff --git a/packages/pieces/community/sender/src/lib/triggers/new-subscriber.ts b/packages/pieces/community/sender/src/lib/triggers/new-subscriber.ts
index 2a7f430447b..398ecb8c0ee 100644
--- a/packages/pieces/community/sender/src/lib/triggers/new-subscriber.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/new-subscriber.ts
@@ -1,10 +1,15 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderSubscriberTriggerOutputSchema } from '../output-schemas';
+
+const TOPIC = 'subscribers/new';
+const STORE_KEY = 'webhookId';
export const newSubscriberTrigger = createTrigger({
auth: senderAuth,
name: 'new_subscriber',
+ outputSchema: senderSubscriberTriggerOutputSchema,
classification: 'READ',
displayName: 'New Subscriber',
description: 'Fires when a subscriber is added to any group or to account',
@@ -14,45 +19,26 @@ export const newSubscriberTrigger = createTrigger({
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
-
- const webhookData = {
- url: webhookUrl,
- topic: 'subscribers/new',
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
async test(context) {
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/subscribers?limit=1',
- HttpMethod.GET
- );
- return response.body.data;
+ const page = await senderApi.listSubscribers({ auth: context.auth, limit: 1 });
+ return page.data ?? [];
},
sampleData: {},
});
diff --git a/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber-from-group.ts b/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber-from-group.ts
index 74faf268275..c1b4b8c99af 100644
--- a/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber-from-group.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber-from-group.ts
@@ -1,11 +1,15 @@
-import { createTrigger, TriggerStrategy, Property } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { createTrigger, Property, TriggerStrategy } from '@activepieces/pieces-framework';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderSubscriberTriggerOutputSchema } from '../output-schemas';
+const TOPIC = 'groups/unsubscribed';
+const STORE_KEY = 'webhookId';
export const newUnsubscriberFromGroupTrigger = createTrigger({
auth: senderAuth,
name: 'new_unsubscriber_from_group',
+ outputSchema: senderSubscriberTriggerOutputSchema,
classification: 'READ',
displayName: 'New Unsubscriber From Group',
description: 'Fires when a subscriber is removed/unsubscribed from a specific group',
@@ -21,42 +25,26 @@ export const newUnsubscriberFromGroupTrigger = createTrigger({
}),
},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
- const groupId = context.propsValue.groupId;
-
- const webhookData = {
- url: webhookUrl,
- topic: 'groups/unsubscribed',
- relation_id : groupId,
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ relationId: context.propsValue.groupId,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
- async test(context) {
+ async test() {
return [];
},
sampleData: {},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber.ts b/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber.ts
index 6680efd77b3..8facd4f89a8 100644
--- a/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/new-unsubscriber.ts
@@ -1,11 +1,15 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderSubscriberTriggerOutputSchema } from '../output-schemas';
+const TOPIC = 'subscribers/unsubscribed';
+const STORE_KEY = 'webhookId';
export const newUnsubscriberTrigger = createTrigger({
auth: senderAuth,
name: 'new_unsubscriber',
+ outputSchema: senderSubscriberTriggerOutputSchema,
classification: 'READ',
displayName: 'New Unsubscriber',
description: 'Fires when someone unsubscribes globally',
@@ -15,40 +19,25 @@ export const newUnsubscriberTrigger = createTrigger({
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
-
- const webhookData = {
- url: webhookUrl,
- topic: 'subscribers/unsubscribed',
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
- async test(context) {
+ async test() {
return [];
},
sampleData: {},
-});
\ No newline at end of file
+});
diff --git a/packages/pieces/community/sender/src/lib/triggers/updated-subscriber.ts b/packages/pieces/community/sender/src/lib/triggers/updated-subscriber.ts
index c625d38764b..9a8f140dd90 100644
--- a/packages/pieces/community/sender/src/lib/triggers/updated-subscriber.ts
+++ b/packages/pieces/community/sender/src/lib/triggers/updated-subscriber.ts
@@ -1,10 +1,15 @@
import { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
-import { makeSenderRequest, senderAuth } from '../common/common';
-import { HttpMethod } from '@activepieces/pieces-common';
+import { senderAuth } from '../auth';
+import { senderApi } from '../common/api';
+import { senderSubscriberTriggerOutputSchema } from '../output-schemas';
+
+const TOPIC = 'subscribers/updated';
+const STORE_KEY = 'webhookId';
export const updatedSubscriberTrigger = createTrigger({
auth: senderAuth,
name: 'updated_subscriber',
+ outputSchema: senderSubscriberTriggerOutputSchema,
classification: 'READ',
displayName: 'Updated Subscriber',
description: "Fires when a subscriber's data (fields) is updated",
@@ -14,45 +19,26 @@ export const updatedSubscriberTrigger = createTrigger({
type: TriggerStrategy.WEBHOOK,
props: {},
async onEnable(context) {
- const webhookUrl = context.webhookUrl;
-
- const webhookData = {
- url: webhookUrl,
- topic: 'subscribers/updated',
- };
-
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/account/webhooks',
- HttpMethod.POST,
- webhookData
- );
-
- await context.store.put('webhookId', response.body.data.id);
+ const webhook = await senderApi.createWebhook({
+ auth: context.auth,
+ url: context.webhookUrl,
+ topic: TOPIC,
+ });
+ await context.store.put(STORE_KEY, webhook.id);
},
async onDisable(context) {
- const webhookId = await context.store.get<string>('webhookId');
-
+ const webhookId = await context.store.get<string>(STORE_KEY);
if (webhookId) {
- await makeSenderRequest(
- context.auth.secret_text,
- `/account/webhooks/${webhookId}`,
- HttpMethod.DELETE
- );
+ await senderApi.deleteWebhook({ auth: context.auth, webhookId });
}
-
- await context.store.delete('webhookId');
+ await context.store.delete(STORE_KEY);
},
async run(context) {
return [context.payload.body];
},
async test(context) {
- const response = await makeSenderRequest(
- context.auth.secret_text,
- '/subscribers?limit=1',
- HttpMethod.GET
- );
- return response.body.data || [];
+ const page = await senderApi.listSubscribers({ auth: context.auth, limit: 1 });
+ return page.data ?? [];
},
sampleData: {},
});