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(zoho-campaigns): add AI actions and output schemas (#16811)

Kishan Parmarc999055c2384
diff --git a/packages/pieces/community/zoho-campaigns/package.json b/packages/pieces/community/zoho-campaigns/package.json
index 0cfed7a7461..3a296d119df 100644
--- a/packages/pieces/community/zoho-campaigns/package.json
+++ b/packages/pieces/community/zoho-campaigns/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-zoho-campaigns",
- "version": "0.2.3",
+ "version": "0.3.0",
"type": "commonjs",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
diff --git a/packages/pieces/community/zoho-campaigns/src/index.ts b/packages/pieces/community/zoho-campaigns/src/index.ts
index 57460b6abe8..efe13e9e0c0 100644
--- a/packages/pieces/community/zoho-campaigns/src/index.ts
+++ b/packages/pieces/community/zoho-campaigns/src/index.ts
@@ -1,58 +1,50 @@
-import { createPiece, OAuth2PropertyValue } from '@activepieces/pieces-framework';
-import { addContactToMailingList } from './lib/actions/add-contact-to-mailing-list';
-import { addTagToContact } from './lib/actions/add-tag-to-contact';
-import { addUpdateContact } from './lib/actions/add-update-contact';
-import { cloneCampaign } from './lib/actions/clone-campaign';
-import { createCampaign } from './lib/actions/create-campaign';
-import { findCampaign } from './lib/actions/find-campaign';
-import { findContact } from './lib/actions/find-contact';
-import { removeTag } from './lib/actions/remove-tag';
-import { sendCampaign } from './lib/actions/send-campaign';
-import { unsubscribeContact } from './lib/actions/unsubscribe-contact';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from './lib/common';
-import { newCampaign } from './lib/triggers/new-campaign';
-import { newContact } from './lib/triggers/new-contact';
-import { unsubscribe } from './lib/triggers/unsubscribe';
import { createCustomApiCallAction } from '@activepieces/pieces-common';
+import { createPiece } from '@activepieces/pieces-framework';
+import { zohoCampaignsAiActions } from './lib/actions/ai';
+import { addContactToMailingListAction } from './lib/actions/add-contact-to-mailing-list';
+import { addTagToContactAction } from './lib/actions/add-tag-to-contact';
+import { addUpdateContactAction } from './lib/actions/add-update-contact';
+import { cloneCampaignAction } from './lib/actions/clone-campaign';
+import { createCampaignAction } from './lib/actions/create-campaign';
+import { findCampaignAction } from './lib/actions/find-campaign';
+import { findContactAction } from './lib/actions/find-contact';
+import { removeTagAction } from './lib/actions/remove-tag';
+import { sendCampaignAction } from './lib/actions/send-campaign';
+import { unsubscribeContactAction } from './lib/actions/unsubscribe-contact';
+import { zohoCampaignsAuth } from './lib/auth';
+import { zohoCampaignsClient } from './lib/common/client';
+import { newCampaignTrigger } from './lib/triggers/new-campaign';
+import { newContactTrigger } from './lib/triggers/new-contact';
+import { unsubscribeTrigger } from './lib/triggers/unsubscribe';
export const zohoCampaigns = createPiece({
displayName: 'Zoho Campaigns',
description:
'Zoho Campaigns is an email marketing platform for managing mailing lists, sending campaigns, tracking engagement, and automating subscriber workflows.',
auth: zohoCampaignsAuth,
- minimumSupportedRelease: '0.36.1',
+ minimumSupportedRelease: '0.88.2',
logoUrl: 'https://cdn.activepieces.com/pieces/zoho-campaigns.png',
authors: ['LuizDMM', 'onyedikachi-david'],
actions: [
- // Write Actions
- createCampaign,
- cloneCampaign,
- sendCampaign,
- addUpdateContact,
- addTagToContact,
- removeTag,
- unsubscribeContact,
- addContactToMailingList,
- // Search Actions
- findContact,
- findCampaign,
+ createCampaignAction,
+ cloneCampaignAction,
+ sendCampaignAction,
+ addUpdateContactAction,
+ addTagToContactAction,
+ removeTagAction,
+ unsubscribeContactAction,
+ addContactToMailingListAction,
+ findContactAction,
+ findCampaignAction,
+ ...zohoCampaignsAiActions,
createCustomApiCallAction({
- baseUrl: (auth) =>
- {
- const authValue = auth as OAuth2PropertyValue
- const location = authValue.props?.['location'] || 'zoho.com';
-
- return `${zohoCampaignsCommon.baseUrl(location)}?resfmt=JSON`
- },
- auth: zohoCampaignsAuth,
- authMapping: async (auth) => ({
- Authorization: `Zoho-oauthtoken ${(auth as OAuth2PropertyValue).access_token}`,
- }),
- }),
- ],
- triggers: [
- newContact,
- unsubscribe,
- newCampaign,
+ auth: zohoCampaignsAuth,
+ baseUrl: (auth) =>
+ auth ? `${zohoCampaignsClient.baseUrl({ auth })}?resfmt=JSON` : '',
+ authMapping: async (auth) => ({
+ Authorization: `Zoho-oauthtoken ${auth.access_token}`,
+ }),
+ }),
],
+ triggers: [newContactTrigger, unsubscribeTrigger, newCampaignTrigger],
});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/add-contact-to-mailing-list.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/add-contact-to-mailing-list.ts
index e16b5a1c2a8..8f18d4489b2 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/add-contact-to-mailing-list.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/add-contact-to-mailing-list.ts
@@ -1,33 +1,46 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsAddContactsToMailingListOutputSchema } from '../output-schemas';
-export const addContactToMailingList = createAction({
+export const addContactToMailingListAction = createAction({
auth: zohoCampaignsAuth,
name: 'addContactToMailingList',
+ outputSchema: zohoCampaignsAddContactsToMailingListOutputSchema,
classification: 'WRITE',
displayName: 'Add Contact to Mailing List',
description: 'Add contacts to your mailing lists.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Adds one or more contacts (by email address) to a specified mailing list. Use to subscribe known emails in bulk to a list. Idempotent: re-adding emails already on the list leaves the membership unchanged.',
idempotent: true,
},
- props: zohoCampaignsCommon.addContactToMailingListProperties(),
+ props: {
+ listkey: zohoCampaignsProps.listKey({ required: true }),
+ emails: Property.Array({
+ displayName: 'Emails',
+ description:
+ 'Contacts email addresses to be added to the mailing list (maximum 10 emails)',
+ required: true,
+ }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token
-
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.addContactToMailingListSchema
- );
- return await zohoCampaignsCommon.addContactToMailingList({
- accessToken,
- location,
- listkey: String(propsValue.listkey),
+ await propsValidation.validateZod(propsValue, schema);
+ return await zohoCampaignsApi.addContactsToMailingList({
+ auth,
+ listkey: propsValue.listkey,
emailids: propsValue.emails.join(','),
});
},
});
+
+const schema = {
+ listkey: z.string(),
+ emails: z
+ .array(z.string().check(z.email()))
+ .check(z.minLength(1), z.maxLength(10)),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/add-tag-to-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/add-tag-to-contact.ts
index f59a66863c4..ff9c22bdaf8 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/add-tag-to-contact.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/add-tag-to-contact.ts
@@ -1,45 +1,41 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsStatusOutputSchema } from '../output-schemas';
-export const addTagToContact = createAction({
+export const addTagToContactAction = createAction({
auth: zohoCampaignsAuth,
name: 'addTagToContact',
+ outputSchema: zohoCampaignsStatusOutputSchema,
classification: 'WRITE',
displayName: 'Add Tag to Contact',
description:
"Apply a tag to a contact by email. Creates the tag if it doesn't exist.",
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Applies a tag to a contact identified by email address, first creating the tag in the account if it does not already exist. Use to label or segment a subscriber. Idempotent: re-applying the same tag to the same contact leaves the contact in the same tagged state.',
idempotent: true,
},
- props: zohoCampaignsCommon.addTagToContactProperties,
+ props: {
+ tagName: zohoCampaignsProps.tagName({ required: true }),
+ lead_email: Property.ShortText({
+ displayName: 'Contact Email',
+ description: 'Email address of the contact to tag',
+ required: true,
+ }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.addTagToContactSchema
- );
- const tags = await zohoCampaignsCommon.listTags({ accessToken, location });
- const tagExists =
- tags !== undefined &&
- tags.some((tagMap) =>
- Object.values(tagMap).some((t) => t.tag_name === propsValue.tagName)
- );
- if (!tagExists) {
- await zohoCampaignsCommon.createTag({
- accessToken,
- location,
- tagName: propsValue.tagName,
- });
- }
- return await zohoCampaignsCommon.addTagToContact({
- accessToken,
- location,
- ...propsValue,
- });
+ await propsValidation.validateZod(propsValue, schema);
+ await zohoCampaignsApi.ensureTag({ auth, tagName: propsValue.tagName });
+ return await zohoCampaignsApi.addTagToContact({ auth, ...propsValue });
},
});
+
+const schema = {
+ tagName: z.string(),
+ lead_email: z.string().check(z.email()),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/add-update-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/add-update-contact.ts
index 45bc7ed5d65..3e256762c9a 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/add-update-contact.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/add-update-contact.ts
@@ -1,39 +1,56 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsStatusOutputSchema } from '../output-schemas';
-export const addUpdateContact = createAction({
+export const addUpdateContactAction = createAction({
auth: zohoCampaignsAuth,
name: 'addUpdateContact',
+ outputSchema: zohoCampaignsStatusOutputSchema,
classification: 'WRITE',
displayName: 'Add/Update Contact',
description:
'Add a new contact or update an existing one. Confirmation email sent based on mailing list settings.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Adds a contact to a mailing list or updates the existing contact matched by email, setting standard and custom fields. Use to create or keep a subscriber record current. Effectively an upsert keyed on email, so repeating with the same input converges to the same state and is idempotent; note a confirmation email may be sent depending on the list settings.',
idempotent: true,
},
- props: zohoCampaignsCommon.addUpdateContactProperties(),
+ props: {
+ listkey: zohoCampaignsProps.listKey({ required: true }),
+ contactinfo: zohoCampaignsProps.contactInfo({ required: true }),
+ source: Property.ShortText({
+ displayName: 'Source',
+ description: 'Contact source can be added.',
+ required: false,
+ }),
+ topic_id: zohoCampaignsProps.topicId({ required: false }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.addUpdateContactSchema
- );
+ await propsValidation.validateZod(propsValue, schema);
const { additionalFields, ...baseFields } = propsValue.contactinfo;
-
- return await zohoCampaignsCommon.addUpdateContact({
- accessToken,
- location,
- ...propsValue,
- listkey: String(propsValue.listkey),
+ return await zohoCampaignsApi.addUpdateContact({
+ auth,
+ listkey: propsValue.listkey,
contactinfo: {
...baseFields,
...additionalFields,
},
+ source: propsValue.source,
+ topic_id: propsValue.topic_id,
});
},
});
+
+const schema = {
+ listkey: z.string(),
+ contactinfo: z.object({
+ 'Contact Email': z.string().check(z.email()),
+ }),
+ source: z.optional(z.string()),
+ topic_id: z.optional(z.nullable(z.string())),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-contact-to-do-not-mail.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-contact-to-do-not-mail.ts
new file mode 100644
index 00000000000..f08cf89f01a
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-contact-to-do-not-mail.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const addContactToDoNotMailAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_add_contact_to_do_not_mail',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Add Contact to Do-Not-Mail',
+ description: 'Blocks an email address from all future campaigns.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Moves an email address to the account-wide Do-Not-Mail registry so no campaign is ever sent to it again, across every list. Use Unsubscribe Contact to leave a single list instead. Cannot be undone through the API; idempotent.',
+ idempotent: true,
+ },
+ props: {
+ email: zohoCampaignsAiProps.contactEmail({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.addContactToDoNotMail({
+ auth,
+ contactinfo: zohoCampaignsUtils.contactInfo({ email: propsValue.email }),
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-contacts-to-mailing-list.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-contacts-to-mailing-list.ts
new file mode 100644
index 00000000000..ff78d6e0751
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-contacts-to-mailing-list.ts
@@ -0,0 +1,38 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsAddContactsToMailingListOutputSchema } from '../../output-schemas';
+
+export const addContactsToMailingListAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_add_contacts_to_mailing_list',
+ outputSchema: zohoCampaignsAddContactsToMailingListOutputSchema,
+ displayName: 'Add Contacts to Mailing List',
+ description: 'Adds up to 10 email addresses to a mailing list in one call.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds 1 to 10 email addresses to an existing mailing list (key from List Mailing Lists) in one call, without other fields. Use Subscribe Contact to set names or custom fields. Idempotent: addresses already on the list stay as they are.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ emails: Property.Array({
+ displayName: 'Emails',
+ description: '1 to 10 email addresses to add.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.addContactsToMailingList({
+ auth,
+ listkey: propsValue.listKey,
+ emailids: zohoCampaignsUtils.joinEmails({ emails: propsValue.emails, propName: 'Emails' }),
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-tag-to-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-tag-to-contact.ts
new file mode 100644
index 00000000000..294defa24c1
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/add-tag-to-contact.ts
@@ -0,0 +1,39 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsAddTagToContactOutputSchema } from '../../output-schemas';
+
+export const addTagToContactAiAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_add_tag_to_contact',
+ outputSchema: zohoCampaignsAddTagToContactOutputSchema,
+ displayName: 'Add Tag to Contact',
+ description: 'Tags a contact by email, creating the tag if it does not exist.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds a tag to a contact matched by email, first creating the tag when no tag with that name exists. tagCreated in the result says whether it was created. Idempotent: re-tagging leaves the contact tagged.',
+ idempotent: true,
+ },
+ props: {
+ tagName: Property.ShortText({
+ displayName: 'Tag Name',
+ description: 'Name of the tag, as shown by List Tags.',
+ required: true,
+ }),
+ email: zohoCampaignsAiProps.contactEmail({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const { created } = await zohoCampaignsApi.ensureTag({ auth, tagName: propsValue.tagName });
+ const body = await zohoCampaignsApi.addTagToContact({
+ auth,
+ tagName: propsValue.tagName,
+ lead_email: propsValue.email,
+ });
+ return { ...zohoCampaignsUtils.assertSuccess({ body }), tagCreated: created };
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/clone-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/clone-campaign.ts
new file mode 100644
index 00000000000..72a79209934
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/clone-campaign.ts
@@ -0,0 +1,68 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCloneCampaignOutputSchema } from '../../output-schemas';
+
+export const cloneCampaignAiAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_clone_campaign',
+ outputSchema: zohoCampaignsCloneCampaignOutputSchema,
+ displayName: 'Clone Campaign',
+ description: 'Copies a campaign into a new draft.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Copies an existing campaign (key from List Campaigns) into a new draft, optionally overriding its name, subject, sender, reply-to and encoding. Not idempotent: each call creates a new campaign.',
+ idempotent: false,
+ },
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ campaignName: Property.ShortText({
+ displayName: 'Campaign Name',
+ description: 'Name of the new campaign. Defaults to a copy of the original name.',
+ required: false,
+ }),
+ subject: Property.ShortText({
+ displayName: 'Subject',
+ description: 'Subject line of the new campaign.',
+ required: false,
+ }),
+ fromName: Property.ShortText({
+ displayName: 'From Name',
+ description: 'Sender display name.',
+ required: false,
+ }),
+ fromEmail: Property.ShortText({
+ displayName: 'From Email',
+ description: 'Sender email address. It must be a verified sender in Zoho Campaigns.',
+ required: false,
+ }),
+ replyTo: Property.ShortText({
+ displayName: 'Reply-To Email',
+ description: 'Reply-to email address.',
+ required: false,
+ }),
+ encodeType: Property.ShortText({
+ displayName: 'Encoding',
+ description: 'Email character encoding, e.g. "UTF-8".',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.cloneCampaign({
+ auth,
+ campaignkey: propsValue.campaignKey,
+ campaignname: propsValue.campaignName,
+ subject: propsValue.subject,
+ from_name: propsValue.fromName,
+ from_add: propsValue.fromEmail,
+ reply_to: propsValue.replyTo,
+ encode_type: propsValue.encodeType,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/count-contacts.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/count-contacts.ts
new file mode 100644
index 00000000000..dda81b791db
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/count-contacts.ts
@@ -0,0 +1,47 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCountContactsOutputSchema } from '../../output-schemas';
+
+export const countContactsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_count_contacts',
+ outputSchema: zohoCampaignsCountContactsOutputSchema,
+ displayName: 'Count Contacts',
+ description: 'Counts the contacts of a mailing list, optionally by status.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Counts the contacts of a mailing list (key from List Mailing Lists), optionally only those that are active, unsubscribed, bounced or marked as spam.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ status: Property.StaticDropdown<'active' | 'unsub' | 'bounce' | 'spam', false>({
+ displayName: 'Status',
+ description: 'Only count contacts in this status.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Unsubscribed', value: 'unsub' },
+ { label: 'Bounced', value: 'bounce' },
+ { label: 'Spam', value: 'spam' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.countContacts({
+ auth,
+ listkey: propsValue.listKey,
+ status: propsValue.status,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-campaign.ts
new file mode 100644
index 00000000000..5fa631d1512
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-campaign.ts
@@ -0,0 +1,83 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCreateCampaignOutputSchema } from '../../output-schemas';
+
+export const createCampaignAiAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_create_campaign',
+ outputSchema: zohoCampaignsCreateCampaignOutputSchema,
+ displayName: 'Create Campaign',
+ description: 'Creates a draft email campaign.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a draft email campaign addressed to mailing lists (keys from List Mailing Lists) and/or segments, which must hold at least one contact, and returns its campaignKey for Send Campaign or Schedule Campaign. Give a public Content URL, or the campaign has no content and cannot be sent. Accounts using topic management also need a Topic ID (from List Topics). Not idempotent: each call creates a new campaign.',
+ idempotent: false,
+ },
+ props: {
+ campaignName: Property.ShortText({
+ displayName: 'Campaign Name',
+ description: 'Internal name of the campaign.',
+ required: true,
+ }),
+ subject: Property.ShortText({
+ displayName: 'Subject',
+ description: 'Email subject line.',
+ required: true,
+ }),
+ fromEmail: Property.ShortText({
+ displayName: 'From Email',
+ description: 'Sender email address. It must be a verified sender in Zoho Campaigns.',
+ required: true,
+ }),
+ fromName: Property.ShortText({
+ displayName: 'From Name',
+ description: 'Sender display name.',
+ required: false,
+ }),
+ contentUrl: Property.ShortText({
+ displayName: 'Content URL',
+ description: 'Public URL of the HTML page to import as the email content.',
+ required: false,
+ }),
+ listKeys: Property.Array({
+ displayName: 'Mailing List Keys',
+ description:
+ 'Keys of the mailing lists to send to (from List Mailing Lists). Lists take precedence when segments are also given.',
+ required: false,
+ }),
+ segmentIds: Property.Array({
+ displayName: 'Segment IDs',
+ description: 'Segment IDs (cvid) to send to, from the segments of List Mailing Lists.',
+ required: false,
+ }),
+ topicId: Property.ShortText({
+ displayName: 'Topic ID',
+ description: 'Topic ID from List Topics. Required on accounts that use topic management.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const listKeys = propsValue.listKeys?.map(String);
+ const segmentIds = propsValue.segmentIds?.map(String);
+ if ((listKeys ?? []).length === 0 && (segmentIds ?? []).length === 0) {
+ throw new Error('Give at least one List Key or Segment ID to address the campaign to.');
+ }
+ const body = await zohoCampaignsApi.createCampaign({
+ auth,
+ campaignname: propsValue.campaignName,
+ subject: propsValue.subject,
+ from_email: propsValue.fromEmail,
+ ...(propsValue.fromName && { from_name: propsValue.fromName }),
+ ...(propsValue.contentUrl && { content_url: propsValue.contentUrl }),
+ ...(listKeys && listKeys.length > 0 && { list_details: listKeys }),
+ ...(segmentIds && segmentIds.length > 0 && { segments: segmentIds }),
+ topicId: propsValue.topicId,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-custom-field.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-custom-field.ts
new file mode 100644
index 00000000000..3d1e5793093
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-custom-field.ts
@@ -0,0 +1,69 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCreateCustomFieldOutputSchema } from '../../output-schemas';
+
+const FIELD_TYPES = [
+ 'Text',
+ 'Integer',
+ 'Phone',
+ 'Date',
+ 'Picklist',
+ 'Email',
+ 'Checkbox',
+ 'LongInteger',
+ 'URL',
+ 'textarea',
+ 'RadioOption',
+ 'Multiselect',
+ 'DateTime',
+ 'Decimal',
+ 'Percent',
+];
+
+export const createCustomFieldAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_create_custom_field',
+ outputSchema: zohoCampaignsCreateCustomFieldOutputSchema,
+ displayName: 'Create Custom Field',
+ description: 'Creates a custom contact field.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a custom contact field of the given type, so contacts can store a new attribute through Subscribe Contact. Check List Contact Fields first: a duplicate name fails. Not idempotent, and fields cannot be deleted through the API.',
+ idempotent: false,
+ },
+ props: {
+ fieldName: Property.ShortText({
+ displayName: 'Field Name',
+ description: 'Alphanumeric name of the field.',
+ required: true,
+ }),
+ fieldType: Property.StaticDropdown({
+ displayName: 'Field Type',
+ description: 'Data type of the field.',
+ required: true,
+ options: {
+ disabled: false,
+ options: FIELD_TYPES.map((type) => ({ label: type, value: type })),
+ },
+ }),
+ fieldLength: Property.Number({
+ displayName: 'Field Length',
+ description: 'Maximum length of the value. Defaults to 20.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.createCustomField({
+ auth,
+ fieldname: propsValue.fieldName,
+ fieldtype: propsValue.fieldType,
+ fieldlength: propsValue.fieldLength,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-mailing-list.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-mailing-list.ts
new file mode 100644
index 00000000000..734cd026216
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-mailing-list.ts
@@ -0,0 +1,51 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsAddContactsToMailingListOutputSchema } from '../../output-schemas';
+
+export const createMailingListAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_create_mailing_list',
+ outputSchema: zohoCampaignsAddContactsToMailingListOutputSchema,
+ displayName: 'Create Mailing List',
+ description: 'Creates a mailing list with its first contacts.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a mailing list and adds 1 to 10 contacts by email (the API requires at least one), returning the new list key. Add more contacts with Add Contacts to Mailing List or Subscribe Contact. Not idempotent: each call creates a new list.',
+ idempotent: false,
+ },
+ props: {
+ listName: Property.ShortText({
+ displayName: 'List Name',
+ description:
+ 'Name of the new list. Use letters, digits and spaces; Zoho rejects "&" and some other punctuation and accented letters.',
+ required: true,
+ }),
+ signupForm: zohoCampaignsAiProps.signupForm({ required: true }),
+ emails: Property.Array({
+ displayName: 'Emails',
+ description: '1 to 10 email addresses to add to the new list.',
+ required: true,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'Description of the list.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.createMailingList({
+ auth,
+ listname: propsValue.listName,
+ signupform: propsValue.signupForm,
+ listdescription: propsValue.description,
+ emailids: zohoCampaignsUtils.joinEmails({ emails: propsValue.emails, propName: 'Emails' }),
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-tag.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-tag.ts
new file mode 100644
index 00000000000..c8c8ed03e0d
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-tag.ts
@@ -0,0 +1,47 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCreateTagOutputSchema } from '../../output-schemas';
+
+export const createTagAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_create_tag',
+ outputSchema: zohoCampaignsCreateTagOutputSchema,
+ displayName: 'Create Tag',
+ description: 'Creates a contact tag.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a contact tag. A tag name that already exists fails, so check List Tags first, or use Add Tag to Contact, which creates a missing tag itself. Not idempotent.',
+ idempotent: false,
+ },
+ props: {
+ tagName: Property.ShortText({
+ displayName: 'Tag Name',
+ description: 'Name of the tag, as shown by List Tags.',
+ required: true,
+ }),
+ description: Property.ShortText({
+ displayName: 'Description',
+ description: 'Short description of the tag.',
+ required: false,
+ }),
+ color: Property.ShortText({
+ displayName: 'Color',
+ description: 'Hex color of the tag, e.g. "#48b9d1". Defaults to #ec676c.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.createTag({
+ auth,
+ tagName: propsValue.tagName,
+ tagDesc: propsValue.description,
+ color: propsValue.color,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-topic.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-topic.ts
new file mode 100644
index 00000000000..3895b02c1de
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/create-topic.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCreateTopicOutputSchema } from '../../output-schemas';
+
+export const createTopicAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_create_topic',
+ outputSchema: zohoCampaignsCreateTopicOutputSchema,
+ displayName: 'Create Topic',
+ description: 'Creates a subscription topic, optionally under a product.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Creates a subscription topic contacts can subscribe to, and returns its topic_id. Needs topic management on the account. Not idempotent, and topics cannot be deleted through the API.',
+ idempotent: false,
+ },
+ props: {
+ topicName: Property.ShortText({
+ displayName: 'Topic Name',
+ description: 'Name of the topic.',
+ required: true,
+ }),
+ topicDescription: Property.ShortText({
+ displayName: 'Topic Description',
+ description: 'Description of the topic.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.createTopic({
+ auth,
+ topicName: propsValue.topicName,
+ topicDesc: propsValue.topicDescription,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-campaign.ts
new file mode 100644
index 00000000000..16291c5160a
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-campaign.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const deleteCampaignAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_delete_campaign',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Delete Campaign',
+ description: 'Permanently deletes a campaign.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a campaign (key from List Campaigns), including a scheduled one, which cancels its send. This is a hard delete and cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.deleteCampaign({
+ auth,
+ campaignkey: propsValue.campaignKey,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-mailing-list.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-mailing-list.ts
new file mode 100644
index 00000000000..f42f57902cd
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-mailing-list.ts
@@ -0,0 +1,45 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const deleteMailingListAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_delete_mailing_list',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Delete Mailing List',
+ description: 'Permanently deletes a mailing list, optionally with its contacts.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a mailing list (key from List Mailing Lists). Delete Contacts set to Yes also deletes its contacts from the whole account; otherwise they are only removed from the list. Cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ deleteContacts: Property.StaticDropdown<'on' | 'off', false>({
+ displayName: 'Delete Contacts',
+ description: 'Yes also deletes the list contacts from the account. Defaults to No.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Yes', value: 'on' },
+ { label: 'No', value: 'off' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.deleteMailingList({
+ auth,
+ listkey: propsValue.listKey,
+ deletecontacts: propsValue.deleteContacts,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-tag.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-tag.ts
new file mode 100644
index 00000000000..d84110d0599
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/delete-tag.ts
@@ -0,0 +1,32 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const deleteTagAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_delete_tag',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Delete Tag',
+ description: 'Permanently deletes a tag from the account.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Permanently deletes a tag (by name, from List Tags) from the account and from every contact that carries it. Use Remove Tag from Contact to untag one contact. Cannot be undone.',
+ idempotent: false,
+ },
+ props: {
+ tagName: Property.ShortText({
+ displayName: 'Tag Name',
+ description: 'Name of the tag, as shown by List Tags.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.deleteTag({ auth, tagName: propsValue.tagName });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-campaign-report.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-campaign-report.ts
new file mode 100644
index 00000000000..febb9d31bc1
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-campaign-report.ts
@@ -0,0 +1,32 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCampaignReportOutputSchema } from '../../output-schemas';
+
+export const getCampaignReportAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_get_campaign_report',
+ displayName: 'Get Campaign Report',
+ description: 'Gets the delivery, open, click and bounce figures of a sent campaign.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the report of a sent campaign (key from List Sent Campaigns or List Campaigns): sent, delivered, opens, clicks, bounces, unsubscribes and spam complaints with percentages, plus opens by location. Only sent campaigns have a report.',
+ idempotent: true,
+ },
+ outputSchema: zohoCampaignsCampaignReportOutputSchema,
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.getCampaignReport({
+ auth,
+ campaignkey: propsValue.campaignKey,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-campaign.ts
new file mode 100644
index 00000000000..bbc34a5268c
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-campaign.ts
@@ -0,0 +1,45 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsGetCampaignOutputSchema } from '../../output-schemas';
+
+export const getCampaignAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_get_campaign',
+ outputSchema: zohoCampaignsGetCampaignOutputSchema,
+ displayName: 'Get Campaign',
+ description: 'Gets a campaign with its sender, mailing lists, status and report.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets one campaign by its campaign key (from List Campaigns): sender details, associated mailing lists and segments, recipient count and its report figures. Set Campaign Type to abtesting for A/B test campaigns.',
+ idempotent: true,
+ },
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ campaignType: Property.StaticDropdown<'normal' | 'abtesting', false>({
+ displayName: 'Campaign Type',
+ description: 'normal (default) or abtesting for an A/B test campaign.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Normal', value: 'normal' },
+ { label: 'A/B Testing', value: 'abtesting' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.getCampaignDetails({
+ auth,
+ campaignkey: propsValue.campaignKey,
+ campaigntype: propsValue.campaignType,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-last-campaign-report.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-last-campaign-report.ts
new file mode 100644
index 00000000000..d7d7b8290c3
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-last-campaign-report.ts
@@ -0,0 +1,26 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsCampaignReportOutputSchema } from '../../output-schemas';
+
+export const getLastCampaignReportAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_get_last_campaign_report',
+ displayName: 'Get Last Campaign Report',
+ description: 'Gets the report of the most recently sent campaign.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the report of the most recently sent campaign in the account, with no key needed. Use Get Campaign Report for any other sent campaign.',
+ idempotent: true,
+ },
+ outputSchema: zohoCampaignsCampaignReportOutputSchema,
+ props: {},
+ async run({ auth }) {
+ const body = await zohoCampaignsApi.getLastCampaignReport({ auth });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-mailing-list-details.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-mailing-list-details.ts
new file mode 100644
index 00000000000..655882e8a6f
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/get-mailing-list-details.ts
@@ -0,0 +1,53 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsGetMailingListDetailsOutputSchema } from '../../output-schemas';
+
+export const getMailingListDetailsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_get_mailing_list_details',
+ outputSchema: zohoCampaignsGetMailingListDetailsOutputSchema,
+ displayName: 'Get Mailing List Details',
+ description: 'Gets the contact stats and campaign history of a mailing list.',
+ audience: 'ai',
+ classification: 'READ',
+ aiMetadata: {
+ description:
+ 'Gets the advanced details of a mailing list (key from List Mailing Lists): contact stats (active, unsubscribed, bounced), subscriber locations, email clients and devices, and the campaigns sent or scheduled to it, filtered by Campaign Filter.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ campaignFilter: Property.StaticDropdown<
+ 'sentcampaigns' | 'scheduledcampaigns' | 'recentcampaigns',
+ false
+ >({
+ displayName: 'Campaign Filter',
+ description: 'Which campaigns of the list to include. Defaults to the vendor default.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Sent Campaigns', value: 'sentcampaigns' },
+ { label: 'Scheduled Campaigns', value: 'scheduledcampaigns' },
+ { label: 'Recent Campaigns', value: 'recentcampaigns' },
+ ],
+ },
+ }),
+ fromIndex: zohoCampaignsAiProps.fromIndex({ required: false }),
+ range: zohoCampaignsAiProps.range({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.getMailingListDetails({
+ auth,
+ listkey: propsValue.listKey,
+ filtertype: propsValue.campaignFilter,
+ fromindex: propsValue.fromIndex,
+ range: propsValue.range,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/index.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/index.ts
new file mode 100644
index 00000000000..cc83df6a3d4
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/index.ts
@@ -0,0 +1,65 @@
+import { addContactToDoNotMailAction } from './add-contact-to-do-not-mail';
+import { addContactsToMailingListAction } from './add-contacts-to-mailing-list';
+import { addTagToContactAiAction } from './add-tag-to-contact';
+import { cloneCampaignAiAction } from './clone-campaign';
+import { countContactsAction } from './count-contacts';
+import { createCampaignAiAction } from './create-campaign';
+import { createCustomFieldAction } from './create-custom-field';
+import { createMailingListAction } from './create-mailing-list';
+import { createTagAction } from './create-tag';
+import { createTopicAction } from './create-topic';
+import { deleteCampaignAction } from './delete-campaign';
+import { deleteMailingListAction } from './delete-mailing-list';
+import { deleteTagAction } from './delete-tag';
+import { getCampaignAction } from './get-campaign';
+import { getCampaignReportAction } from './get-campaign-report';
+import { getLastCampaignReportAction } from './get-last-campaign-report';
+import { getMailingListDetailsAction } from './get-mailing-list-details';
+import { listCampaignRecipientsAction } from './list-campaign-recipients';
+import { listCampaignsAction } from './list-campaigns';
+import { listContactFieldsAction } from './list-contact-fields';
+import { listContactsAction } from './list-contacts';
+import { listMailingListsAction } from './list-mailing-lists';
+import { listSentCampaignsAction } from './list-sent-campaigns';
+import { listTagsAction } from './list-tags';
+import { listTopicsAction } from './list-topics';
+import { removeTagFromContactAction } from './remove-tag-from-contact';
+import { scheduleCampaignAction } from './schedule-campaign';
+import { sendCampaignAiAction } from './send-campaign';
+import { subscribeContactAction } from './subscribe-contact';
+import { unsubscribeContactAiAction } from './unsubscribe-contact';
+import { updateMailingListAction } from './update-mailing-list';
+
+export const zohoCampaignsAiActions = [
+ getCampaignAction,
+ listCampaignsAction,
+ listSentCampaignsAction,
+ createCampaignAiAction,
+ cloneCampaignAiAction,
+ sendCampaignAiAction,
+ scheduleCampaignAction,
+ deleteCampaignAction,
+ getCampaignReportAction,
+ getLastCampaignReportAction,
+ listCampaignRecipientsAction,
+ listMailingListsAction,
+ getMailingListDetailsAction,
+ createMailingListAction,
+ updateMailingListAction,
+ deleteMailingListAction,
+ countContactsAction,
+ listContactsAction,
+ subscribeContactAction,
+ unsubscribeContactAiAction,
+ addContactToDoNotMailAction,
+ addContactsToMailingListAction,
+ listContactFieldsAction,
+ createCustomFieldAction,
+ listTagsAction,
+ createTagAction,
+ addTagToContactAiAction,
+ removeTagFromContactAction,
+ deleteTagAction,
+ listTopicsAction,
+ createTopicAction,
+];
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-campaign-recipients.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-campaign-recipients.ts
new file mode 100644
index 00000000000..a24c38f3b25
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-campaign-recipients.ts
@@ -0,0 +1,59 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListCampaignRecipientsOutputSchema } from '../../output-schemas';
+
+import type { ZohoCampaignsRecipientAction } from '../../common/types';
+
+export const listCampaignRecipientsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_campaign_recipients',
+ displayName: 'List Campaign Recipients',
+ description:
+ 'Lists the recipients of a sent campaign by what they did, such as opened or clicked.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the recipients of a sent campaign (key from List Sent Campaigns) filtered by activity: sent, opened, unopened, clicked, opted out, marked as spam, hard or soft bounced, or not sent. Paged with From Index and Range.',
+ idempotent: true,
+ },
+ outputSchema: zohoCampaignsListCampaignRecipientsOutputSchema,
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ activity: Property.StaticDropdown<ZohoCampaignsRecipientAction, true>({
+ displayName: 'Activity',
+ description: 'Which recipients to return.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Sent', value: 'sentcontacts' },
+ { label: 'Opened', value: 'openedcontacts' },
+ { label: 'Unopened', value: 'unopenedcontacts' },
+ { label: 'Clicked', value: 'clickedcontacts' },
+ { label: 'Opted Out', value: 'optoutcontacts' },
+ { label: 'Marked as Spam', value: 'spamcontacts' },
+ { label: 'Hard Bounced', value: 'senthardbounce' },
+ { label: 'Soft Bounced', value: 'sentsoftbounce' },
+ { label: 'Not Sent', value: 'unsentcontacts' },
+ ],
+ },
+ }),
+ fromIndex: zohoCampaignsAiProps.fromIndex({ required: false }),
+ range: zohoCampaignsAiProps.range({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.listCampaignRecipients({
+ auth,
+ campaignkey: propsValue.campaignKey,
+ action: propsValue.activity,
+ fromindex: propsValue.fromIndex,
+ range: propsValue.range,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-campaigns.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-campaigns.ts
new file mode 100644
index 00000000000..9ae04bd85f9
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-campaigns.ts
@@ -0,0 +1,74 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListCampaignsOutputSchema } from '../../output-schemas';
+
+import type { ZohoCampaignsCampaignStatus } from '../../common/types';
+
+export const listCampaignsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_campaigns',
+ outputSchema: zohoCampaignsListCampaignsOutputSchema,
+ displayName: 'List Campaigns',
+ description: 'Lists campaigns, newest first, optionally filtered by status or name.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists campaigns with their campaign keys, names, statuses and creation times, filtered by status and paged with From Index and Range. Name Contains keeps only campaigns whose name contains the text (case-insensitive) within the returned page. Use it to find the campaign key other actions need.',
+ idempotent: true,
+ },
+ props: {
+ status: Property.StaticDropdown<ZohoCampaignsCampaignStatus, false>({
+ displayName: 'Status',
+ description: 'Only return campaigns in this status. Defaults to all.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'All', value: 'all' },
+ { label: 'Drafts', value: 'drafts' },
+ { label: 'Scheduled', value: 'scheduled' },
+ { label: 'In Progress', value: 'inprogress' },
+ { label: 'Sent', value: 'sent' },
+ { label: 'Stopped', value: 'stopped' },
+ { label: 'Canceled', value: 'canceled' },
+ { label: 'To Be Reviewed', value: 'tobereviewed' },
+ { label: 'Reviewed', value: 'reviewed' },
+ { label: 'Paused', value: 'paused' },
+ { label: 'In Testing', value: 'intesting' },
+ ],
+ },
+ }),
+ nameContains: Property.ShortText({
+ displayName: 'Name Contains',
+ description: 'Only keep campaigns whose name contains this text (case-insensitive).',
+ required: false,
+ }),
+ sort: zohoCampaignsAiProps.sort({ required: false }),
+ fromIndex: zohoCampaignsAiProps.fromIndex({ required: false }),
+ range: zohoCampaignsAiProps.range({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const body = zohoCampaignsUtils.assertSuccess({
+ body: await zohoCampaignsApi.getRecentCampaigns({
+ auth,
+ status: propsValue.status,
+ sort: propsValue.sort,
+ fromindex: propsValue.fromIndex,
+ range: propsValue.range,
+ }),
+ });
+ const needle = propsValue.nameContains?.toLowerCase();
+ const campaigns = body.recent_campaigns ?? [];
+ const matches = needle
+ ? campaigns.filter((campaign) =>
+ (campaign.campaign_name ?? '').toLowerCase().includes(needle),
+ )
+ : campaigns;
+ return { ...body, recent_campaigns: matches, count: matches.length };
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-contact-fields.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-contact-fields.ts
new file mode 100644
index 00000000000..615e196bacc
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-contact-fields.ts
@@ -0,0 +1,26 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListContactFieldsOutputSchema } from '../../output-schemas';
+
+export const listContactFieldsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_contact_fields',
+ outputSchema: zohoCampaignsListContactFieldsOutputSchema,
+ displayName: 'List Contact Fields',
+ description: 'Lists every contact field, standard and custom.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every contact field in the account, standard and custom, with display name, internal name and field ID. Use the display names as keys in the Additional Fields of Subscribe Contact.',
+ idempotent: true,
+ },
+ props: {},
+ async run({ auth }) {
+ const body = await zohoCampaignsApi.listContactFields({ auth });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-contacts.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-contacts.ts
new file mode 100644
index 00000000000..cf56ad02129
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-contacts.ts
@@ -0,0 +1,72 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListContactsOutputSchema } from '../../output-schemas';
+
+import type { ZohoCampaignsContactStatus } from '../../common/types';
+
+const NO_CONTACTS_CODE = '2502';
+
+export const listContactsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_contacts',
+ outputSchema: zohoCampaignsListContactsOutputSchema,
+ displayName: 'List Contacts',
+ description: 'Lists the contacts of a mailing list, optionally filtered by status or email.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists contacts of a mailing list (key from List Mailing Lists) with email, name, phone and company, filtered by status and paged with From Index and Range. Email Contains keeps only contacts whose email contains the text (case-insensitive) within the returned page. Returns an empty list when the list has no contacts with that status.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ status: Property.StaticDropdown<ZohoCampaignsContactStatus, false>({
+ displayName: 'Status',
+ description: 'Only return contacts in this status. Defaults to active.',
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Recent', value: 'recent' },
+ { label: 'Most Recent', value: 'most recent' },
+ { label: 'Unsubscribed', value: 'unsub' },
+ { label: 'Bounced', value: 'bounce' },
+ ],
+ },
+ }),
+ emailContains: Property.ShortText({
+ displayName: 'Email Contains',
+ description: 'Only keep contacts whose email contains this text (case-insensitive).',
+ required: false,
+ }),
+ sort: zohoCampaignsAiProps.sort({ required: false }),
+ fromIndex: zohoCampaignsAiProps.fromIndex({ required: false }),
+ range: zohoCampaignsAiProps.range({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const response = await zohoCampaignsApi.getListSubscribers({
+ auth,
+ listkey: propsValue.listKey,
+ status: propsValue.status,
+ sort: propsValue.sort,
+ fromindex: propsValue.fromIndex,
+ range: propsValue.range,
+ });
+ if (String(response.code) === NO_CONTACTS_CODE) {
+ return { list_of_details: [], count: 0 };
+ }
+ const body = zohoCampaignsUtils.assertSuccess({ body: response });
+ const needle = propsValue.emailContains?.toLowerCase();
+ const contacts = body.list_of_details ?? [];
+ const matches = needle
+ ? contacts.filter((contact) => (contact.contact_email ?? '').toLowerCase().includes(needle))
+ : contacts;
+ return { ...body, list_of_details: matches, count: matches.length };
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-mailing-lists.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-mailing-lists.ts
new file mode 100644
index 00000000000..9b87a6ed64b
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-mailing-lists.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListMailingListsOutputSchema } from '../../output-schemas';
+
+export const listMailingListsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_mailing_lists',
+ outputSchema: zohoCampaignsListMailingListsOutputSchema,
+ displayName: 'List Mailing Lists',
+ description: 'Lists mailing lists with their keys, sizes and segments.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the mailing lists in the account with their list keys, names, contact, unsubscribe and bounce counts, and their segments (segment IDs). Paged with From Index and Range. Use it to find the list key other actions need.',
+ idempotent: true,
+ },
+ props: {
+ sort: zohoCampaignsAiProps.sort({ required: false }),
+ fromIndex: zohoCampaignsAiProps.fromIndex({ required: false }),
+ range: zohoCampaignsAiProps.range({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.getMailingLists({
+ auth,
+ sort: propsValue.sort,
+ fromindex: propsValue.fromIndex,
+ range: propsValue.range,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-sent-campaigns.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-sent-campaigns.ts
new file mode 100644
index 00000000000..68ef0ae9029
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-sent-campaigns.ts
@@ -0,0 +1,33 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListSentCampaignsOutputSchema } from '../../output-schemas';
+
+export const listSentCampaignsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_sent_campaigns',
+ outputSchema: zohoCampaignsListSentCampaignsOutputSchema,
+ displayName: 'List Sent Campaigns',
+ description: 'Lists the most recently sent campaigns.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the most recently sent campaigns with their campaign keys, names and send times, newest first. Use it to find a sent campaign for Get Campaign Report or List Campaign Recipients.',
+ idempotent: true,
+ },
+ props: {
+ limit: Property.Number({
+ displayName: 'Limit',
+ description: 'How many sent campaigns to return. Defaults to 10.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.listSentCampaigns({ auth, limit: propsValue.limit ?? 10 });
+ const result = zohoCampaignsUtils.assertSuccess({ body });
+ return { ...result, recent_sent_campaigns: result.recent_sent_campaigns ?? null };
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-tags.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-tags.ts
new file mode 100644
index 00000000000..5c70e57debd
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-tags.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListTagsOutputSchema } from '../../output-schemas';
+
+const NO_TAGS_CODE = '992';
+
+export const listTagsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_tags',
+ outputSchema: zohoCampaignsListTagsOutputSchema,
+ displayName: 'List Tags',
+ description: 'Lists every contact tag with its description and contact count.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists every contact tag in the account with its tag ID, name, description, color, owner and how many contacts carry it. Tag actions identify tags by name. Returns an empty tags list when the account has no tags.',
+ idempotent: true,
+ },
+ props: {},
+ async run({ auth }) {
+ const body = await zohoCampaignsApi.getAllTags({ auth });
+ if (String(body.code) === NO_TAGS_CODE) {
+ return { tags: [] };
+ }
+ const tags = zohoCampaignsUtils.assertSuccess({ body }).tags ?? [];
+ return {
+ tags: tags.flatMap((tagMap) =>
+ Object.entries(tagMap).map(([tagId, tag]) => ({ tag_id: tagId, ...tag })),
+ ),
+ };
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-topics.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-topics.ts
new file mode 100644
index 00000000000..9acb436191b
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/list-topics.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsListTopicsOutputSchema } from '../../output-schemas';
+
+export const listTopicsAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_list_topics',
+ outputSchema: zohoCampaignsListTopicsOutputSchema,
+ displayName: 'List Topics',
+ description: 'Lists the subscription topics in the account.',
+ audience: 'ai',
+ classification: 'SEARCH',
+ aiMetadata: {
+ description:
+ 'Lists the subscription topics in the account with their topic IDs and names. Use a topic ID in Create Campaign, Subscribe Contact or Unsubscribe Contact.',
+ idempotent: true,
+ },
+ props: {
+ fromIndex: Property.Number({
+ displayName: 'From Index',
+ description: 'The 0-based position of the first record to return.',
+ required: false,
+ }),
+ range: Property.Number({
+ displayName: 'Range',
+ description: 'How many records to return.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.getTopics({
+ auth,
+ fromIndex: propsValue.fromIndex,
+ range: propsValue.range,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/remove-tag-from-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/remove-tag-from-contact.ts
new file mode 100644
index 00000000000..b9ec4fdacc7
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/remove-tag-from-contact.ts
@@ -0,0 +1,38 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const removeTagFromContactAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_remove_tag_from_contact',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Remove Tag from Contact',
+ description: 'Removes a tag from a contact.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Removes a tag (by name, from List Tags) from a contact matched by email. The tag itself stays; use Delete Tag to remove it from the account. Idempotent.',
+ idempotent: true,
+ },
+ props: {
+ tagName: Property.ShortText({
+ displayName: 'Tag Name',
+ description: 'Name of the tag, as shown by List Tags.',
+ required: true,
+ }),
+ email: zohoCampaignsAiProps.contactEmail({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.removeTag({
+ auth,
+ tagName: propsValue.tagName,
+ lead_email: propsValue.email,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/schedule-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/schedule-campaign.ts
new file mode 100644
index 00000000000..45daf1a29c4
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/schedule-campaign.ts
@@ -0,0 +1,95 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsSendCampaignOutputSchema } from '../../output-schemas';
+
+const HOURS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
+const MINUTES = ['00', '05', '10', '15', '20', '25', '30', '35', '40', '45', '50', '55'];
+
+export const scheduleCampaignAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_schedule_campaign',
+ displayName: 'Schedule Campaign',
+ description: 'Schedules a draft campaign to send at a set date and time.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Schedules a draft campaign (key from Create Campaign or List Campaigns) to send at a future date and time. Use Send Campaign to send now. Not idempotent; delete the campaign with Delete Campaign to cancel. Sending needs a sender domain with SPF and DKIM set up in Zoho; until then it fails with "Content not reviewed".',
+ idempotent: false,
+ },
+ outputSchema: zohoCampaignsSendCampaignOutputSchema,
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ scheduleDate: Property.ShortText({
+ displayName: 'Schedule Date',
+ description: 'Send date in mm/dd/yyyy format, e.g. "01/19/2027".',
+ required: true,
+ }),
+ scheduleHour: Property.StaticDropdown({
+ displayName: 'Hour',
+ description: 'Hour of the send time on a 12-hour clock (1-12).',
+ required: true,
+ options: {
+ disabled: false,
+ options: HOURS.map((hour) => ({ label: hour, value: hour })),
+ },
+ }),
+ scheduleMinute: Property.StaticDropdown({
+ displayName: 'Minute',
+ description: 'Minute of the send time, in 5-minute steps (00-55).',
+ required: true,
+ options: {
+ disabled: false,
+ options: MINUTES.map((minute) => ({ label: minute, value: minute })),
+ },
+ }),
+ amPm: Property.StaticDropdown<'AM' | 'PM', true>({
+ displayName: 'AM/PM',
+ description: 'Whether the hour is AM or PM.',
+ required: true,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'AM', value: 'AM' },
+ { label: 'PM', value: 'PM' },
+ ],
+ },
+ }),
+ sendingTZ: Property.ShortText({
+ displayName: 'Time Zone',
+ description:
+ 'IANA time zone of the send time, e.g. "Asia/Kolkata". Defaults to the account time zone.',
+ required: false,
+ }),
+ isTimeWarp: Property.StaticDropdown<boolean, false>({
+ displayName: 'Time Warp',
+ description:
+ "Yes delivers at the scheduled time in each recipient's own time zone. Leave unset for the account default.",
+ required: false,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Yes', value: true },
+ { label: 'No', value: false },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.scheduleCampaign({
+ auth,
+ campaignkey: propsValue.campaignKey,
+ scheduleDate: propsValue.scheduleDate,
+ scheduleHour: propsValue.scheduleHour,
+ scheduleMinute: propsValue.scheduleMinute,
+ amPm: propsValue.amPm,
+ isTimeWarp: propsValue.isTimeWarp,
+ sendingTZ: propsValue.sendingTZ,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/send-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/send-campaign.ts
new file mode 100644
index 00000000000..baf33f4c521
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/send-campaign.ts
@@ -0,0 +1,29 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsSendCampaignOutputSchema } from '../../output-schemas';
+
+export const sendCampaignAiAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_send_campaign',
+ displayName: 'Send Campaign',
+ description: 'Sends a draft campaign now.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sends a draft campaign (key from Create Campaign, Clone Campaign or List Campaigns) to its recipients immediately. Use Schedule Campaign to send later. Not idempotent and irreversible: emails go out to every recipient. Sending needs a sender domain with SPF and DKIM set up in Zoho; until then it fails with "Content not reviewed".',
+ idempotent: false,
+ },
+ outputSchema: zohoCampaignsSendCampaignOutputSchema,
+ props: {
+ campaignKey: zohoCampaignsAiProps.campaignKey({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.sendCampaign({ auth, campaignkey: propsValue.campaignKey });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/subscribe-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/subscribe-contact.ts
new file mode 100644
index 00000000000..5b41d68789e
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/subscribe-contact.ts
@@ -0,0 +1,59 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const subscribeContactAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_subscribe_contact',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Subscribe Contact',
+ description: 'Adds a contact to a mailing list, or updates the contact if it exists.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Adds a contact to a mailing list (key from List Mailing Lists), or updates the contact matched by email, setting standard fields and any field from List Contact Fields via Additional Fields. New contacts get a confirmation email and join the list only after they confirm; use Add Contacts to Mailing List to add contacts without confirmation. Idempotent upsert keyed on email.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ email: zohoCampaignsAiProps.contactEmail({ required: true }),
+ firstName: Property.ShortText({ displayName: 'First Name', required: false }),
+ lastName: Property.ShortText({ displayName: 'Last Name', required: false }),
+ phone: Property.ShortText({ displayName: 'Phone', required: false }),
+ companyName: Property.ShortText({ displayName: 'Company Name', required: false }),
+ additionalFields: Property.Json({
+ displayName: 'Additional Fields',
+ description:
+ 'Other contact fields keyed by display name from List Contact Fields, e.g. {"City": "Austin"}. The dedicated props above win over keys here.',
+ required: false,
+ }),
+ source: Property.ShortText({
+ displayName: 'Source',
+ description: 'Where the contact came from, stored as the contact source.',
+ required: false,
+ }),
+ topicId: zohoCampaignsAiProps.topicId({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.addUpdateContact({
+ auth,
+ listkey: propsValue.listKey,
+ contactinfo: zohoCampaignsUtils.contactInfo({
+ email: propsValue.email,
+ firstName: propsValue.firstName,
+ lastName: propsValue.lastName,
+ phone: propsValue.phone,
+ companyName: propsValue.companyName,
+ additionalFields: propsValue.additionalFields,
+ }),
+ source: propsValue.source,
+ topic_id: propsValue.topicId,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/unsubscribe-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/unsubscribe-contact.ts
new file mode 100644
index 00000000000..922cc6f06b6
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/unsubscribe-contact.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const unsubscribeContactAiAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_unsubscribe_contact',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Unsubscribe Contact',
+ description: 'Unsubscribes a contact from a mailing list.',
+ audience: 'ai',
+ classification: 'DESTRUCTIVE',
+ aiMetadata: {
+ description:
+ 'Unsubscribes a contact, matched by email, from a mailing list (key from List Mailing Lists), optionally only from one topic. The contact stays in the account. Idempotent: an unsubscribed contact stays unsubscribed.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ email: zohoCampaignsAiProps.contactEmail({ required: true }),
+ topicId: zohoCampaignsAiProps.topicId({ required: false }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.unsubscribeContact({
+ auth,
+ listkey: propsValue.listKey,
+ contactinfo: zohoCampaignsUtils.contactInfo({ email: propsValue.email }),
+ topic_id: propsValue.topicId,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/update-mailing-list.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/update-mailing-list.ts
new file mode 100644
index 00000000000..cc8300aab24
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/ai/update-mailing-list.ts
@@ -0,0 +1,41 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../../auth';
+import { zohoCampaignsAiProps } from '../../common/ai-props';
+import { zohoCampaignsApi } from '../../common/api';
+import { zohoCampaignsUtils } from '../../common/utils';
+import { zohoCampaignsStatusOutputSchema } from '../../output-schemas';
+
+export const updateMailingListAction = createAction({
+ auth: zohoCampaignsAuth,
+ name: 'zoho_campaigns_update_mailing_list',
+ outputSchema: zohoCampaignsStatusOutputSchema,
+ displayName: 'Update Mailing List',
+ description: 'Renames a mailing list and sets whether it has a public signup form.',
+ audience: 'ai',
+ classification: 'WRITE',
+ aiMetadata: {
+ description:
+ 'Sets the name and signup-form visibility of a mailing list (key from List Mailing Lists). Both are required, so pass the current name to change only the signup form. Idempotent: the same values leave the list unchanged.',
+ idempotent: true,
+ },
+ props: {
+ listKey: zohoCampaignsAiProps.listKey({ required: true }),
+ listName: Property.ShortText({
+ displayName: 'List Name',
+ description:
+ 'The name the list should have. Use letters, digits and spaces; Zoho rejects "&" and some other punctuation and accented letters.',
+ required: true,
+ }),
+ signupForm: zohoCampaignsAiProps.signupForm({ required: true }),
+ },
+ async run({ auth, propsValue }) {
+ const body = await zohoCampaignsApi.updateMailingList({
+ auth,
+ listkey: propsValue.listKey,
+ newlistname: propsValue.listName,
+ signupform: propsValue.signupForm,
+ });
+ return zohoCampaignsUtils.assertSuccess({ body });
+ },
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/clone-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/clone-campaign.ts
index af297730266..17f6e8dc89c 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/clone-campaign.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/clone-campaign.ts
@@ -1,49 +1,69 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsCloneCampaignOutputSchema } from '../output-schemas';
-export const cloneCampaign = createAction({
+export const cloneCampaignAction = createAction({
auth: zohoCampaignsAuth,
name: 'cloneCampaign',
+ outputSchema: zohoCampaignsCloneCampaignOutputSchema,
classification: 'WRITE',
displayName: 'Clone Campaign',
description: 'Clone an existing campaign, optionally renaming.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Duplicates an existing Zoho Campaigns campaign (identified by its campaign key) into a new draft, optionally overriding name, subject, sender name/address, reply-to, and encoding. Use to reuse a prior campaign as a starting point. Not idempotent: each call produces a new campaign.',
idempotent: false,
},
- props: zohoCampaignsCommon.cloneCampaignProperties(),
+ props: {
+ campaignkey: zohoCampaignsProps.campaignKey({ required: true }),
+ campaignname: Property.ShortText({
+ displayName: 'Campaign Name',
+ description: 'New name for the cloned campaign',
+ required: false,
+ }),
+ subject: Property.ShortText({
+ displayName: 'Subject',
+ description: 'New subject line for the cloned campaign',
+ required: false,
+ }),
+ from_name: Property.ShortText({
+ displayName: 'From Name',
+ description: 'Sender name for the cloned campaign',
+ required: false,
+ }),
+ from_add: Property.ShortText({
+ displayName: 'From Email',
+ description: 'Sender email address for the cloned campaign',
+ required: false,
+ }),
+ reply_to: Property.ShortText({
+ displayName: 'Reply-To Email',
+ description: 'Reply-to email address for the cloned campaign',
+ required: false,
+ }),
+ encode_type: Property.ShortText({
+ displayName: 'Encoding Type',
+ description: 'Email encoding type (e.g., UTF-8)',
+ required: false,
+ }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.cloneCampaignSchema
- );
- const {
- campaignkey,
- campaignname,
- subject,
- from_name,
- from_add,
- reply_to,
- encode_type,
- } = propsValue;
- const campaigninfo = {
- oldcampaignkey: campaignkey,
- ...(campaignname && { campaignname }),
- ...(subject && { subject }),
- ...(from_name && { from_name }),
- ...(from_add && { from_add }),
- ...(reply_to && { reply_to }),
- ...(encode_type && { encode_type }),
- };
- return await zohoCampaignsCommon.cloneCampaign({
- accessToken,
- location,
- campaigninfo,
- });
+ await propsValidation.validateZod(propsValue, schema);
+ return await zohoCampaignsApi.cloneCampaign({ auth, ...propsValue });
},
});
+
+const schema = {
+ campaignkey: z.string(),
+ campaignname: z.optional(z.string()),
+ subject: z.optional(z.string()),
+ from_name: z.optional(z.string()),
+ from_add: z.optional(z.string().check(z.email())),
+ reply_to: z.optional(z.string().check(z.email())),
+ encode_type: z.optional(z.string()),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/create-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/create-campaign.ts
index 78fee9bf4bf..e1b44b5d434 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/create-campaign.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/create-campaign.ts
@@ -1,38 +1,64 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
-export const createCampaign = createAction({
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsCreateCampaignOutputSchema } from '../output-schemas';
+
+export const createCampaignAction = createAction({
auth: zohoCampaignsAuth,
name: 'createCampaign',
+ outputSchema: zohoCampaignsCreateCampaignOutputSchema,
classification: 'WRITE',
displayName: 'Create Campaign',
description:
'Create a new campaign with campaign name, subject, topic, sender name/address, and mailing list.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Creates a new draft email campaign in Zoho Campaigns with the given name, subject, sender name/address, topic, and target mailing list(s). Use to set up a campaign before sending or cloning it. Not idempotent: each call creates a separate campaign even with identical inputs.',
idempotent: false,
},
- props: zohoCampaignsCommon.createCampaignProperties(),
+ props: {
+ campaignname: Property.ShortText({
+ displayName: 'Campaign Name',
+ description: 'A name to your campaign',
+ required: true,
+ }),
+ from_email: Property.ShortText({
+ displayName: 'From Email',
+ description: 'Sender email address for the campaign',
+ required: true,
+ }),
+ subject: Property.ShortText({
+ displayName: 'Subject',
+ description: 'The subject line of the campaign',
+ required: true,
+ }),
+ list_details: zohoCampaignsProps.listKeys({ required: true }),
+ content_url: Property.ShortText({
+ displayName: 'Content URL',
+ description: 'Public URL containing the HTML content for your campaign',
+ required: false,
+ }),
+ topicId: zohoCampaignsProps.topicId({ required: false }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token ;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.createCampaignSchema
- );
- const list_details =
- propsValue.list_details?.reduce((acc, curr) => {
- acc[curr] = [];
- return acc;
- }, {} as { [key: string]: [] }) || {};
-
- return await zohoCampaignsCommon.createCampaign({
- accessToken,
- location,
+ await propsValidation.validateZod(propsValue, schema);
+ return await zohoCampaignsApi.createCampaign({
+ auth,
...propsValue,
- list_details,
+ list_details: propsValue.list_details ?? [],
});
},
});
+
+const schema = {
+ campaignname: z.string(),
+ from_email: z.string().check(z.email()),
+ subject: z.string(),
+ content_url: z.optional(z.string().check(z.url())),
+ list_details: z.array(z.string()),
+ topicId: z.optional(z.nullable(z.string())),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/find-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/find-campaign.ts
index 6646fae13c0..bc93151ffce 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/find-campaign.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/find-campaign.ts
@@ -1,45 +1,90 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import type {
+ ZohoCampaignsCampaignStatus,
+ ZohoCampaignsSort,
+} from '../common/types';
+import { zohoCampaignsFindCampaignOutputSchema } from '../output-schemas';
-export const findCampaign = createAction({
+export const findCampaignAction = createAction({
auth: zohoCampaignsAuth,
name: 'findCampaign',
+ outputSchema: zohoCampaignsFindCampaignOutputSchema,
classification: 'SEARCH',
displayName: 'Find Campaign',
description: 'Locate an existing campaign by campaign name.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Searches recent campaigns in the account and returns those whose name contains the supplied value (case-insensitive partial match); an empty name effectively returns all campaigns, optionally filtered by status and paginated. Use to resolve a campaign key or browse campaigns. Read-only and idempotent; throws if no campaign matches.',
idempotent: true,
},
- props: zohoCampaignsCommon.findCampaignProperties(),
+ props: {
+ campaignName: Property.ShortText({
+ displayName: 'Campaign Name',
+ description:
+ 'Name of the campaign to be found (partial matches supported)',
+ required: true,
+ }),
+ status: Property.StaticDropdown<ZohoCampaignsCampaignStatus, false>({
+ displayName: 'Campaign Status',
+ description: 'Filter campaigns by status (optional)',
+ required: false,
+ options: {
+ options: [
+ { label: 'All', value: 'all' },
+ { label: 'All Campaigns', value: 'all campaigns' },
+ { label: 'Drafts', value: 'drafts' },
+ { label: 'Scheduled', value: 'scheduled' },
+ { label: 'In Progress', value: 'inprogress' },
+ { label: 'Sent', value: 'sent' },
+ { label: 'Stopped', value: 'stopped' },
+ { label: 'Canceled', value: 'canceled' },
+ { label: 'To Be Reviewed', value: 'tobereviewed' },
+ { label: 'Reviewed', value: 'reviewed' },
+ { label: 'Paused', value: 'paused' },
+ { label: 'In Testing', value: 'intesting' },
+ ],
+ },
+ }),
+ sort: Property.StaticDropdown<ZohoCampaignsSort, false>({
+ displayName: 'Sort Order',
+ description: 'Sort order for results (optional)',
+ required: false,
+ options: {
+ options: [
+ { label: 'Ascending', value: 'asc' },
+ { label: 'Descending', value: 'desc' },
+ ],
+ },
+ }),
+ fromindex: Property.Number({
+ displayName: 'From Index',
+ description: 'Starting index for pagination (optional, default: 1)',
+ required: false,
+ }),
+ range: Property.Number({
+ displayName: 'Range',
+ description: 'Number of campaigns to retrieve (optional, default: 5)',
+ required: false,
+ }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.findCampaignSchema
- );
+ await propsValidation.validateZod(propsValue, schema);
const { campaignName, status, sort, fromindex, range } = propsValue;
- const searchParams: any = {
- accessToken,
- };
-
- if (status) searchParams.status = status;
- if (sort) searchParams.sort = sort;
- if (fromindex) searchParams.fromindex = fromindex;
- if (range) searchParams.range = range;
-
- const campaigns = await zohoCampaignsCommon.listCampaigns({
- ...searchParams,
- location
+ const campaigns = await zohoCampaignsApi.listCampaigns({
+ auth,
+ ...(status && { status }),
+ ...(sort && { sort }),
+ ...(fromindex && { fromindex }),
+ ...(range && { range }),
});
const needle = (campaignName ?? '').trim().toLowerCase();
- // Try to find case-insensitive and partial match
const matchingCampaigns = campaigns.filter((campaign) =>
(campaign.campaign_name ?? '').toLowerCase().includes(needle)
);
@@ -54,3 +99,26 @@ export const findCampaign = createAction({
return matchingCampaigns;
},
});
+
+const schema = {
+ campaignName: z.string(),
+ status: z.optional(
+ z.enum([
+ 'all',
+ 'all campaigns',
+ 'drafts',
+ 'scheduled',
+ 'inprogress',
+ 'sent',
+ 'stopped',
+ 'canceled',
+ 'tobereviewed',
+ 'reviewed',
+ 'paused',
+ 'intesting',
+ ])
+ ),
+ sort: z.optional(z.enum(['asc', 'desc'])),
+ fromindex: z.optional(z.number().check(z.minimum(1))),
+ range: z.optional(z.number().check(z.minimum(1))),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/find-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/find-contact.ts
index 69432ba11af..c444adc648d 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/find-contact.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/find-contact.ts
@@ -1,27 +1,74 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import type {
+ ZohoCampaignsContactStatus,
+ ZohoCampaignsSort,
+} from '../common/types';
+import { zohoCampaignsFindContactOutputSchema } from '../output-schemas';
-export const findContact = createAction({
+export const findContactAction = createAction({
auth: zohoCampaignsAuth,
name: 'findContact',
+ outputSchema: zohoCampaignsFindContactOutputSchema,
classification: 'SEARCH',
displayName: 'Find Contact',
description: 'Look up an existing contact by email address.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Searches subscribers of a given mailing list and returns those whose email contains the supplied value (case-insensitive partial match); an empty email value effectively returns all contacts in the list, optionally filtered by subscription status and paginated. Use to resolve a contact or browse list members. Read-only and idempotent; throws if no contact matches.',
idempotent: true,
},
- props: zohoCampaignsCommon.findContactProperties(),
+ props: {
+ listkey: zohoCampaignsProps.listKey({ required: true }),
+ contactEmail: Property.ShortText({
+ displayName: 'Contact Email',
+ description:
+ 'Email of the contact to be found (partial matches supported)',
+ required: true,
+ }),
+ status: Property.StaticDropdown<ZohoCampaignsContactStatus, true>({
+ displayName: 'Contact Status',
+ description: 'Filter contacts by status',
+ required: true,
+ options: {
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Recent', value: 'recent' },
+ { label: 'Most Recent', value: 'most recent' },
+ { label: 'Unsubscribed', value: 'unsub' },
+ { label: 'Bounced', value: 'bounce' },
+ ],
+ },
+ }),
+ sort: Property.StaticDropdown<ZohoCampaignsSort, true>({
+ displayName: 'Sort Order',
+ description: 'Sort order for results',
+ required: true,
+ options: {
+ options: [
+ { label: 'Ascending', value: 'asc' },
+ { label: 'Descending', value: 'desc' },
+ ],
+ },
+ }),
+ fromindex: Property.Number({
+ displayName: 'From Index',
+ description: 'Starting index for pagination (optional, default: 1)',
+ required: false,
+ }),
+ range: Property.Number({
+ displayName: 'Range',
+ description: 'Number of contacts to retrieve (optional, default: all)',
+ required: false,
+ }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.findContactSchema
- );
+ await propsValidation.validateZod(propsValue, schema);
const {
listkey,
contactEmail: email,
@@ -31,23 +78,16 @@ export const findContact = createAction({
range,
} = propsValue;
- const searchParams: any = {
- accessToken,
- listkey: listkey as string,
- };
-
- if (status) searchParams.status = status;
- if (sort) searchParams.sort = sort;
- if (fromindex) searchParams.fromindex = fromindex;
- if (range) searchParams.range = range;
-
- const contacts = await zohoCampaignsCommon.listContacts({
- ...searchParams,
- location,
+ const contacts = await zohoCampaignsApi.listContacts({
+ auth,
+ listkey,
+ ...(status && { status }),
+ ...(sort && { sort }),
+ ...(fromindex && { fromindex }),
+ ...(range && { range }),
});
const needle = (email ?? '').trim().toLowerCase();
- // Try to find case-insensitive and partial match
const matchingContacts = contacts.filter((contact) =>
(contact.contact_email ?? '').toLowerCase().includes(needle)
);
@@ -62,3 +102,14 @@ export const findContact = createAction({
return matchingContacts;
},
});
+
+const schema = {
+ listkey: z.string(),
+ contactEmail: z.string().check(z.email()),
+ status: z.optional(
+ z.enum(['active', 'recent', 'most recent', 'unsub', 'bounce'])
+ ),
+ sort: z.optional(z.enum(['asc', 'desc'])),
+ fromindex: z.optional(z.number().check(z.minimum(1))),
+ range: z.optional(z.number().check(z.minimum(1))),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/remove-tag.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/remove-tag.ts
index 3841f8df075..785ad2e76d0 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/remove-tag.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/remove-tag.ts
@@ -1,31 +1,39 @@
import { propsValidation } from '@activepieces/pieces-common';
-import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { createAction, Property } from '@activepieces/pieces-framework';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsStatusOutputSchema } from '../output-schemas';
-export const removeTag = createAction({
+export const removeTagAction = createAction({
auth: zohoCampaignsAuth,
name: 'removeTag',
+ outputSchema: zohoCampaignsStatusOutputSchema,
classification: 'WRITE',
displayName: 'Remove Tag',
description: 'Remove a tag from a contact.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Removes a tag from a contact. Use to unlabel or de-segment a subscriber. Idempotent: once the tag is gone, repeating the call leaves the contact in the same untagged state.',
idempotent: true,
},
- props: zohoCampaignsCommon.removeTagProperties,
+ props: {
+ tagName: zohoCampaignsProps.tagName({ required: true }),
+ lead_email: Property.ShortText({
+ displayName: 'Contact Email',
+ description: 'Email address of the contact to remove the tag from',
+ required: true,
+ }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.removeTagSchema
- );
- return await zohoCampaignsCommon.removeTag({
- accessToken,
- location,
- ...propsValue,
- });
+ await propsValidation.validateZod(propsValue, schema);
+ return await zohoCampaignsApi.removeTag({ auth, ...propsValue });
},
});
+
+const schema = {
+ tagName: z.string(),
+ lead_email: z.string().check(z.email()),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/send-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/send-campaign.ts
index ca360e18f16..c747c405633 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/send-campaign.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/send-campaign.ts
@@ -1,32 +1,36 @@
import { propsValidation } from '@activepieces/pieces-common';
import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsSendCampaignOutputSchema } from '../output-schemas';
-export const sendCampaign = createAction({
+export const sendCampaignAction = createAction({
auth: zohoCampaignsAuth,
name: 'sendCampaign',
+ outputSchema: zohoCampaignsSendCampaignOutputSchema,
classification: 'WRITE',
displayName: 'Send Campaign',
description: 'Send a campaign that has been created or cloned.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Sends an existing draft campaign (identified by its campaign key) to its configured mailing list recipients. Use after a campaign has been created or cloned and is ready to go out. Not idempotent and has an irreversible side effect: it dispatches email to subscribers.',
idempotent: false,
},
- props: zohoCampaignsCommon.sendCampaignProperties(),
+ props: {
+ campaignkey: zohoCampaignsProps.campaignKey({ required: true }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.sendCampaignSchema
- );
- const { campaignkey } = propsValue;
- return await zohoCampaignsCommon.sendCampaign({
- accessToken,
- location,
- campaignkey: campaignkey as string,
+ await propsValidation.validateZod(propsValue, schema);
+ return await zohoCampaignsApi.sendCampaign({
+ auth,
+ campaignkey: propsValue.campaignkey,
});
},
});
+
+const schema = {
+ campaignkey: z.string(),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/actions/unsubscribe-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/actions/unsubscribe-contact.ts
index 43b6220e43a..910984dffbc 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/actions/unsubscribe-contact.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/actions/unsubscribe-contact.ts
@@ -1,38 +1,48 @@
import { propsValidation } from '@activepieces/pieces-common';
import { createAction } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import * as z from 'zod/mini';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsStatusOutputSchema } from '../output-schemas';
-export const unsubscribeContact = createAction({
+export const unsubscribeContactAction = createAction({
auth: zohoCampaignsAuth,
name: 'unsubscribeContact',
+ outputSchema: zohoCampaignsStatusOutputSchema,
classification: 'DESTRUCTIVE',
displayName: 'Unsubscribe Contact',
description: 'Remove a contact from a mailing list.',
- audience: 'both',
+ audience: 'human',
aiMetadata: {
description:
'Unsubscribes a contact (matched by email) from a specified mailing list, optionally scoped to a particular topic. Use to opt a subscriber out of a list or topic. Idempotent: an already-unsubscribed contact stays unsubscribed on repeat calls.',
idempotent: true,
},
- props: zohoCampaignsCommon.unsubscribeContactProperties(),
+ props: {
+ listkey: zohoCampaignsProps.listKey({ required: true }),
+ contactinfo: zohoCampaignsProps.contactInfo({ required: true }),
+ topic_id: zohoCampaignsProps.topicId({ required: false }),
+ },
async run({ auth, propsValue }) {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- await propsValidation.validateZod(
- propsValue,
- zohoCampaignsCommon.unsubscribeContactSchema
- );
+ await propsValidation.validateZod(propsValue, schema);
const { additionalFields, ...baseFields } = propsValue.contactinfo;
-
- return await zohoCampaignsCommon.unsubscribeContact({
- accessToken,
- location,
- listkey: String(propsValue.listkey),
+ return await zohoCampaignsApi.unsubscribeContact({
+ auth,
+ listkey: propsValue.listkey,
contactinfo: {
...baseFields,
...additionalFields,
},
- ...(propsValue.topic_id && { topic_id: propsValue.topic_id }),
+ topic_id: propsValue.topic_id,
});
},
});
+
+const schema = {
+ listkey: z.string(),
+ contactinfo: z.object({
+ 'Contact Email': z.string().check(z.email()),
+ }),
+ topic_id: z.optional(z.nullable(z.string())),
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/auth.ts b/packages/pieces/community/zoho-campaigns/src/lib/auth.ts
new file mode 100644
index 00000000000..120fb49dc08
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/auth.ts
@@ -0,0 +1,45 @@
+import { OAuth2GrantType, PieceAuth, Property } from '@activepieces/pieces-framework';
+
+export const zohoCampaignsAuth = PieceAuth.OAuth2({
+ props: {
+ location: Property.StaticDropdown({
+ displayName: 'Data Center',
+ description: 'The data center location of your Zoho Campaigns account',
+ required: true,
+ options: {
+ options: [
+ {
+ label: 'zoho.com (United States)',
+ value: 'zoho.com',
+ },
+ {
+ label: 'zoho.eu (Europe)',
+ value: 'zoho.eu',
+ },
+ {
+ label: 'zoho.in (India)',
+ value: 'zoho.in',
+ },
+ {
+ label: 'zoho.com.au (Australia)',
+ value: 'zoho.com.au',
+ },
+ {
+ label: 'zoho.jp (Japan)',
+ value: 'zoho.jp',
+ },
+ {
+ label: 'zoho.com.cn (China)',
+ value: 'zoho.com.cn',
+ },
+ ],
+ },
+ }),
+ },
+ description: 'Connect your Zoho Campaigns account using OAuth2',
+ grantType: OAuth2GrantType.AUTHORIZATION_CODE,
+ required: true,
+ authUrl: 'https://accounts.{location}/oauth/v2/auth',
+ tokenUrl: 'https://accounts.{location}/oauth/v2/token',
+ scope: ['ZohoCampaigns.campaign.ALL', 'ZohoCampaigns.contact.ALL'],
+});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/ai-props.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/ai-props.ts
new file mode 100644
index 00000000000..f82a5663e20
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/common/ai-props.ts
@@ -0,0 +1,101 @@
+import { Property } from '@activepieces/pieces-framework';
+
+import type { PropParams } from './props';
+import type { ZohoCampaignsSignupForm, ZohoCampaignsSort } from './types';
+
+function campaignKey<R extends boolean>({
+ required,
+ displayName = 'Campaign Key',
+ description = 'The campaign key, e.g. "f70c4878c4a47169407e63917ad24497". Use List Campaigns or Create Campaign to get it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function listKey<R extends boolean>({
+ required,
+ displayName = 'Mailing List Key',
+ description = 'The mailing list key, e.g. "3c20ad524dfa4af86216a5be13e238ed". Use List Mailing Lists or Create Mailing List to get it.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function contactEmail<R extends boolean>({
+ required,
+ displayName = 'Contact Email',
+ description = 'Email address of the contact.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function topicId<R extends boolean>({
+ required,
+ displayName = 'Topic ID',
+ description = 'Topic ID from List Topics. Required on accounts that use topic management.',
+}: PropParams<R>) {
+ return Property.ShortText({ displayName, description, required });
+}
+
+function signupForm<R extends boolean>({
+ required,
+ displayName = 'Signup Form',
+ description = 'public lets people join the list through a signup form; private does not.',
+}: PropParams<R>) {
+ return Property.StaticDropdown<ZohoCampaignsSignupForm, R>({
+ displayName,
+ description,
+ required,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Public', value: 'public' },
+ { label: 'Private', value: 'private' },
+ ],
+ },
+ });
+}
+
+function fromIndex<R extends boolean>({
+ required,
+ displayName = 'From Index',
+ description = 'The 1-based position of the first record to return. Defaults to 1.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function range<R extends boolean>({
+ required,
+ displayName = 'Range',
+ description = 'How many records to return from From Index. Zoho Campaigns applies its own default when unset.',
+}: PropParams<R>) {
+ return Property.Number({ displayName, description, required });
+}
+
+function sort<R extends boolean>({
+ required,
+ displayName = 'Sort Order',
+ description = 'Sort order of the results: asc or desc.',
+}: PropParams<R>) {
+ return Property.StaticDropdown<ZohoCampaignsSort, R>({
+ displayName,
+ description,
+ required,
+ options: {
+ disabled: false,
+ options: [
+ { label: 'Ascending', value: 'asc' },
+ { label: 'Descending', value: 'desc' },
+ ],
+ },
+ });
+}
+
+export const zohoCampaignsAiProps = {
+ campaignKey,
+ listKey,
+ contactEmail,
+ topicId,
+ signupForm,
+ fromIndex,
+ range,
+ sort,
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/api.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/api.ts
new file mode 100644
index 00000000000..052520c01fe
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/common/api.ts
@@ -0,0 +1,836 @@
+import { HttpMethod } from '@activepieces/pieces-common';
+
+import { zohoCampaignsClient } from './client';
+
+import type {
+ ZohoCampaignsAuthValue,
+ ZohoCampaignsCampaign,
+ ZohoCampaignsCampaignStatus,
+ ZohoCampaignsContact,
+ ZohoCampaignsContactStatus,
+ ZohoCampaignsCreateCampaignResponse,
+ ZohoCampaignsListCampaignsResponse,
+ ZohoCampaignsListContactsResponse,
+ ZohoCampaignsListMailingListsResponse,
+ ZohoCampaignsListSentCampaignsResponse,
+ ZohoCampaignsListTagsResponse,
+ ZohoCampaignsListTopicsResponse,
+ ZohoCampaignsMailingList,
+ ZohoCampaignsRecipientAction,
+ ZohoCampaignsResponse,
+ ZohoCampaignsSignupForm,
+ ZohoCampaignsSort,
+ ZohoCampaignsTag,
+ ZohoCampaignsTopic,
+} from './types';
+
+async function createCampaign({
+ auth,
+ list_details: listKeys,
+ topicId,
+ segments,
+ ...restParams
+}: CreateCampaignParams & {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsCreateCampaignResponse> {
+ const list_details = listKeys
+ ? JSON.stringify(
+ listKeys.reduce<Record<string, never[]>>((acc, curr) => {
+ acc[curr] = [];
+ return acc;
+ }, {}),
+ )
+ : undefined;
+ const body = new URLSearchParams({
+ resfmt: 'json',
+ ...(list_details && { list_details }),
+ ...restParams,
+ ...(topicId && { topicId }),
+ ...(segments && { segments: `[${segments.join(',')}]` }),
+ }).toString();
+ return await zohoCampaignsClient.request<ZohoCampaignsCreateCampaignResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/createCampaign',
+ headers: FORM_HEADERS,
+ body,
+ });
+}
+
+async function createTag({
+ auth,
+ tagName,
+ tagDesc,
+ color,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ tagName: string;
+ tagDesc?: string;
+ color?: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/tag/add',
+ query: { ...BASE_PARAMS, tagName, ...(tagDesc && { tagDesc }), ...(color && { color }) },
+ });
+}
+
+async function ensureTag({
+ auth,
+ tagName,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ tagName: string;
+}): Promise<{ created: boolean }> {
+ const tags = await listTags({ auth });
+ const tagExists =
+ tags !== undefined &&
+ tags.some((tagMap) => Object.values(tagMap).some((t) => t.tag_name === tagName));
+ if (tagExists) {
+ return { created: false };
+ }
+ const response = await createTag({ auth, tagName });
+ return { created: response.status === 'success' };
+}
+
+async function deleteTag({
+ auth,
+ tagName,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ tagName: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/tag/delete',
+ query: { ...BASE_PARAMS, tagName },
+ });
+}
+
+async function cloneCampaign({
+ auth,
+ campaignkey,
+ campaignname,
+ subject,
+ from_name,
+ from_add,
+ reply_to,
+ encode_type,
+}: CloneCampaignParams & { auth: ZohoCampaignsAuthValue }): Promise<ZohoCampaignsResponse> {
+ const campaigninfo = {
+ oldcampaignkey: campaignkey,
+ ...(campaignname && { campaignname }),
+ ...(subject && { subject }),
+ ...(from_name && { from_name }),
+ ...(from_add && { from_add }),
+ ...(reply_to && { reply_to }),
+ ...(encode_type && { encode_type }),
+ };
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/json/clonecampaign',
+ query: { ...BASE_PARAMS, campaigninfo: JSON.stringify(campaigninfo) },
+ });
+}
+
+async function sendCampaign({
+ auth,
+ campaignkey,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ campaignkey: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/sendcampaign',
+ headers: FORM_HEADERS,
+ query: { ...BASE_PARAMS, campaignkey },
+ });
+}
+
+async function addUpdateContact({
+ auth,
+ listkey,
+ contactinfo,
+ source,
+ topic_id,
+}: AddUpdateContactParams & { auth: ZohoCampaignsAuthValue }): Promise<ZohoCampaignsResponse> {
+ const body = new URLSearchParams({
+ ...BASE_PARAMS,
+ listkey,
+ ...(source && { source }),
+ ...(topic_id && { topic_id }),
+ contactinfo: JSON.stringify(contactinfo),
+ }).toString();
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/json/listsubscribe',
+ headers: FORM_HEADERS,
+ body,
+ });
+}
+
+async function addTagToContact({
+ auth,
+ tagName,
+ lead_email,
+}: TagContactParams & { auth: ZohoCampaignsAuthValue }): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/tag/associate',
+ query: { ...BASE_PARAMS, tagName, lead_email },
+ });
+}
+
+async function removeTag({
+ auth,
+ tagName,
+ lead_email,
+}: TagContactParams & { auth: ZohoCampaignsAuthValue }): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/tag/deassociate',
+ query: { ...BASE_PARAMS, tagName, lead_email },
+ });
+}
+
+async function unsubscribeContact({
+ auth,
+ listkey,
+ contactinfo,
+ topic_id,
+}: UnsubscribeContactParams & {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsResponse> {
+ const body = new URLSearchParams({
+ ...BASE_PARAMS,
+ listkey,
+ ...(topic_id && { topic_id }),
+ contactinfo: JSON.stringify(contactinfo),
+ }).toString();
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/json/listunsubscribe',
+ headers: FORM_HEADERS,
+ body,
+ });
+}
+
+async function addContactsToMailingList({
+ auth,
+ listkey,
+ emailids,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ listkey: string;
+ emailids: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/addlistsubscribersinbulk',
+ query: { ...BASE_PARAMS, listkey, emailids },
+ });
+}
+
+async function listContacts(
+ params: ListContactsParams & { auth: ZohoCampaignsAuthValue },
+): Promise<ZohoCampaignsContact[]> {
+ const response = await getListSubscribers(params);
+ return response.list_of_details || [];
+}
+
+async function getListSubscribers({
+ auth,
+ listkey,
+ sort,
+ status,
+ fromindex,
+ range,
+}: ListContactsParams & {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsListContactsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsListContactsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/getlistsubscribers',
+ query: {
+ ...BASE_PARAMS,
+ listkey,
+ ...pagingQuery({ fromindex, range }),
+ ...(sort && { sort }),
+ ...(status && { status }),
+ },
+ });
+}
+
+async function listCampaigns(
+ params: ListCampaignsParams & { auth: ZohoCampaignsAuthValue },
+): Promise<ZohoCampaignsCampaign[]> {
+ const response = await getRecentCampaigns(params);
+ return response.recent_campaigns || [];
+}
+
+async function getRecentCampaigns({
+ auth,
+ sort,
+ status,
+ fromindex,
+ range,
+}: ListCampaignsParams & {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsListCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsListCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/recentcampaigns',
+ query: {
+ ...BASE_PARAMS,
+ ...pagingQuery({ fromindex, range }),
+ ...(sort && { sort }),
+ ...(status && { status }),
+ },
+ });
+}
+
+async function listMailingLists(
+ params: ListMailingListsParams & { auth: ZohoCampaignsAuthValue },
+): Promise<ZohoCampaignsMailingList[]> {
+ const response = await getMailingLists(params);
+ return response.list_of_details || [];
+}
+
+async function getMailingLists({
+ auth,
+ sort,
+ fromindex,
+ range,
+}: ListMailingListsParams & {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsListMailingListsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsListMailingListsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/getmailinglists',
+ query: {
+ ...BASE_PARAMS,
+ ...pagingQuery({ fromindex, range }),
+ ...(sort && { sort }),
+ },
+ });
+}
+
+async function getMailingListDetails({
+ auth,
+ listkey,
+ filtertype,
+ fromindex,
+ range,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ listkey: string;
+ filtertype?: 'sentcampaigns' | 'scheduledcampaigns' | 'recentcampaigns';
+ fromindex?: number;
+ range?: number;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/getlistadvanceddetails',
+ query: {
+ ...BASE_PARAMS,
+ listkey,
+ ...(filtertype && { filtertype }),
+ ...pagingQuery({ fromindex, range }),
+ },
+ });
+}
+
+async function listContactFields({
+ auth,
+}: {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/contact/allfields',
+ query: { type: 'json' },
+ });
+}
+
+async function updateMailingList({
+ auth,
+ listkey,
+ newlistname,
+ signupform,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ listkey: string;
+ newlistname: string;
+ signupform: ZohoCampaignsSignupForm;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/updatelistdetails',
+ query: { ...BASE_PARAMS, listkey, newlistname, signupform },
+ });
+}
+
+async function deleteMailingList({
+ auth,
+ listkey,
+ deletecontacts,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ listkey: string;
+ deletecontacts?: 'on' | 'off';
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/deletemailinglist',
+ query: { ...BASE_PARAMS, listkey, ...(deletecontacts && { deletecontacts }) },
+ });
+}
+
+async function countContacts({
+ auth,
+ listkey,
+ status,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ listkey: string;
+ status?: 'active' | 'unsub' | 'bounce' | 'spam';
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/listsubscriberscount',
+ query: { ...BASE_PARAMS, listkey, ...(status && { status }) },
+ });
+}
+
+async function addContactToDoNotMail({
+ auth,
+ contactinfo,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ contactinfo: Record<string, unknown>;
+}): Promise<ZohoCampaignsResponse> {
+ const body = new URLSearchParams({
+ ...BASE_PARAMS,
+ contactinfo: JSON.stringify(contactinfo),
+ }).toString();
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/json/contactdonotmail',
+ headers: FORM_HEADERS,
+ body,
+ });
+}
+
+async function createMailingList({
+ auth,
+ listname,
+ signupform,
+ listdescription,
+ emailids,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ listname: string;
+ signupform: ZohoCampaignsSignupForm;
+ listdescription?: string;
+ emailids: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/addlistandcontacts',
+ headers: FORM_HEADERS,
+ query: {
+ ...BASE_PARAMS,
+ listname,
+ signupform,
+ mode: 'newlist',
+ emailids,
+ ...(listdescription && { listdescription }),
+ },
+ });
+}
+
+async function createCustomField({
+ auth,
+ fieldname,
+ fieldtype,
+ fieldlength,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ fieldname: string;
+ fieldtype: string;
+ fieldlength?: number;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/custom/add',
+ headers: FORM_HEADERS,
+ query: {
+ type: 'json',
+ fieldname,
+ fieldtype,
+ ...(fieldlength !== undefined && { fieldlength: String(fieldlength) }),
+ },
+ });
+}
+
+async function listTopics({
+ auth,
+}: {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsTopic[]> {
+ const response = await getTopics({ auth });
+ return response.topicDetails;
+}
+
+async function getTopics({
+ auth,
+ fromIndex,
+ range,
+}: TopicPagingParams & { auth: ZohoCampaignsAuthValue }): Promise<ZohoCampaignsListTopicsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsListTopicsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/topics',
+ query: { ...BASE_PARAMS, ...topicPagingQuery({ fromIndex, range }) },
+ });
+}
+
+async function createTopic({
+ auth,
+ topicName,
+ topicDesc,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ topicName: string;
+ topicDesc: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/topics',
+ query: {
+ ...BASE_PARAMS,
+ details: JSON.stringify({
+ topic_name: topicName,
+ topic_desc: topicDesc,
+ }),
+ },
+ });
+}
+
+async function listTags({
+ auth,
+}: {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsTag[] | undefined> {
+ const response = await getAllTags({ auth });
+ return response.tags;
+}
+
+async function getAllTags({
+ auth,
+}: {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsListTagsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsListTagsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/tag/getalltags',
+ query: { ...BASE_PARAMS },
+ });
+}
+
+function topicPagingQuery({ fromIndex, range }: TopicPagingParams): Record<string, string> {
+ if (fromIndex === undefined && range === undefined) {
+ return {};
+ }
+ return {
+ details: JSON.stringify({
+ ...(fromIndex !== undefined && { from_index: fromIndex }),
+ ...(range !== undefined && { range }),
+ }),
+ };
+}
+
+async function getCampaignDetails({
+ auth,
+ campaignkey,
+ campaigntype,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ campaignkey: string;
+ campaigntype?: 'normal' | 'abtesting';
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/getcampaigndetails',
+ query: { ...BASE_PARAMS, campaignkey, ...(campaigntype && { campaigntype }) },
+ });
+}
+
+async function scheduleCampaign({
+ auth,
+ campaignkey,
+ scheduleDate,
+ scheduleHour,
+ scheduleMinute,
+ amPm,
+ isTimeWarp,
+ sendingTZ,
+}: ScheduleCampaignParams & { auth: ZohoCampaignsAuthValue }): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/sendcampaign',
+ headers: FORM_HEADERS,
+ query: {
+ ...BASE_PARAMS,
+ isschedule: 'true',
+ campaignkey,
+ scheduleDate,
+ scheduleHour,
+ scheduleMinute,
+ am_pm: amPm,
+ ...(isTimeWarp !== undefined && { istimewarp: String(isTimeWarp) }),
+ ...(sendingTZ && { sendingTZ }),
+ },
+ });
+}
+
+async function getCampaignReport({
+ auth,
+ campaignkey,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ campaignkey: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/campaignreports',
+ query: { ...BASE_PARAMS, campaignkey },
+ });
+}
+
+async function listSentCampaigns({
+ auth,
+ limit,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ limit: number;
+}): Promise<ZohoCampaignsListSentCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsListSentCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/recentsentcampaigns',
+ query: { ...BASE_PARAMS, limit: String(limit) },
+ });
+}
+
+async function getLastCampaignReport({
+ auth,
+}: {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/getlastcampaignreport',
+ headers: FORM_HEADERS,
+ query: { ...BASE_PARAMS },
+ });
+}
+
+async function listCampaignRecipients({
+ auth,
+ campaignkey,
+ action,
+ fromindex,
+ range,
+}: ListCampaignRecipientsParams & {
+ auth: ZohoCampaignsAuthValue;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.POST,
+ path: '/getcampaignrecipientsdata',
+ headers: FORM_HEADERS,
+ query: { ...BASE_PARAMS, campaignkey, action, ...pagingQuery({ fromindex, range }) },
+ });
+}
+
+async function deleteCampaign({
+ auth,
+ campaignkey,
+}: {
+ auth: ZohoCampaignsAuthValue;
+ campaignkey: string;
+}): Promise<ZohoCampaignsResponse> {
+ return await zohoCampaignsClient.request<ZohoCampaignsResponse>({
+ auth,
+ method: HttpMethod.GET,
+ path: '/deletecampaign',
+ query: { ...BASE_PARAMS, campaignkey },
+ });
+}
+
+function pagingQuery({
+ fromindex,
+ range,
+}: {
+ fromindex?: number;
+ range?: number;
+}): Record<string, string> {
+ return {
+ ...(fromindex && { fromindex: String(fromindex) }),
+ ...(range && { range: String(range) }),
+ };
+}
+
+export const zohoCampaignsApi = {
+ createCampaign,
+ createTag,
+ cloneCampaign,
+ sendCampaign,
+ addUpdateContact,
+ addTagToContact,
+ removeTag,
+ unsubscribeContact,
+ addContactsToMailingList,
+ listContacts,
+ listCampaigns,
+ getRecentCampaigns,
+ getCampaignDetails,
+ scheduleCampaign,
+ getCampaignReport,
+ listSentCampaigns,
+ getLastCampaignReport,
+ listCampaignRecipients,
+ deleteCampaign,
+ listMailingLists,
+ getListSubscribers,
+ getMailingLists,
+ getMailingListDetails,
+ listContactFields,
+ updateMailingList,
+ deleteMailingList,
+ countContacts,
+ addContactToDoNotMail,
+ createMailingList,
+ createCustomField,
+ listTopics,
+ getTopics,
+ createTopic,
+ listTags,
+ getAllTags,
+ ensureTag,
+ deleteTag,
+};
+
+const BASE_PARAMS = { resfmt: 'JSON' };
+
+const FORM_HEADERS = { 'Content-Type': 'application/x-www-form-urlencoded' };
+
+type CreateCampaignParams = {
+ campaignname: string;
+ from_email: string;
+ subject: string;
+ from_name?: string;
+ content_url?: string;
+ list_details?: string[];
+ segments?: string[];
+ topicId?: string;
+};
+
+type ScheduleCampaignParams = {
+ campaignkey: string;
+ scheduleDate: string;
+ scheduleHour: string;
+ scheduleMinute: string;
+ amPm: 'AM' | 'PM';
+ isTimeWarp?: boolean;
+ sendingTZ?: string;
+};
+
+type ListCampaignRecipientsParams = {
+ campaignkey: string;
+ action: ZohoCampaignsRecipientAction;
+ fromindex?: number;
+ range?: number;
+};
+
+type CloneCampaignParams = {
+ campaignkey: string;
+ campaignname?: string;
+ subject?: string;
+ from_name?: string;
+ from_add?: string;
+ reply_to?: string;
+ encode_type?: string;
+};
+
+type AddUpdateContactParams = {
+ listkey: string;
+ contactinfo: Record<string, unknown>;
+ source?: string;
+ topic_id?: string;
+};
+
+type TagContactParams = {
+ tagName: string;
+ lead_email: string;
+};
+
+type UnsubscribeContactParams = {
+ listkey: string;
+ contactinfo: Record<string, unknown>;
+ topic_id?: string;
+};
+
+type ListContactsParams = {
+ listkey: string;
+ sort?: ZohoCampaignsSort;
+ status?: ZohoCampaignsContactStatus;
+ fromindex?: number;
+ range?: number;
+};
+
+type ListCampaignsParams = {
+ sort?: ZohoCampaignsSort;
+ status?: ZohoCampaignsCampaignStatus;
+ fromindex?: number;
+ range?: number;
+};
+
+type TopicPagingParams = {
+ fromIndex?: number;
+ range?: number;
+};
+
+type ListMailingListsParams = {
+ sort?: ZohoCampaignsSort;
+ fromindex?: number;
+ range?: number;
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/client.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/client.ts
new file mode 100644
index 00000000000..c21777ab6c9
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/common/client.ts
@@ -0,0 +1,42 @@
+import { httpClient, HttpMethod, QueryParams } from '@activepieces/pieces-common';
+
+import type { ZohoCampaignsAuthValue } from './types';
+
+function baseUrl({ auth }: { auth: ZohoCampaignsAuthValue }): string {
+ const location = auth.props?.location || DEFAULT_LOCATION;
+ return `https://campaigns.${location}/api/v1.1`;
+}
+
+async function request<T>({
+ auth,
+ method,
+ path,
+ query,
+ body,
+ headers,
+}: RequestParams & { auth: ZohoCampaignsAuthValue }): Promise<T> {
+ const response = await httpClient.sendRequest<T>({
+ method,
+ url: `${baseUrl({ auth })}${path}`,
+ headers: {
+ Authorization: `Zoho-oauthtoken ${auth.access_token}`,
+ 'Content-Type': 'application/json',
+ ...headers,
+ },
+ queryParams: query,
+ body,
+ });
+ return response.body;
+}
+
+export const zohoCampaignsClient = { baseUrl, request };
+
+const DEFAULT_LOCATION = 'zoho.com';
+
+type RequestParams = {
+ method: HttpMethod;
+ path: string;
+ query?: QueryParams;
+ body?: unknown;
+ headers?: Record<string, string>;
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/index.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/index.ts
deleted file mode 100644
index 2ba95dbdbd5..00000000000
--- a/packages/pieces/community/zoho-campaigns/src/lib/common/index.ts
+++ /dev/null
@@ -1,393 +0,0 @@
-import { httpClient, HttpMethod } from '@activepieces/pieces-common';
-import { PieceAuth, Property } from '@activepieces/pieces-framework';
-import { OAuth2GrantType } from '@activepieces/pieces-framework';
-import * as properties from './properties';
-import * as schemas from './schemas';
-import {
- AddContactToMailingListParams,
- AddTagToContactParams,
- AddUpdateContactParams,
- AuthorizationParams,
- CloneCampaignParams,
- CreateCampaignParams,
- CreateCampaignResponse,
- CreateTagParams,
- ListCampaignParams,
- ListCampaignResponse,
- ListContactsParams,
- ListContactsResponse,
- ListMailingListsParams,
- ListMailingListsResponse,
- ListTagsResponse,
- ListTopicsResponse,
- RemoveTagParams,
- SendCampaignParams,
- UnsubscribeContactParams,
-} from './types';
-
-export const zohoCampaignsAuth = PieceAuth.OAuth2({
- props: {
- location: Property.StaticDropdown({
- displayName: 'Data Center',
- description: 'The data center location of your Zoho Campaigns account',
- required: true,
- options: {
- options: [
- {
- label: 'zoho.com (United States)',
- value: 'zoho.com',
- },
- {
- label: 'zoho.eu (Europe)',
- value: 'zoho.eu',
- },
- {
- label: 'zoho.in (India)',
- value: 'zoho.in',
- },
- {
- label: 'zoho.com.au (Australia)',
- value: 'zoho.com.au',
- },
- {
- label: 'zoho.jp (Japan)',
- value: 'zoho.jp',
- },
- {
- label: 'zoho.com.cn (China)',
- value: 'zoho.com.cn',
- },
- ],
- },
- }),
- },
- description: 'Connect your Zoho Campaigns account using OAuth2',
- grantType: OAuth2GrantType.AUTHORIZATION_CODE,
- required: true,
- authUrl: 'https://accounts.{location}/oauth/v2/auth',
- tokenUrl: 'https://accounts.{location}/oauth/v2/token',
- scope: ['ZohoCampaigns.campaign.ALL', 'ZohoCampaigns.contact.ALL'],
-});
-
-export const zohoCampaignsCommon = {
- baseUrl: (location = 'zoho.com') => {
- return `https://campaigns.${location}/api/v1.1`;
- },
- endpoints: {
- createCampaign: '/createCampaign',
- createTag: '/tag/add',
- cloneCampaign: '/json/clonecampaign',
- sendCampaign: '/sendcampaign',
- addUpdateContact: '/json/listsubscribe',
- addTagToContact: '/tag/associate',
- removeTag: '/tag/deassociate',
- unsubscribeContact: '/json/listunsubscribe',
- addContactToMailingList: '/addlistsubscribersinbulk',
- listContacts: '/getlistsubscribers',
- listCampaigns: '/recentcampaigns',
- listMailingLists: '/getmailinglists',
- listTopics: '/topics',
- listTags: '/tag/getalltags',
- },
- baseHeaders: (accessToken: string) => {
- return {
- Authorization: `Zoho-oauthtoken ${accessToken}`,
- 'Content-Type': 'application/json',
- };
- },
- baseParams: {
- resfmt: 'JSON',
- },
-
- // Properties
- createCampaignProperties: properties.createCampaign,
- cloneCampaignProperties: properties.cloneCampaign,
- sendCampaignProperties: properties.sendCampaign,
- addUpdateContactProperties: properties.addUpdateContact,
- addTagToContactProperties: properties.addTagToContact,
- removeTagProperties: properties.removeTag,
- unsubscribeContactProperties: properties.unsubscribeContact,
- addContactToMailingListProperties: properties.addContactToMailingList,
- findContactProperties: properties.findContact,
- findCampaignProperties: properties.findCampaign,
- newContactProperties: properties.newContact,
- unsubscribeProperties: properties.unsubscribe,
-
- // Schemas
- createCampaignSchema: schemas.createCampaign,
- cloneCampaignSchema: schemas.cloneCampaign,
- sendCampaignSchema: schemas.sendCampaign,
- addUpdateContactSchema: schemas.addUpdateContact,
- addTagToContactSchema: schemas.addTagToContact,
- removeTagSchema: schemas.removeTag,
- unsubscribeContactSchema: schemas.unsubscribeContact,
- addContactToMailingListSchema: schemas.addContactToMailingList,
- findContactSchema: schemas.findContact,
- findCampaignSchema: schemas.findCampaign,
-
- // Methods
- createCampaign: async ({
- accessToken,
- location = 'zoho.com',
- ...campaignParams
- }: CreateCampaignParams & { location?: string }) => {
- const {
- list_details: listDetails,
- topicId,
- ...restParams
- } = campaignParams;
-
- const list_details = JSON.stringify(listDetails);
- const body = new URLSearchParams({
- resfmt: 'json',
- list_details,
- ...restParams,
- ...(topicId && { topicId }),
- }).toString();
- const response = await httpClient.sendRequest<CreateCampaignResponse>({
- method: HttpMethod.POST,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.createCampaign}`,
- headers: {
- ...zohoCampaignsCommon.baseHeaders(accessToken),
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body,
- });
- return response.body;
- },
- createTag: async ({ accessToken, location = 'zoho.com', tagName }: CreateTagParams & { location?: string }) => {
- const response = await httpClient.sendRequest({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.createTag}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- tagName,
- },
- });
- return response.body;
- },
- cloneCampaign: async ({ accessToken, location = 'zoho.com', campaigninfo }: CloneCampaignParams & { location?: string }) => {
- const strCampaignInfo = JSON.stringify(campaigninfo);
- const response = await httpClient.sendRequest({
- method: HttpMethod.POST,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.cloneCampaign}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- campaigninfo: strCampaignInfo,
- },
- });
- return response.body;
- },
- sendCampaign: async ({ accessToken, location = 'zoho.com', campaignkey }: SendCampaignParams & { location?: string }) => {
- const response = await httpClient.sendRequest({
- method: HttpMethod.POST,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.sendCampaign}`,
- headers: {
- ...zohoCampaignsCommon.baseHeaders(accessToken),
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- campaignkey,
- },
- });
- return response.body;
- },
- addUpdateContact: async ({
- accessToken,
- location = 'zoho.com',
- ...contactParams
- }: AddUpdateContactParams & { location?: string }) => {
- const {
- listkey,
- contactinfo: contactInfoObj,
- source,
- topic_id,
- } = contactParams;
- const body = new URLSearchParams({
- ...zohoCampaignsCommon.baseParams,
- listkey,
- ...(source && { source }),
- ...(topic_id && { topic_id }),
- contactinfo: JSON.stringify(contactInfoObj),
- }).toString();
- const response = await httpClient.sendRequest({
- method: HttpMethod.POST,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.addUpdateContact}`,
- headers: {
- ...zohoCampaignsCommon.baseHeaders(accessToken),
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body,
- });
-
- return response.body;
- },
- addTagToContact: async ({
- accessToken,
- location = 'zoho.com',
- ...tagParams
- }: AddTagToContactParams & { location?: string }) => {
- const response = await httpClient.sendRequest({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.addTagToContact}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- ...tagParams,
- },
- });
- return response.body;
- },
- removeTag: async ({ accessToken, location = 'zoho.com', ...tagParams }: RemoveTagParams & { location?: string }) => {
- const response = await httpClient.sendRequest({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.removeTag}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- ...tagParams,
- },
- });
- return response.body;
- },
- unsubscribeContact: async ({
- accessToken,
- location = 'zoho.com',
- ...unsubscribeParams
- }: UnsubscribeContactParams & { location?: string }) => {
- const {
- contactinfo: contactInfoObj,
- listkey,
- topic_id,
- } = unsubscribeParams;
- const body = new URLSearchParams({
- ...zohoCampaignsCommon.baseParams,
- listkey,
- ...(topic_id && { topic_id }),
- contactinfo: JSON.stringify(contactInfoObj),
- }).toString();
- const response = await httpClient.sendRequest({
- method: HttpMethod.POST,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.unsubscribeContact}`,
- headers: {
- ...zohoCampaignsCommon.baseHeaders(accessToken),
- 'Content-Type': 'application/x-www-form-urlencoded',
- },
- body,
- });
- return response.body;
- },
- addContactToMailingList: async ({
- accessToken,
- location = 'zoho.com',
- ...mailingListParams
- }: AddContactToMailingListParams & { location?: string }) => {
- const response = await httpClient.sendRequest({
- method: HttpMethod.POST,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.addContactToMailingList}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- ...mailingListParams,
- },
- });
- return response.body;
- },
- listContacts: async ({
- accessToken,
- location = 'zoho.com',
- listkey,
- ...rest
- }: ListContactsParams & { location?: string }) => {
- const { fromindex, range, ...otherParams } = rest;
- const strFromIndex =
- typeof fromindex === 'number' ? String(fromindex) : undefined;
- const strRange = typeof range === 'number' ? String(range) : undefined;
- const queryParams = {
- ...zohoCampaignsCommon.baseParams,
- listkey,
- ...(fromindex && { fromindex: strFromIndex }),
- ...(range && { range: strRange }),
- ...otherParams,
- };
- const response = await httpClient.sendRequest<ListContactsResponse>({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.listContacts}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams,
- });
- return response.body.list_of_details || [];
- },
- listCampaigns: async ({
- accessToken,
- location = 'zoho.com',
- ...filterParams
- }: ListCampaignParams & { location?: string }) => {
- const { fromindex, range, ...otherParams } = filterParams;
- const strFromIndex =
- typeof fromindex === 'number' ? String(fromindex) : undefined;
- const strRange = typeof range === 'number' ? String(range) : undefined;
- const queryParams = {
- ...zohoCampaignsCommon.baseParams,
- ...(fromindex && { fromindex: strFromIndex }),
- ...(range && { range: strRange }),
- ...otherParams,
- };
- const response = await httpClient.sendRequest<ListCampaignResponse>({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.listCampaigns}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams,
- });
- return response.body.recent_campaigns || [];
- },
- listMailingLists: async ({
- accessToken,
- location = 'zoho.com',
- ...filterParams
- }: ListMailingListsParams & { location?: string }) => {
- const { fromindex, range, ...otherParams } = filterParams;
- const strFromIndex =
- typeof fromindex === 'number' ? String(fromindex) : undefined;
- const strRange = typeof range === 'number' ? String(range) : undefined;
- const queryParams = {
- ...zohoCampaignsCommon.baseParams,
- ...(fromindex && { fromindex: strFromIndex }),
- ...(range && { range: strRange }),
- ...otherParams,
- };
-
- const response = await httpClient.sendRequest<ListMailingListsResponse>({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.listMailingLists}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams,
- });
- return response.body.list_of_details || [];
- },
- listTopics: async ({ accessToken, location = 'zoho.com' }: AuthorizationParams & { location?: string }) => {
- const response = await httpClient.sendRequest<ListTopicsResponse>({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.listTopics}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- },
- });
- return response.body.topicDetails;
- },
- listTags: async ({ accessToken, location = 'zoho.com' }: AuthorizationParams & { location?: string }) => {
- const response = await httpClient.sendRequest<ListTagsResponse>({
- method: HttpMethod.GET,
- url: `${zohoCampaignsCommon.baseUrl(location)}${zohoCampaignsCommon.endpoints.listTags}`,
- headers: zohoCampaignsCommon.baseHeaders(accessToken),
- queryParams: {
- ...zohoCampaignsCommon.baseParams,
- },
- });
- return response.body.tags;
- },
-};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/properties.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/properties.ts
deleted file mode 100644
index d4fccf59691..00000000000
--- a/packages/pieces/community/zoho-campaigns/src/lib/common/properties.ts
+++ /dev/null
@@ -1,471 +0,0 @@
-import { PiecePropValueSchema, Property } from '@activepieces/pieces-framework';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '.';
-import { Tag } from './types';
-
-// Custom Properties
-const campaignDropdown = () =>
- Property.Dropdown({
- auth: zohoCampaignsAuth,
- displayName: 'Campaign',
- description: 'Select the campaign',
- required: true,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- const authValue = auth as PiecePropValueSchema<typeof zohoCampaignsAuth>;
- const location = authValue.props?.['location'] || 'zoho.com';
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Connect your Zoho Campaigns account first',
- options: [],
- };
- }
- const campaigns = await zohoCampaignsCommon.listCampaigns({
- accessToken: authValue.access_token,
- location,
- });
- if (campaigns.length === 0) {
- return {
- disabled: true,
- placeholder: 'No campaigns found',
- options: [],
- };
- }
-
- return {
- options: campaigns.map((campaign) => ({
- label: campaign.campaign_name,
- value: campaign.campaign_key,
- })),
- };
- },
- });
-
-const tagDropdown = ({ required = true }: { required?: boolean }) =>
- Property.Dropdown({
- auth: zohoCampaignsAuth,
- displayName: 'Tag',
- description: 'Select the tag to associate with the contact',
- required: required,
- refreshers: ['auth'],
- options: async ({
- auth,
- }): Promise<{
- disabled?: boolean;
- placeholder?: string;
- options: Array<{ label: string; value: string }>;
- }> => {
- const authValue = auth as PiecePropValueSchema<typeof zohoCampaignsAuth>;
- const location = authValue.props?.['location'] || 'zoho.com';
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Connect your Zoho Campaigns account first',
- options: [],
- };
- }
- const tags = await zohoCampaignsCommon.listTags({
- accessToken: authValue.access_token,
- location,
- });
- if (!tags || tags.length === 0) {
- return {
- disabled: true,
- placeholder: 'No tags found',
- options: [],
- };
- }
-
- const tagOptions = tags.flatMap((tagMap: Tag) =>
- Object.values(tagMap).map((tag: any) => ({
- label: tag.tag_name,
- value: tag.tag_name,
- }))
- );
-
- return {
- options: tagOptions,
- };
- },
- });
-
-const mailingListDropdown = ({ required = true }) =>
- Property.Dropdown({
- auth: zohoCampaignsAuth,
- displayName: 'Mailing List',
- description: 'Select the mailing list',
- required: required,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- const authValue = auth as PiecePropValueSchema<typeof zohoCampaignsAuth>;
- const location = authValue.props?.['location'] || 'zoho.com';
-
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Connect your Zoho Campaigns account first',
- options: [],
- };
- }
- const mailingLists = await zohoCampaignsCommon.listMailingLists({
- accessToken: authValue.access_token,
- location,
- });
- if (mailingLists.length === 0) {
- return {
- disabled: true,
- placeholder: 'No mailing lists found',
- options: [],
- };
- }
- return {
- options: mailingLists.map((list) => ({
- label: list.listname,
- value: list.listkey,
- })),
- };
- },
- });
-
-const mailingListMultiSelectDropdown = ({ required = true }) =>
- Property.MultiSelectDropdown({
- auth: zohoCampaignsAuth,
- displayName: 'Mailing Lists',
- description: 'Select the mailing lists',
- required: required,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- const authValue = auth as PiecePropValueSchema<typeof zohoCampaignsAuth>;
- const location = authValue.props?.['location'] || 'zoho.com';
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Connect your Zoho Campaigns account first',
- options: [],
- };
- }
- const mailingLists = await zohoCampaignsCommon.listMailingLists({
- accessToken: authValue.access_token,
- location,
- });
- if (mailingLists.length === 0) {
- return {
- disabled: true,
- placeholder: 'No mailing lists found',
- options: [],
- };
- }
- return {
- options: mailingLists.map((list) => ({
- label: list.listname,
- value: list.listkey,
- })),
- };
- },
- });
-
-const topicDropdown = ({ required = true }) =>
- Property.Dropdown({
- auth: zohoCampaignsAuth,
- displayName: 'Topic',
- description: 'Select the topic',
- required: required,
- refreshers: ['auth'],
- options: async ({ auth }) => {
- const authValue = auth as PiecePropValueSchema<typeof zohoCampaignsAuth>;
- const location = authValue.props?.['location'] || 'zoho.com';
- if (!auth) {
- return {
- disabled: true,
- placeholder: 'Connect your Zoho Campaigns account first',
- options: [],
- };
- }
- const topics = await zohoCampaignsCommon.listTopics({
- accessToken: authValue.access_token,
- location,
- });
- if (topics.length === 0) {
- return {
- disabled: true,
- placeholder: 'No topics found',
- options: [],
- };
- }
- return {
- options: topics.map((topic) => ({
- label: topic.topicName,
- value: topic.topicId,
- })),
- };
- },
- });
-
-const contactInformation = Property.DynamicProperties({
- displayName: 'Contact Information',
- description: 'Information about the contact',
- required: true,
- auth: zohoCampaignsAuth,
- refreshers: ['auth'],
- props: async () => ({
- 'Contact Email': Property.ShortText({
- displayName: 'Contact Email',
- description: 'Email address of the contact',
- required: true,
- }),
- 'First Name': Property.ShortText({
- displayName: 'First Name',
- description: 'First name of the contact',
- required: false,
- }),
- 'Last Name': Property.ShortText({
- displayName: 'Last Name',
- description: 'Last name of the contact',
- required: false,
- }),
- Phone: Property.ShortText({
- displayName: 'Phone',
- description: 'Phone number of the contact',
- required: false,
- }),
- 'Company Name': Property.ShortText({
- displayName: 'Company Name',
- description: 'Company name of the contact',
- required: false,
- }),
- additionalFields: Property.Object({
- displayName: 'Additional Fields',
- description:
- 'Additional fields for the contact in key-value pairs. For example, {"City": "New York", "State": "NY"}',
- required: false,
- }),
- }),
-});
-
-// Action Properties
-export const createCampaign = () => ({
- campaignname: Property.ShortText({
- displayName: 'Campaign Name',
- description: 'A name to your campaign',
- required: true,
- }),
- from_email: Property.ShortText({
- displayName: 'From Email',
- description: 'Sender email address for the campaign',
- required: true,
- }),
- subject: Property.ShortText({
- displayName: 'Subject',
- description: 'The subject line of the campaign',
- required: true,
- }),
- list_details: mailingListMultiSelectDropdown({ required: true }),
- content_url: Property.ShortText({
- displayName: 'Content URL',
- description: 'Public URL containing the HTML content for your campaign',
- required: false,
- }),
- topicId: topicDropdown({ required: false }),
-});
-
-export const cloneCampaign = () => ({
- campaignkey: campaignDropdown(),
- campaignname: Property.ShortText({
- displayName: 'Campaign Name',
- description: 'New name for the cloned campaign',
- required: false,
- }),
- subject: Property.ShortText({
- displayName: 'Subject',
- description: 'New subject line for the cloned campaign',
- required: false,
- }),
- from_name: Property.ShortText({
- displayName: 'From Name',
- description: 'Sender name for the cloned campaign',
- required: false,
- }),
- from_add: Property.ShortText({
- displayName: 'From Email',
- description: 'Sender email address for the cloned campaign',
- required: false,
- }),
- reply_to: Property.ShortText({
- displayName: 'Reply-To Email',
- description: 'Reply-to email address for the cloned campaign',
- required: false,
- }),
- encode_type: Property.ShortText({
- displayName: 'Encoding Type',
- description: 'Email encoding type (e.g., UTF-8)',
- required: false,
- }),
-});
-
-export const sendCampaign = () => ({
- campaignkey: campaignDropdown(),
-});
-
-export const addUpdateContact = () => ({
- listkey: mailingListDropdown({ required: true }),
- contactinfo: contactInformation,
- source: Property.ShortText({
- displayName: 'Source',
- description: 'Contact source can be added.',
- required: false,
- }),
- topic_id: topicDropdown({ required: false }),
-});
-
-export const addTagToContact: {
- tagName: any;
- lead_email: any;
-} = {
- tagName: tagDropdown({ required: true }),
- lead_email: Property.ShortText({
- displayName: 'Contact Email',
- description: 'Email address of the contact to tag',
- required: true,
- }),
-};
-
-export const removeTag: {
- tagName: any;
- lead_email: any;
-} = {
- tagName: tagDropdown({ required: true }),
- lead_email: Property.ShortText({
- displayName: 'Contact Email',
- description: 'Email address of the contact to remove the tag from',
- required: true,
- }),
-};
-
-export const unsubscribeContact = () => ({
- listkey: mailingListDropdown({ required: true }),
- contactinfo: contactInformation,
- topic_id: topicDropdown({ required: false }),
-});
-
-export const addContactToMailingList = () => ({
- listkey: mailingListDropdown({ required: true }),
- emails: Property.Array({
- displayName: 'Emails',
- description:
- 'Contacts email addresses to be added to the mailing list (maximum 10 emails)',
- required: true,
- }),
-});
-
-export const findContact = () => ({
- listkey: mailingListDropdown({ required: true }),
- contactEmail: Property.ShortText({
- displayName: 'Contact Email',
- description: 'Email of the contact to be found (partial matches supported)',
- required: true,
- }),
- status: Property.StaticDropdown({
- displayName: 'Contact Status',
- description: 'Filter contacts by status',
- required: true,
- options: {
- options: [
- { label: 'Active', value: 'active' },
- { label: 'Recent', value: 'recent' },
- { label: 'Most Recent', value: 'most recent' },
- { label: 'Unsubscribed', value: 'unsub' },
- { label: 'Bounced', value: 'bounce' },
- ],
- },
- }),
- sort: Property.StaticDropdown({
- displayName: 'Sort Order',
- description: 'Sort order for results',
- required: true,
- options: {
- options: [
- { label: 'Ascending', value: 'asc' },
- { label: 'Descending', value: 'desc' },
- ],
- },
- }),
- fromindex: Property.Number({
- displayName: 'From Index',
- description: 'Starting index for pagination (optional, default: 1)',
- required: false,
- }),
- range: Property.Number({
- displayName: 'Range',
- description: 'Number of contacts to retrieve (optional, default: all)',
- required: false,
- }),
-});
-
-export const findCampaign = () => ({
- campaignName: Property.ShortText({
- displayName: 'Campaign Name',
- description: 'Name of the campaign to be found (partial matches supported)',
- required: true,
- }),
- status: Property.StaticDropdown({
- displayName: 'Campaign Status',
- description: 'Filter campaigns by status (optional)',
- required: false,
- options: {
- options: [
- { label: 'All', value: 'all' },
- { label: 'All Campaigns', value: 'all campaigns' },
- { label: 'Drafts', value: 'drafts' },
- { label: 'Scheduled', value: 'scheduled' },
- { label: 'In Progress', value: 'inprogress' },
- { label: 'Sent', value: 'sent' },
- { label: 'Stopped', value: 'stopped' },
- { label: 'Canceled', value: 'canceled' },
- { label: 'To Be Reviewed', value: 'tobereviewed' },
- { label: 'Reviewed', value: 'reviewed' },
- { label: 'Paused', value: 'paused' },
- { label: 'In Testing', value: 'intesting' },
- ],
- },
- }),
- sort: Property.StaticDropdown({
- displayName: 'Sort Order',
- description: 'Sort order for results (optional)',
- required: false,
- options: {
- options: [
- { label: 'Ascending', value: 'asc' },
- { label: 'Descending', value: 'desc' },
- ],
- },
- }),
- fromindex: Property.Number({
- displayName: 'From Index',
- description: 'Starting index for pagination (optional, default: 1)',
- required: false,
- }),
- range: Property.Number({
- displayName: 'Range',
- description: 'Number of campaigns to retrieve (optional, default: 5)',
- required: false,
- }),
-});
-
-export const newContact = () => ({
- listkey: mailingListDropdown({ required: true }),
-});
-
-export const unsubscribe = () => ({
- listkey: mailingListDropdown({ required: true }),
- status: Property.StaticDropdown({
- displayName: 'Unsubscribe Type',
- description: 'Type of contact removal to monitor (default: unsubscribed)',
- required: false,
- options: {
- options: [
- { label: 'Unsubscribed', value: 'unsub' },
- { label: 'Bounced', value: 'bounce' },
- ],
- },
- }),
-});
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/props.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/props.ts
new file mode 100644
index 00000000000..12285b3dba2
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/common/props.ts
@@ -0,0 +1,219 @@
+import { DropdownState, Property } from '@activepieces/pieces-framework';
+
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from './api';
+
+function campaignKey<R extends boolean>({
+ required,
+ displayName = 'Campaign',
+ description = 'Select the campaign',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: zohoCampaignsAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ const campaigns = await zohoCampaignsApi.listCampaigns({ auth });
+ if (campaigns.length === 0) {
+ return disabledOptions({ placeholder: 'No campaigns found' });
+ }
+ return {
+ options: campaigns.map((campaign) => ({
+ label: campaign.campaign_name,
+ value: campaign.campaign_key,
+ })),
+ };
+ },
+ });
+}
+
+function tagName<R extends boolean>({
+ required,
+ displayName = 'Tag',
+ description = 'Select the tag to associate with the contact',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: zohoCampaignsAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ const tags = await zohoCampaignsApi.listTags({ auth });
+ if (!tags || tags.length === 0) {
+ return disabledOptions({ placeholder: 'No tags found' });
+ }
+ return {
+ options: tags.flatMap((tagMap) =>
+ Object.values(tagMap).map((tag) => ({
+ label: tag.tag_name,
+ value: tag.tag_name,
+ })),
+ ),
+ };
+ },
+ });
+}
+
+function listKey<R extends boolean>({
+ required,
+ displayName = 'Mailing List',
+ description = 'Select the mailing list',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: zohoCampaignsAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ const mailingLists = await zohoCampaignsApi.listMailingLists({ auth });
+ if (mailingLists.length === 0) {
+ return disabledOptions({ placeholder: 'No mailing lists found' });
+ }
+ return {
+ options: mailingLists.map((list) => ({
+ label: list.listname,
+ value: list.listkey,
+ })),
+ };
+ },
+ });
+}
+
+function listKeys<R extends boolean>({
+ required,
+ displayName = 'Mailing Lists',
+ description = 'Select the mailing lists',
+}: PropParams<R>) {
+ return Property.MultiSelectDropdown({
+ auth: zohoCampaignsAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ const mailingLists = await zohoCampaignsApi.listMailingLists({ auth });
+ if (mailingLists.length === 0) {
+ return disabledOptions({ placeholder: 'No mailing lists found' });
+ }
+ return {
+ options: mailingLists.map((list) => ({
+ label: list.listname,
+ value: list.listkey,
+ })),
+ };
+ },
+ });
+}
+
+function topicId<R extends boolean>({
+ required,
+ displayName = 'Topic',
+ description = 'Select the topic',
+}: PropParams<R>) {
+ return Property.Dropdown({
+ auth: zohoCampaignsAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ options: async ({ auth }) => {
+ if (!auth) {
+ return disabledOptions({ placeholder: NOT_CONNECTED });
+ }
+ const topics = await zohoCampaignsApi.listTopics({ auth });
+ if (topics.length === 0) {
+ return disabledOptions({ placeholder: 'No topics found' });
+ }
+ return {
+ options: topics.map((topic) => ({
+ label: topic.topicName,
+ value: topic.topicId,
+ })),
+ };
+ },
+ });
+}
+
+function contactInfo<R extends boolean>({
+ required,
+ displayName = 'Contact Information',
+ description = 'Information about the contact',
+}: PropParams<R>) {
+ return Property.DynamicProperties({
+ auth: zohoCampaignsAuth,
+ displayName,
+ description,
+ required,
+ refreshers: ['auth'],
+ props: async () => ({
+ 'Contact Email': Property.ShortText({
+ displayName: 'Contact Email',
+ description: 'Email address of the contact',
+ required: true,
+ }),
+ 'First Name': Property.ShortText({
+ displayName: 'First Name',
+ description: 'First name of the contact',
+ required: false,
+ }),
+ 'Last Name': Property.ShortText({
+ displayName: 'Last Name',
+ description: 'Last name of the contact',
+ required: false,
+ }),
+ Phone: Property.ShortText({
+ displayName: 'Phone',
+ description: 'Phone number of the contact',
+ required: false,
+ }),
+ 'Company Name': Property.ShortText({
+ displayName: 'Company Name',
+ description: 'Company name of the contact',
+ required: false,
+ }),
+ additionalFields: Property.Object({
+ displayName: 'Additional Fields',
+ description:
+ 'Additional fields for the contact in key-value pairs. For example, {"City": "New York", "State": "NY"}',
+ required: false,
+ }),
+ }),
+ });
+}
+
+function disabledOptions({ placeholder }: { placeholder: string }): DropdownState<never> {
+ return { disabled: true, options: [], placeholder };
+}
+
+export const zohoCampaignsProps = {
+ campaignKey,
+ tagName,
+ listKey,
+ listKeys,
+ topicId,
+ contactInfo,
+};
+
+const NOT_CONNECTED = 'Connect your Zoho Campaigns account first';
+
+export type PropParams<R extends boolean> = {
+ required: R;
+ displayName?: string;
+ description?: string;
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/schemas.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/schemas.ts
deleted file mode 100644
index 1b38836818e..00000000000
--- a/packages/pieces/community/zoho-campaigns/src/lib/common/schemas.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import * as z from 'zod/mini'
-
-export const createCampaign = {
- campaignname: z.string(),
- from_email: z.string().check(z.email()),
- subject: z.string(),
- content_url: z.optional(z.string().check(z.url())),
- list_details: z.array(z.string()),
- topicId: z.optional(z.nullable(z.string())),
-}
-
-export const cloneCampaign = {
- campaignkey: z.string(),
- campaignname: z.optional(z.string()),
- subject: z.optional(z.string()),
- from_name: z.optional(z.string()),
- from_add: z.optional(z.string().check(z.email())),
- reply_to: z.optional(z.string().check(z.email())),
- encode_type: z.optional(z.string()),
-}
-
-export const sendCampaign = {
- campaignkey: z.string(),
-}
-
-export const addUpdateContact = {
- listkey: z.string(),
- contactinfo: z.object({
- 'Contact Email': z.string().check(z.email()),
- }),
- source: z.optional(z.string()),
- topic_id: z.optional(z.nullable(z.string())),
-}
-
-export const addTagToContact = {
- tagName: z.string(),
- lead_email: z.string().check(z.email()),
-}
-
-export const removeTag = {
- tagName: z.string(),
- lead_email: z.string().check(z.email()),
-}
-
-export const unsubscribeContact = {
- listkey: z.string(),
- contactinfo: z.object({
- 'Contact Email': z.string().check(z.email()),
- }),
- topic_id: z.optional(z.nullable(z.string())),
-}
-
-export const addContactToMailingList = {
- listkey: z.string(),
- emails: z.array(z.string().check(z.email())).check(z.minLength(1), z.maxLength(10)),
-}
-
-export const findContact = {
- listkey: z.string(),
- contactEmail: z.string().check(z.email()),
- status: z.optional(z.enum(['active', 'recent', 'most recent', 'unsub', 'bounce'])),
- sort: z.optional(z.enum(['asc', 'desc'])),
- fromindex: z.optional(z.number().check(z.minimum(1))),
- range: z.optional(z.number().check(z.minimum(1))),
-}
-
-export const findCampaign = {
- campaignName: z.string(),
- status: z.optional(z.enum(['all', 'all campaigns', 'drafts', 'scheduled', 'inprogress', 'sent', 'stopped', 'canceled', 'tobereviewed', 'reviewed', 'paused', 'intesting'])),
- sort: z.optional(z.enum(['asc', 'desc'])),
- fromindex: z.optional(z.number().check(z.minimum(1))),
- range: z.optional(z.number().check(z.minimum(1))),
-}
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/types.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/types.ts
index e28887f31ce..469a5f8dbd1 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/common/types.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/common/types.ts
@@ -1,96 +1,62 @@
-export interface AuthorizationParams {
- accessToken: string;
-}
-
-export interface BaseCampaignKeyParams {
- campaignkey: string;
-}
-
-export interface CreateCampaignParams extends AuthorizationParams {
- campaignname: string;
- from_email: string;
- subject: string;
- content_url?: string;
- list_details: object;
- topicId?: string;
-}
-
-export interface CreateTagParams extends AuthorizationParams {
- tagName: string;
-}
-
-export interface CloneCampaignParams extends AuthorizationParams {
- campaigninfo: object;
-}
-
-export interface SendCampaignParams
- extends AuthorizationParams,
- BaseCampaignKeyParams {}
-
-export interface AddUpdateContactParams extends AuthorizationParams {
- listkey: string;
- contactinfo: object;
- source?: string;
- topic_id?: string;
-}
-
-export interface AddTagToContactParams extends AuthorizationParams {
- tagName: string;
- lead_email: string;
-}
-
-export interface RemoveTagParams extends AuthorizationParams {
- tagName: string;
- lead_email: string;
-}
-
-export interface UnsubscribeContactParams extends AuthorizationParams {
- listkey: string;
- contactinfo: object;
- topic_id?: string;
-}
+import type { AppConnectionType } from '@activepieces/pieces-framework';
+
+export type ZohoCampaignsAuthValue = {
+ type:
+ | AppConnectionType.OAUTH2
+ | AppConnectionType.CLOUD_OAUTH2
+ | AppConnectionType.PLATFORM_OAUTH2;
+ access_token: string;
+ props?: { location?: string };
+};
-export interface AddContactToMailingListParams extends AuthorizationParams {
- listkey: string;
- emailids: string;
-}
+export type ZohoCampaignsSort = 'asc' | 'desc';
+
+export type ZohoCampaignsSignupForm = 'public' | 'private';
+
+export type ZohoCampaignsContactStatus =
+ | 'active'
+ | 'recent'
+ | 'most recent'
+ | 'unsub'
+ | 'bounce';
+
+export type ZohoCampaignsCampaignStatus =
+ | 'all'
+ | 'all campaigns'
+ | 'drafts'
+ | 'scheduled'
+ | 'inprogress'
+ | 'sent'
+ | 'stopped'
+ | 'canceled'
+ | 'tobereviewed'
+ | 'reviewed'
+ | 'paused'
+ | 'intesting';
+
+export type ZohoCampaignsRecipientAction =
+ | 'sentcontacts'
+ | 'openedcontacts'
+ | 'optoutcontacts'
+ | 'spamcontacts'
+ | 'unopenedcontacts'
+ | 'clickedcontacts'
+ | 'senthardbounce'
+ | 'sentsoftbounce'
+ | 'unsentcontacts';
+
+export type ZohoCampaignsResponse = {
+ status?: string;
+ code?: string | number;
+ message?: string;
+ response?: {
+ status?: string;
+ code?: string | number;
+ message?: string;
+ };
+};
-export interface ListContactsParams extends AuthorizationParams {
- listkey: string;
- sort?: 'asc' | 'desc';
- fromindex?: number;
- range?: number;
- status?: 'active' | 'recent' | 'most recent' | 'unsub' | 'bounce';
-}
-
-export interface ListCampaignParams extends AuthorizationParams {
- sort?: 'asc' | 'desc';
- fromindex?: number;
- range?: number;
- status?:
- | 'all'
- | 'all campaigns'
- | 'drafts'
- | 'scheduled'
- | 'inprogress'
- | 'sent'
- | 'stopped'
- | 'canceled'
- | 'tobereviewed'
- | 'reviewed'
- | 'paused'
- | 'intesting';
-}
-
-export interface ListMailingListsParams extends AuthorizationParams {
- sort?: 'asc' | 'desc';
- fromindex?: number;
- range?: number;
-}
-
-
-// API Response types
-export type Campaign = {
+export type ZohoCampaignsCampaign = {
campaign_key: string;
campaign_name: string;
created_date_string: string;
@@ -99,7 +65,7 @@ export type Campaign = {
campaign_preview: string;
};
-export type Contact = {
+export type ZohoCampaignsContact = {
firstname: string;
added_time: string;
phone: string;
@@ -109,7 +75,7 @@ export type Contact = {
zuid: string;
};
-export type MailingList = {
+export type ZohoCampaignsMailingList = {
date: string;
deletable: string;
segments: object;
@@ -142,13 +108,13 @@ export type MailingList = {
zx: string;
};
-export type Topic = {
+export type ZohoCampaignsTopic = {
topicId: string;
topicName: string;
primaryList: number;
};
-export type Tag = {
+export type ZohoCampaignsTag = {
[key: string]: {
tagowner: string;
tag_created_time: string;
@@ -161,24 +127,22 @@ export type Tag = {
};
};
-export interface ListCampaignResponse {
- fromindex: string;
- total_record_count: string;
- code: string;
- recent_campaigns: Campaign[];
- range: string;
- campaign_count: string;
- uri: string;
- version: string;
- requestdetails: string;
- status: string;
-}
+export type ZohoCampaignsListCampaignsResponse = ZohoCampaignsResponse & {
+ fromindex?: string;
+ total_record_count?: string;
+ recent_campaigns?: ZohoCampaignsCampaign[];
+ range?: string;
+ campaign_count?: string;
+ uri?: string;
+ version?: string;
+ requestdetails?: string;
+};
-export interface ListContactsResponse {
+export type ZohoCampaignsListContactsResponse = ZohoCampaignsResponse & {
code: string;
uri: string;
version: string;
- list_of_details: Contact[];
+ list_of_details?: ZohoCampaignsContact[];
requestdetails: {
fromindex: number;
range: number;
@@ -186,13 +150,13 @@ export interface ListContactsResponse {
status: string;
};
status: string;
-}
+};
-export interface ListMailingListsResponse {
+export type ZohoCampaignsListMailingListsResponse = ZohoCampaignsResponse & {
code: string;
uri: string;
version: string;
- list_of_details: MailingList[];
+ list_of_details?: ZohoCampaignsMailingList[];
requestdetails: {
fromindex: number;
range: number;
@@ -200,25 +164,27 @@ export interface ListMailingListsResponse {
sort: string;
};
status: string;
-}
+};
-export interface ListTopicsResponse {
- topicDetails: Topic[];
+export type ZohoCampaignsListTopicsResponse = ZohoCampaignsResponse & {
+ topicDetails: ZohoCampaignsTopic[];
message: string;
code: string;
uri: string;
-}
+};
-export interface CreateCampaignResponse {
- message: string;
- campaignKey: string;
- code: string;
- uri: string;
-}
+export type ZohoCampaignsCreateCampaignResponse = ZohoCampaignsResponse & {
+ campaignKey?: string;
+ uri?: string;
+};
-export interface ListTagsResponse {
+export type ZohoCampaignsListTagsResponse = ZohoCampaignsResponse & {
uri: string;
version: string;
requestdetails: string;
- tags?: Tag[];
-}
+ tags?: ZohoCampaignsTag[];
+};
+
+export type ZohoCampaignsListSentCampaignsResponse = ZohoCampaignsResponse & {
+ recent_sent_campaigns?: string;
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/common/utils.ts b/packages/pieces/community/zoho-campaigns/src/lib/common/utils.ts
new file mode 100644
index 00000000000..f8b8ff3a2ab
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/common/utils.ts
@@ -0,0 +1,69 @@
+import type { ZohoCampaignsResponse } from './types';
+
+function assertSuccess<T extends ZohoCampaignsResponse>({ body }: { body: T }): T {
+ const status = body.status ?? body.response?.status;
+ const code = body.code ?? body.response?.code;
+ const failed =
+ status === 'error' ||
+ status === 'failure' ||
+ (status === undefined && code !== undefined && !SUCCESS_CODES.includes(String(code)));
+ if (failed) {
+ const message = body.message ?? body.response?.message;
+ throw new Error(
+ message
+ ? `Zoho Campaigns returned an error (code ${code}): ${message}`
+ : `Zoho Campaigns returned an error: ${JSON.stringify(body)}`,
+ );
+ }
+ return body;
+}
+
+function joinEmails({
+ emails,
+ propName,
+}: {
+ emails: unknown[] | undefined;
+ propName: string;
+}): string {
+ const list = emails ?? [];
+ if (
+ list.length === 0 ||
+ list.length > MAX_EMAILS ||
+ !list.every((email): email is string => typeof email === 'string' && email !== '')
+ ) {
+ throw new Error(`${propName} must hold 1 to ${MAX_EMAILS} non-empty email addresses.`);
+ }
+ return list.join(',');
+}
+
+function contactInfo({
+ email,
+ firstName,
+ lastName,
+ phone,
+ companyName,
+ additionalFields,
+}: ContactInfoParams): Record<string, unknown> {
+ return {
+ ...additionalFields,
+ 'Contact Email': email,
+ ...(firstName && { 'First Name': firstName }),
+ ...(lastName && { 'Last Name': lastName }),
+ ...(phone && { Phone: phone }),
+ ...(companyName && { 'Company Name': companyName }),
+ };
+}
+
+export const zohoCampaignsUtils = { assertSuccess, joinEmails, contactInfo };
+
+const MAX_EMAILS = 10;
+const SUCCESS_CODES = ['0', '200'];
+
+type ContactInfoParams = {
+ email: string;
+ firstName?: string;
+ lastName?: string;
+ phone?: string;
+ companyName?: string;
+ additionalFields?: Record<string, unknown>;
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/output-schemas.ts b/packages/pieces/community/zoho-campaigns/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..db51eb8ff29
--- /dev/null
+++ b/packages/pieces/community/zoho-campaigns/src/lib/output-schemas.ts
@@ -0,0 +1,576 @@
+import { OutputSchema } from '@activepieces/pieces-framework';
+
+const responseFields: OutputSchema['fields'] = [
+ { key: 'status', label: 'Status' },
+ { key: 'code', label: 'Code' },
+ { key: 'uri', label: 'URI' },
+ { key: 'version', label: 'API Version' },
+];
+
+const statusFields: OutputSchema['fields'] = [
+ ...responseFields,
+ { key: 'message', label: 'Message' },
+];
+
+const campaignSummaryFields: OutputSchema['fields'] = [
+ { key: 'campaign_key', label: 'Campaign Key' },
+ { key: 'campaignId', label: 'Campaign ID' },
+ { key: 'campaign_name', label: 'Campaign Name' },
+ { key: 'subject', label: 'Subject' },
+ { key: 'campaign_status', label: 'Campaign Status' },
+ { key: 'campaigntype', label: 'Campaign Type' },
+ { key: 'from_email', label: 'From Email', format: 'email' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ { key: 'campaign_preview', label: 'Preview URL', format: 'url' },
+ { key: 'created_date_string', label: 'Created Date' },
+ { key: 'created_time', label: 'Created Time', format: 'datetime' },
+ { key: 'created_time_gmt', label: 'Created Time (GMT)', format: 'datetime' },
+ { key: 'folder_id', label: 'Folder ID' },
+ { key: 'is_hybrid', label: 'Is Hybrid' },
+ { key: 'zuid', label: 'Owner User ID' },
+];
+
+const contactFields: OutputSchema['fields'] = [
+ { key: 'contact_email', label: 'Email', format: 'email' },
+ { key: 'firstname', label: 'First Name' },
+ { key: 'lastname', label: 'Last Name' },
+ { key: 'phone', label: 'Phone' },
+ { key: 'companyname', label: 'Company Name' },
+ { key: 'added_time', label: 'Added Date' },
+ { key: 'zuid', label: 'User ID' },
+];
+
+const listContactsResultFields: OutputSchema['fields'] = [
+ { key: 'listkey', label: 'List Key' },
+ { key: 'listname', label: 'List Name' },
+ { key: 'ignored_contacts', label: 'Ignored Contacts' },
+ { key: 'existing_contacts', label: 'Existing Contacts' },
+ { key: 'readd_contacts', label: 'Re-added Contacts' },
+ { key: 'url', label: 'URI' },
+ { key: 'status', label: 'Status' },
+ { key: 'code', label: 'Code' },
+ { key: 'version', label: 'API Version' },
+];
+
+const campaignReportFields: OutputSchema['fields'] = [
+ {
+ key: 'campaign-reports',
+ label: 'Campaign Reports',
+ labelKey: 'campaign_name',
+ listItems: [
+ { key: 'campaign_name', label: 'Campaign Name' },
+ { key: 'emails_sent_count', label: 'Emails Sent', format: 'number' },
+ { key: 'delivered_count', label: 'Delivered', format: 'number' },
+ { key: 'delivered_percent', label: 'Delivered %', format: 'number' },
+ { key: 'opens_count', label: 'Opens', format: 'number' },
+ { key: 'open_percent', label: 'Open %', format: 'number' },
+ { key: 'unopened', label: 'Unopened', format: 'number' },
+ { key: 'unopened_percent', label: 'Unopened %', format: 'number' },
+ { key: 'unique_clicks_count', label: 'Unique Clicks', format: 'number' },
+ { key: 'unique_clicked_percent', label: 'Unique Click %', format: 'number' },
+ { key: 'clicksperopenrate', label: 'Clicks per Open %', format: 'number' },
+ { key: 'bounces_count', label: 'Bounces', format: 'number' },
+ { key: 'bounce_percent', label: 'Bounce %', format: 'number' },
+ { key: 'hardbounce_count', label: 'Hard Bounces', format: 'number' },
+ { key: 'softbounce_count', label: 'Soft Bounces', format: 'number' },
+ { key: 'unsub_count', label: 'Unsubscribes', format: 'number' },
+ { key: 'unsubscribe_percent', label: 'Unsubscribe %', format: 'number' },
+ { key: 'spams_count', label: 'Spam Reports', format: 'number' },
+ { key: 'spam_percent', label: 'Spam %', format: 'number' },
+ { key: 'complaints_count', label: 'Complaints', format: 'number' },
+ { key: 'complaints_percent', label: 'Complaint %', format: 'number' },
+ { key: 'forwards_count', label: 'Forwards', format: 'number' },
+ { key: 'forward_percent', label: 'Forward %', format: 'number' },
+ { key: 'autoreply_count', label: 'Auto Replies', format: 'number' },
+ { key: 'unsent_count', label: 'Unsent', format: 'number' },
+ { key: 'unsent_percent', label: 'Unsent %', format: 'number' },
+ ],
+ },
+ {
+ key: 'campaign-details',
+ label: 'Campaign Details',
+ labelKey: 'campaign_name',
+ listItems: [
+ { key: 'campaign_key', label: 'Campaign Key' },
+ { key: 'campaign_name', label: 'Campaign Name' },
+ { key: 'email_subject', label: 'Subject' },
+ { key: 'email_from', label: 'From Email', format: 'email' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ { key: 'email_type', label: 'Email Type' },
+ { key: 'email_options', label: 'Email Options' },
+ { key: 'created_time', label: 'Created Time' },
+ { key: 'sent_time', label: 'Sent Time' },
+ ],
+ },
+ {
+ key: 'campaign-reach',
+ label: 'Campaign Reach',
+ listItems: [
+ { key: 'total', label: 'Total', format: 'number' },
+ { key: 'emails', label: 'Emails', format: 'number' },
+ { key: 'facebook', label: 'Facebook', format: 'number' },
+ { key: 'twitter', label: 'Twitter', format: 'number' },
+ { key: 'linkedin', label: 'LinkedIn', format: 'number' },
+ { key: 'other', label: 'Other', format: 'number' },
+ ],
+ },
+ { key: 'campaign-by-loaction', label: 'Opens by Location' },
+ ...statusFields,
+];
+
+export const zohoCampaignsStatusOutputSchema: OutputSchema = {
+ fields: statusFields,
+};
+
+export const zohoCampaignsAddContactsToMailingListOutputSchema: OutputSchema = {
+ fields: listContactsResultFields,
+};
+
+export const zohoCampaignsCreateCustomFieldOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'response',
+ label: 'Response',
+ children: [
+ { key: 'fieldname', label: 'Field Name' },
+ { key: 'fieldtype', label: 'Field Type' },
+ { key: 'fieldlength', label: 'Field Length', format: 'number' },
+ { key: 'decimallength', label: 'Decimal Length', format: 'number' },
+ { key: 'mandatory_check', label: 'Mandatory' },
+ { key: 'type', label: 'Response Type' },
+ { key: 'code', label: 'Code', format: 'number' },
+ { key: 'message', label: 'Message' },
+ { key: 'uri', label: 'URI' },
+ ],
+ },
+ ],
+};
+
+export const zohoCampaignsListCampaignsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'recent_campaigns',
+ label: 'Campaigns',
+ labelKey: 'campaign_name',
+ listItems: campaignSummaryFields,
+ },
+ { key: 'count', label: 'Returned Count', format: 'number' },
+ { key: 'campaign_count', label: 'Campaign Count' },
+ { key: 'total_record_count', label: 'Total Record Count' },
+ { key: 'fromindex', label: 'From Index' },
+ { key: 'range', label: 'Range' },
+ { key: 'requestdetails', label: 'Request Details' },
+ ...responseFields,
+ ],
+};
+
+export const zohoCampaignsListSentCampaignsOutputSchema: OutputSchema = {
+ fields: [{ key: 'recent_sent_campaigns', label: 'Recently Sent Campaigns' }, ...statusFields],
+};
+
+export const zohoCampaignsCloneCampaignOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'campaignkey', label: 'New Campaign Key' },
+ { key: 'created_date_string', label: 'Created Date' },
+ {
+ key: 'campaign-details',
+ label: 'Campaign Details',
+ labelKey: 'campaign_name',
+ listItems: [
+ { key: 'campaign_name', label: 'Campaign Name' },
+ { key: 'email_subject', label: 'Subject' },
+ { key: 'email_from', label: 'From Email', format: 'email' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ ],
+ },
+ { key: 'url', label: 'URI' },
+ { key: 'status', label: 'Status' },
+ { key: 'code', label: 'Code' },
+ { key: 'version', label: 'API Version' },
+ ],
+};
+
+export const zohoCampaignsCreateCampaignOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'campaignKey', label: 'Campaign Key' },
+ { key: 'campaign_id', label: 'Campaign ID' },
+ { key: 'campaign_name', label: 'Campaign Name' },
+ { key: 'campaign_subject', label: 'Subject' },
+ { key: 'campaign_status', label: 'Campaign Status' },
+ { key: 'content_id', label: 'Content ID' },
+ { key: 'created_date', label: 'Created Date', format: 'datetime' },
+ { key: 'code', label: 'Code' },
+ { key: 'message', label: 'Message' },
+ { key: 'uri', label: 'URI' },
+ { key: 'version', label: 'API Version' },
+ ],
+};
+
+export const zohoCampaignsSendCampaignOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'campaign_status', label: 'Campaign Status' },
+ { key: 'code', label: 'Code' },
+ { key: 'message', label: 'Message' },
+ { key: 'uri', label: 'URI' },
+ { key: 'version', label: 'API Version' },
+ ],
+};
+
+export const zohoCampaignsCampaignReportOutputSchema: OutputSchema = {
+ fields: campaignReportFields,
+};
+
+export const zohoCampaignsListCampaignRecipientsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'list_of_details',
+ label: 'Recipients',
+ labelKey: 'contactemailaddress',
+ listItems: [
+ { key: 'contactemailaddress', label: 'Email', format: 'email' },
+ { key: 'contactid', label: 'Contact ID' },
+ { key: 'firstname', label: 'First Name' },
+ { key: 'lastname', label: 'Last Name' },
+ { key: 'companyname', label: 'Company Name' },
+ { key: 'phone', label: 'Phone' },
+ { key: 'contactstatus', label: 'Contact Status' },
+ { key: 'sentdate', label: 'Sent Date' },
+ { key: 'sent_time', label: 'Sent Time', format: 'datetime' },
+ { key: 'timezone', label: 'Time Zone' },
+ ],
+ },
+ {
+ key: 'requestdetails',
+ label: 'Request Details',
+ children: [
+ { key: 'action', label: 'Activity' },
+ { key: 'fromindex', label: 'From Index', format: 'number' },
+ { key: 'range', label: 'Range', format: 'number' },
+ ],
+ },
+ ...statusFields,
+ ],
+};
+
+export const zohoCampaignsGetCampaignOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'campaign_status', label: 'Campaign Status' },
+ { key: 'total_subscribers_count', label: 'Total Recipients', format: 'number' },
+ {
+ key: 'campaign-details',
+ label: 'Campaign Details',
+ labelKey: 'campaign_name',
+ listItems: [
+ { key: 'campaign_key', label: 'Campaign Key' },
+ { key: 'campaign_name', label: 'Campaign Name' },
+ { key: 'email_subject', label: 'Subject' },
+ { key: 'preheader', label: 'Preheader' },
+ { key: 'email_from', label: 'From Email', format: 'email' },
+ { key: 'sender_name', label: 'Sender Name' },
+ { key: 'reply_to', label: 'Reply To', format: 'email' },
+ { key: 'campaigntype', label: 'Campaign Type' },
+ { key: 'email_type', label: 'Email Type' },
+ { key: 'email_options', label: 'Email Options' },
+ { key: 'topic_id', label: 'Topic ID' },
+ { key: 'topic_name', label: 'Topic Name' },
+ { key: 'campaignaction', label: 'Next Action' },
+ { key: 'schedule_type', label: 'Schedule Type' },
+ { key: 'campaign_preview', label: 'Preview URL', format: 'url' },
+ { key: 'folder_id', label: 'Folder ID' },
+ { key: 'created_date_string', label: 'Created Date' },
+ { key: 'created_time', label: 'Created Time' },
+ { key: 'created_time_gmt', label: 'Created Time (GMT)', format: 'datetime' },
+ { key: 'updated_date_string', label: 'Updated Date' },
+ { key: 'updated_time', label: 'Updated Time' },
+ { key: 'updated_time_gmt', label: 'Updated Time (GMT)', format: 'datetime' },
+ { key: 'modifieddate', label: 'Modified Date' },
+ { key: 'modified_time', label: 'Modified Time' },
+ { key: 'modified_time_gmt', label: 'Modified Time (GMT)', format: 'datetime' },
+ { key: 'encodeName', label: 'Encoding' },
+ { key: 'is_advance', label: 'Is Advanced' },
+ { key: 'advanceTypeString', label: 'Advanced Type' },
+ { key: 'is_hybrid', label: 'Is Hybrid' },
+ { key: 'isGAConfig', label: 'Google Analytics Configured' },
+ { key: 'isReplyTrackingEnabled', label: 'Reply Tracking Enabled' },
+ { key: 'isToNameConfig', label: 'To Name Configured' },
+ { key: 'isWistia', label: 'Has Wistia Video' },
+ { key: 'webAutoStatus', label: 'Web Auto Status' },
+ { key: 'zuid', label: 'Owner User ID' },
+ ],
+ },
+ {
+ key: 'associated_mailing_lists',
+ label: 'Mailing Lists',
+ labelKey: 'listname',
+ listItems: [
+ { key: 'listkey', label: 'List Key' },
+ { key: 'listname', label: 'List Name' },
+ { key: 'liststatus', label: 'List Status' },
+ { key: 'contactscount', label: 'Contacts' },
+ { key: 'no_of_unsubcontacts', label: 'Unsubscribed Contacts' },
+ { key: 'no_of_bounce', label: 'Bounced Contacts' },
+ ],
+ },
+ { key: 'segments_info', label: 'Segments' },
+ { key: 'url', label: 'URI' },
+ { key: 'status', label: 'Status' },
+ { key: 'code', label: 'Code' },
+ { key: 'version', label: 'API Version' },
+ ],
+};
+
+export const zohoCampaignsListContactsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'list_of_details',
+ label: 'Contacts',
+ labelKey: 'contact_email',
+ listItems: contactFields,
+ },
+ { key: 'count', label: 'Returned Count', format: 'number' },
+ {
+ key: 'requestdetails',
+ label: 'Request Details',
+ children: [
+ { key: 'fromindex', label: 'From Index', format: 'number' },
+ { key: 'range', label: 'Range', format: 'number' },
+ { key: 'sort', label: 'Sort' },
+ { key: 'status', label: 'Contact Status' },
+ ],
+ },
+ ...responseFields,
+ ],
+};
+
+export const zohoCampaignsCountContactsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'no_of_contacts', label: 'Number of Contacts', format: 'number' },
+ ...responseFields,
+ ],
+};
+
+export const zohoCampaignsListContactFieldsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'response',
+ label: 'Response',
+ children: [
+ {
+ key: 'fieldnames',
+ label: 'Field Names',
+ children: [
+ {
+ key: 'fieldname',
+ label: 'Fields',
+ labelKey: 'DISPLAY_NAME',
+ listItems: [
+ { key: 'DISPLAY_NAME', label: 'Display Name' },
+ { key: 'FIELD_NAME', label: 'Field Name' },
+ { key: 'FIELD_DISPLAY_NAME', label: 'Field Constant' },
+ { key: 'FIELD_ID', label: 'Field ID', format: 'number' },
+ { key: 'UITYPE', label: 'UI Type' },
+ { key: 'TYPE', label: 'Type' },
+ { key: 'MAXLENGTH', label: 'Max Length', format: 'number' },
+ { key: 'IS_MANDATORY', label: 'Is Mandatory', format: 'boolean' },
+ { key: 'BLOCK_LABEL', label: 'Block' },
+ { key: 'SEQUENCE', label: 'Sequence', format: 'number' },
+ { key: 'block_sequence', label: 'Block Sequence', format: 'number' },
+ { key: 'is_otheruser_field', label: 'Is Other User Field', format: 'boolean' },
+ { key: 'no', label: 'Number', format: 'number' },
+ ],
+ },
+ ],
+ },
+ { key: 'code', label: 'Code', format: 'number' },
+ { key: 'message', label: 'Message' },
+ ],
+ },
+ ],
+};
+
+export const zohoCampaignsFindCampaignOutputSchema: OutputSchema = {
+ itemLabel: '{campaign_name}',
+ fields: [
+ {
+ key: 'campaigns',
+ label: 'Campaigns',
+ value: '',
+ listItems: campaignSummaryFields,
+ },
+ ],
+};
+
+export const zohoCampaignsFindContactOutputSchema: OutputSchema = {
+ itemLabel: '{contact_email}',
+ fields: [
+ {
+ key: 'contacts',
+ label: 'Contacts',
+ value: '',
+ listItems: contactFields,
+ },
+ ],
+};
+
+export const zohoCampaignsGetMailingListDetailsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'contactDetails',
+ label: 'List Details',
+ children: [
+ { key: 'listname', label: 'List Name' },
+ { key: 'noofcontacts', label: 'Contacts' },
+ { key: 'ispublic', label: 'Is Public', format: 'boolean' },
+ { key: 'owner_name', label: 'Owner Name' },
+ { key: 'owner_email', label: 'Owner Email', format: 'email' },
+ { key: 'date', label: 'Created Date' },
+ { key: 'created_time_gmt', label: 'Created Time (GMT)', format: 'datetime' },
+ { key: 'segments', label: 'Segments' },
+ { key: 'zuid', label: 'Owner User ID', format: 'number' },
+ ],
+ },
+ {
+ key: 'contact_stats',
+ label: 'Contact Stats',
+ children: [
+ { key: 'no_of_active', label: 'Active Contacts', format: 'number' },
+ { key: 'no_of_unsub', label: 'Unsubscribed Contacts', format: 'number' },
+ { key: 'no_of_bounce', label: 'Bounced Contacts', format: 'number' },
+ { key: 'sent_count', label: 'Campaigns Sent', format: 'number' },
+ { key: 'schedule_count', label: 'Campaigns Scheduled', format: 'number' },
+ ],
+ },
+ { key: 'campaign_details', label: 'Campaigns' },
+ { key: 'localsubscribers', label: 'Subscribers by Location' },
+ { key: 'open_subscribers_location', label: 'Opens by Location' },
+ {
+ key: 'requestdetails',
+ label: 'Request Details',
+ children: [
+ { key: 'filtertype', label: 'Campaign Filter' },
+ { key: 'fromindex', label: 'From Index', format: 'number' },
+ { key: 'range', label: 'Range', format: 'number' },
+ ],
+ },
+ ...responseFields,
+ ],
+};
+
+export const zohoCampaignsListMailingListsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'list_of_details',
+ label: 'Mailing Lists',
+ labelKey: 'listname',
+ listItems: [
+ { key: 'listkey', label: 'List Key' },
+ { key: 'listname', label: 'List Name' },
+ { key: 'listdesc', label: 'Description' },
+ { key: 'noofcontacts', label: 'Contacts' },
+ { key: 'noofunsubcnt', label: 'Unsubscribed Contacts' },
+ { key: 'noofbouncecnt', label: 'Bounced Contacts' },
+ { key: 'sentcnt', label: 'Campaigns Sent' },
+ { key: 'list_campaigns_count', label: 'Campaigns' },
+ { key: 'segments', label: 'Segments' },
+ { key: 'is_public', label: 'Is Public' },
+ { key: 'owner', label: 'Owner' },
+ { key: 'lockstatus', label: 'Lock Status' },
+ { key: 'editable', label: 'Editable' },
+ { key: 'deletable', label: 'Deletable' },
+ { key: 'issmart', label: 'Is Smart List' },
+ { key: 'otherslist', label: 'Owned by Another User' },
+ { key: 'listtype', label: 'List Type' },
+ { key: 'servicetype', label: 'Service Type' },
+ { key: 'listnotifications', label: 'Notifications' },
+ { key: 'date', label: 'Created Date' },
+ { key: 'list_created_date', label: 'Created At', format: 'datetime' },
+ { key: 'list_created_time', label: 'Created Time', format: 'datetime' },
+ { key: 'created_time', label: 'Created Time (ms)', format: 'datetime' },
+ { key: 'created_time_gmt', label: 'Created Time (GMT)', format: 'datetime' },
+ { key: 'updated_time_gmt', label: 'Updated Time (GMT)', format: 'datetime' },
+ { key: 'listdgs', label: 'List Digest' },
+ { key: 'listunino', label: 'List Number' },
+ { key: 'sno', label: 'Serial Number' },
+ { key: 'zuid', label: 'Owner User ID' },
+ { key: 'zx', label: 'ZX' },
+ ],
+ },
+ {
+ key: 'requestdetails',
+ label: 'Request Details',
+ children: [
+ { key: 'fromindex', label: 'From Index', format: 'number' },
+ { key: 'range', label: 'Range', format: 'number' },
+ { key: 'total_list_count', label: 'Total Lists', format: 'number' },
+ { key: 'sort', label: 'Sort' },
+ ],
+ },
+ ...responseFields,
+ ],
+};
+
+export const zohoCampaignsNewCampaignOutputSchema: OutputSchema = {
+ fields: campaignSummaryFields,
+};
+
+export const zohoCampaignsContactOutputSchema: OutputSchema = {
+ fields: contactFields,
+};
+
+export const zohoCampaignsAddTagToContactOutputSchema: OutputSchema = {
+ fields: [{ key: 'tagCreated', label: 'Tag Created', format: 'boolean' }, ...statusFields],
+};
+
+export const zohoCampaignsCreateTagOutputSchema: OutputSchema = {
+ fields: [{ key: 'TagInfoId', label: 'Tag ID', format: 'number' }, ...statusFields],
+};
+
+export const zohoCampaignsListTagsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'tags',
+ label: 'Tags',
+ labelKey: 'tag_name',
+ listItems: [
+ { key: 'tag_id', label: 'Tag ID' },
+ { key: 'tag_name', label: 'Tag Name' },
+ { key: 'tag_desc', label: 'Description' },
+ { key: 'tag_color', label: 'Color' },
+ { key: 'tagged_contact_count', label: 'Tagged Contacts' },
+ { key: 'tagowner', label: 'Owner' },
+ { key: 'tag_created_time', label: 'Created Time' },
+ { key: 'tag_modified_time', label: 'Modified Time' },
+ { key: 'is_crm_tag', label: 'Is CRM Tag' },
+ { key: 'zuid', label: 'Owner User ID' },
+ ],
+ },
+ ],
+};
+
+export const zohoCampaignsCreateTopicOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'topic_id', label: 'Topic ID' },
+ { key: 'code', label: 'Code' },
+ { key: 'message', label: 'Message' },
+ { key: 'uri', label: 'URI' },
+ ],
+};
+
+export const zohoCampaignsListTopicsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'topicDetails',
+ label: 'Topics',
+ labelKey: 'topicName',
+ listItems: [
+ { key: 'topicId', label: 'Topic ID' },
+ { key: 'topicName', label: 'Topic Name' },
+ { key: 'topicDesc', label: 'Description' },
+ ],
+ },
+ { key: 'total_count', label: 'Total Topics', format: 'number' },
+ { key: 'code', label: 'Code' },
+ { key: 'message', label: 'Message' },
+ { key: 'uri', label: 'URI' },
+ ],
+};
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-campaign.ts b/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-campaign.ts
index 860dd054869..545d290290e 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-campaign.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-campaign.ts
@@ -9,7 +9,9 @@ import {
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsNewCampaignOutputSchema } from '../output-schemas';
const polling: Polling<
AppConnectionValueForAuthProperty<typeof zohoCampaignsAuth>,
@@ -17,12 +19,7 @@ const polling: Polling<
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth }) => {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
- const items = await zohoCampaignsCommon.listCampaigns({
- accessToken,
- location,
- });
+ const items = await zohoCampaignsApi.listCampaigns({ auth });
return items.map((item) => ({
epochMilliSeconds: dayjs(item.created_date_string).valueOf(),
data: item,
@@ -30,9 +27,10 @@ const polling: Polling<
},
};
-export const newCampaign = createTrigger({
+export const newCampaignTrigger = createTrigger({
auth: zohoCampaignsAuth,
name: 'newCampaign',
+ outputSchema: zohoCampaignsNewCampaignOutputSchema,
classification: 'READ',
displayName: 'New Campaign',
description: 'Fires when a new campaign is created.',
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-contact.ts b/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-contact.ts
index 91ee8f98b3f..e4e4b95955e 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-contact.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/triggers/new-contact.ts
@@ -6,32 +6,30 @@ import {
import {
AppConnectionValueForAuthProperty,
createTrigger,
- PiecePropValueSchema,
- StaticPropsValue,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import { zohoCampaignsContactOutputSchema } from '../output-schemas';
const polling: Polling<
AppConnectionValueForAuthProperty<typeof zohoCampaignsAuth>,
- StaticPropsValue<any>
+ { listkey: string | undefined }
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth, propsValue }) => {
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
const { listkey } = propsValue;
if (!listkey) {
throw new Error('Mailing list is required');
}
- const items = await zohoCampaignsCommon.listContacts({
- accessToken,
- location,
+ const items = await zohoCampaignsApi.listContacts({
+ auth,
listkey,
- sort:'desc',
+ sort: 'desc',
});
return items.map((item) => ({
@@ -41,9 +39,10 @@ const polling: Polling<
},
};
-export const newContact = createTrigger({
+export const newContactTrigger = createTrigger({
auth: zohoCampaignsAuth,
name: 'newContact',
+ outputSchema: zohoCampaignsContactOutputSchema,
classification: 'READ',
displayName: 'New Contact',
description: 'Fires when a new contact is added to a selected mailing list.',
@@ -51,7 +50,9 @@ export const newContact = createTrigger({
description:
'Fires when a new contact appears in the selected Zoho Campaigns mailing list, representing a newly added subscriber. Polls the list and emits each new contact record.',
},
- props: zohoCampaignsCommon.newContactProperties(),
+ props: {
+ listkey: zohoCampaignsProps.listKey({ required: true }),
+ },
sampleData: {
contact_email: '[email protected]',
firstname: 'John',
diff --git a/packages/pieces/community/zoho-campaigns/src/lib/triggers/unsubscribe.ts b/packages/pieces/community/zoho-campaigns/src/lib/triggers/unsubscribe.ts
index 8d4e97d6fd8..4c4818c43a2 100644
--- a/packages/pieces/community/zoho-campaigns/src/lib/triggers/unsubscribe.ts
+++ b/packages/pieces/community/zoho-campaigns/src/lib/triggers/unsubscribe.ts
@@ -6,31 +6,33 @@ import {
import {
AppConnectionValueForAuthProperty,
createTrigger,
- PiecePropValueSchema,
- StaticPropsValue,
+ Property,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import dayjs from 'dayjs';
-import { zohoCampaignsAuth, zohoCampaignsCommon } from '../common';
+import { zohoCampaignsAuth } from '../auth';
+import { zohoCampaignsApi } from '../common/api';
+import { zohoCampaignsProps } from '../common/props';
+import type { ZohoCampaignsContactStatus } from '../common/types';
+import { zohoCampaignsContactOutputSchema } from '../output-schemas';
-// replace auth with piece auth variable
const polling: Polling<
AppConnectionValueForAuthProperty<typeof zohoCampaignsAuth>,
- StaticPropsValue<any>
+ {
+ listkey: string | undefined;
+ status: ZohoCampaignsContactStatus | undefined;
+ }
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth, propsValue }) => {
const { listkey, status = 'unsub' } = propsValue;
- const location = auth.props?.['location'] as string || 'zoho.com';
- const accessToken = auth.access_token;
if (!listkey) {
throw new Error('Mailing list is required');
}
- const items = await zohoCampaignsCommon.listContacts({
- accessToken,
- location,
+ const items = await zohoCampaignsApi.listContacts({
+ auth,
listkey,
sort: 'desc',
status,
@@ -42,9 +44,10 @@ const polling: Polling<
},
};
-export const unsubscribe = createTrigger({
+export const unsubscribeTrigger = createTrigger({
auth: zohoCampaignsAuth,
name: 'unsubscribe',
+ outputSchema: zohoCampaignsContactOutputSchema,
classification: 'READ',
displayName: 'Unsubscribe',
description:
@@ -53,7 +56,21 @@ export const unsubscribe = createTrigger({
description:
'Fires when a contact in the selected mailing list reaches the unsubscribed status, representing a subscriber who has opted out or been removed. Polls the list for contacts with that status.',
},
- props: zohoCampaignsCommon.unsubscribeProperties(),
+ props: {
+ listkey: zohoCampaignsProps.listKey({ required: true }),
+ status: Property.StaticDropdown<ZohoCampaignsContactStatus, false>({
+ displayName: 'Unsubscribe Type',
+ description:
+ 'Type of contact removal to monitor (default: unsubscribed)',
+ required: false,
+ options: {
+ options: [
+ { label: 'Unsubscribed', value: 'unsub' },
+ { label: 'Bounced', value: 'bounce' },
+ ],
+ },
+ }),
+ },
sampleData: {
contact_email: '[email protected]',
firstname: 'John',