chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
+141
View File
@@ -0,0 +1,141 @@
import { createLogger } from '@sim/logger'
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpAddMember')
export interface MailchimpAddMemberParams {
apiKey: string
listId: string
emailAddress: string
status: string
mergeFields?: string
interests?: string
}
export interface MailchimpAddMemberResponse {
success: boolean
output: {
member: MailchimpMember
subscriber_hash: string
success: boolean
}
}
export const mailchimpAddMemberTool: ToolConfig<
MailchimpAddMemberParams,
MailchimpAddMemberResponse
> = {
id: 'mailchimp_add_member',
name: 'Add Member to Mailchimp Audience',
description: 'Add a new member to a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
emailAddress: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address (e.g., "user@example.com")',
},
status: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Subscriber status: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional"',
},
mergeFields: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of merge fields (e.g., {"FNAME": "John", "LNAME": "Doe"})',
},
interests: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of interest IDs and their boolean values (e.g., {"abc123": true})',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {
email_address: params.emailAddress,
status: params.status,
}
if (params.mergeFields) {
try {
body.merge_fields = JSON.parse(params.mergeFields)
} catch (error) {
logger.warn('Failed to parse merge fields', { error })
}
}
if (params.interests) {
try {
body.interests = JSON.parse(params.interests)
} catch (error) {
logger.warn('Failed to parse interests', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'add_member')
}
const data = await response.json()
return {
success: true,
output: {
member: data,
subscriber_hash: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Added member data',
properties: {
member: { type: 'json', description: 'Added member object' },
subscriber_hash: { type: 'string', description: 'Subscriber hash ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+104
View File
@@ -0,0 +1,104 @@
import { createLogger } from '@sim/logger'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpAddMemberTags')
export interface MailchimpAddMemberTagsParams {
apiKey: string
listId: string
subscriberEmail: string
tags: string
}
export interface MailchimpAddMemberTagsResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpAddMemberTagsTool: ToolConfig<
MailchimpAddMemberTagsParams,
MailchimpAddMemberTagsResponse
> = {
id: 'mailchimp_add_member_tags',
name: 'Add Tags to Member in Mailchimp',
description: 'Add tags to a member in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
tags: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'JSON array of tag objects (e.g., [{"name": "VIP", "status": "active"}])',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/members/${params.subscriberEmail}/tags`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
let tags = []
try {
tags = JSON.parse(params.tags)
} catch (error) {
logger.warn('Failed to parse tags', { error })
}
return { tags }
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'add_member_tags')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Tag addition confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,149 @@
import { createLogger } from '@sim/logger'
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpAddOrUpdateMember')
export interface MailchimpAddOrUpdateMemberParams {
apiKey: string
listId: string
subscriberEmail: string
emailAddress: string
statusIfNew: string
mergeFields?: string
interests?: string
}
export interface MailchimpAddOrUpdateMemberResponse {
success: boolean
output: {
member: MailchimpMember
subscriber_hash: string
success: boolean
}
}
export const mailchimpAddOrUpdateMemberTool: ToolConfig<
MailchimpAddOrUpdateMemberParams,
MailchimpAddOrUpdateMemberResponse
> = {
id: 'mailchimp_add_or_update_member',
name: 'Add or Update Member in Mailchimp Audience',
description: 'Add a new member or update an existing member in a Mailchimp audience (upsert)',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
emailAddress: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address (e.g., "user@example.com")',
},
statusIfNew: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Subscriber status if new: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional"',
},
mergeFields: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of merge fields (e.g., {"FNAME": "John", "LNAME": "Doe"})',
},
interests: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of interest IDs and their boolean values (e.g., {"abc123": true})',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
method: 'PUT',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {
email_address: params.emailAddress,
status_if_new: params.statusIfNew,
}
if (params.mergeFields) {
try {
body.merge_fields = JSON.parse(params.mergeFields)
} catch (error) {
logger.warn('Failed to parse merge fields', { error })
}
}
if (params.interests) {
try {
body.interests = JSON.parse(params.interests)
} catch (error) {
logger.warn('Failed to parse interests', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'add_or_update_member')
}
const data = await response.json()
return {
success: true,
output: {
member: data,
subscriber_hash: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Member data',
properties: {
member: { type: 'json', description: 'Member object' },
subscriber_hash: { type: 'string', description: 'Subscriber hash ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,103 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpAddSegmentMemberParams {
apiKey: string
listId: string
segmentId: string
emailAddress: string
}
export interface MailchimpAddSegmentMemberResponse {
success: boolean
output: {
member: MailchimpMember
success: boolean
}
}
export const mailchimpAddSegmentMemberTool: ToolConfig<
MailchimpAddSegmentMemberParams,
MailchimpAddSegmentMemberResponse
> = {
id: 'mailchimp_add_segment_member',
name: 'Add Member to Segment in Mailchimp',
description: 'Add a member to a specific segment in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the segment (e.g., "12345")',
},
emailAddress: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Email address of the member (e.g., "user@example.com")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/segments/${params.segmentId}/members`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
email_address: params.emailAddress,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'add_segment_member')
}
const data = await response.json()
return {
success: true,
output: {
member: data,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Added member data',
properties: {
member: { type: 'json', description: 'Added member object' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,100 @@
import type { MailchimpMember } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpAddSubscriberToAutomationParams {
apiKey: string
workflowId: string
workflowEmailId: string
emailAddress: string
}
export interface MailchimpAddSubscriberToAutomationResponse {
success: boolean
output: {
subscriber: MailchimpMember
success: boolean
}
}
export const mailchimpAddSubscriberToAutomationTool: ToolConfig<
MailchimpAddSubscriberToAutomationParams,
MailchimpAddSubscriberToAutomationResponse
> = {
id: 'mailchimp_add_subscriber_to_automation',
name: 'Add Subscriber to Automation in Mailchimp',
description: 'Manually add a subscriber to a workflow email queue',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
workflowId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the automation workflow (e.g., "abc123def4")',
},
workflowEmailId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the workflow email (e.g., "xyz789")',
},
emailAddress: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Email address of the subscriber (e.g., "user@example.com")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/automations/${params.workflowId}/emails/${params.workflowEmailId}/queue`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
email_address: params.emailAddress,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'add_subscriber_to_automation')
}
const data = await response.json()
return {
success: true,
output: {
subscriber: data,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Subscriber queue data',
properties: {
subscriber: { type: 'json', description: 'Subscriber object' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,84 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpArchiveMemberParams {
apiKey: string
listId: string
subscriberEmail: string
}
export interface MailchimpArchiveMemberResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpArchiveMemberTool: ToolConfig<
MailchimpArchiveMemberParams,
MailchimpArchiveMemberResponse
> = {
id: 'mailchimp_archive_member',
name: 'Archive Member from Mailchimp Audience',
description: 'Permanently archive (delete) a member from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/members/${params.subscriberEmail}/actions/delete-permanent`
),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'archive_member')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Archive confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+141
View File
@@ -0,0 +1,141 @@
import { createLogger } from '@sim/logger'
import type { MailchimpAudience } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpCreateAudience')
export interface MailchimpCreateAudienceParams {
apiKey: string
audienceName: string
contact: string
permissionReminder: string
campaignDefaults: string
emailTypeOption: string
}
export interface MailchimpCreateAudienceResponse {
success: boolean
output: {
list: MailchimpAudience
list_id: string
success: boolean
}
}
export const mailchimpCreateAudienceTool: ToolConfig<
MailchimpCreateAudienceParams,
MailchimpCreateAudienceResponse
> = {
id: 'mailchimp_create_audience',
name: 'Create Audience in Mailchimp',
description: 'Create a new audience (list) in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
audienceName: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The name of the audience/list (e.g., "Newsletter Subscribers")',
},
contact: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'JSON object of contact information (e.g., {"company": "Acme", "address1": "123 Main St", "city": "NYC", "state": "NY", "zip": "10001", "country": "US"})',
},
permissionReminder: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Permission reminder text shown to subscribers (e.g., "You signed up for updates on our website")',
},
campaignDefaults: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'JSON object of default campaign settings (e.g., {"from_name": "Acme", "from_email": "news@acme.com", "subject": "", "language": "en"})',
},
emailTypeOption: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Support multiple email formats: "true" or "false"',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, '/lists'),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {
name: params.audienceName,
permission_reminder: params.permissionReminder,
email_type_option: params.emailTypeOption === 'true',
}
if (params.contact) {
try {
body.contact = JSON.parse(params.contact)
} catch (error) {
logger.warn('Failed to parse contact', { error })
}
}
if (params.campaignDefaults) {
try {
body.campaign_defaults = JSON.parse(params.campaignDefaults)
} catch (error) {
logger.warn('Failed to parse campaign defaults', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_audience')
}
const data = await response.json()
return {
success: true,
output: {
list: data,
list_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created audience data',
properties: {
list: { type: 'json', description: 'Created audience/list object' },
list_id: { type: 'string', description: 'Created audience/list ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,96 @@
import { createLogger } from '@sim/logger'
import type { MailchimpBatchOperation } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpCreateBatchOperation')
export interface MailchimpCreateBatchOperationParams {
apiKey: string
operations: string
}
export interface MailchimpCreateBatchOperationResponse {
success: boolean
output: {
batch: MailchimpBatchOperation
batch_id: string
success: boolean
}
}
export const mailchimpCreateBatchOperationTool: ToolConfig<
MailchimpCreateBatchOperationParams,
MailchimpCreateBatchOperationResponse
> = {
id: 'mailchimp_create_batch_operation',
name: 'Create Batch Operation in Mailchimp',
description: 'Create a new batch operation in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
operations: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'JSON array of batch operations (e.g., [{"method": "POST", "path": "/lists/{list_id}/members", "body": "..."}])',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, '/batches'),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
let operations = []
try {
operations = JSON.parse(params.operations)
} catch (error) {
logger.warn('Failed to parse operations', { error })
}
return { operations }
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_batch_operation')
}
const data = await response.json()
return {
success: true,
output: {
batch: data,
batch_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created batch operation data',
properties: {
batch: { type: 'json', description: 'Created batch operation object' },
batch_id: { type: 'string', description: 'Created batch operation ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+126
View File
@@ -0,0 +1,126 @@
import { createLogger } from '@sim/logger'
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaign,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpCreateCampaign')
export interface MailchimpCreateCampaignParams {
apiKey: string
campaignType: string
campaignSettings: string
recipients?: string
}
export interface MailchimpCreateCampaignResponse {
success: boolean
output: {
campaign: MailchimpCampaign
campaign_id: string
success: boolean
}
}
export const mailchimpCreateCampaignTool: ToolConfig<
MailchimpCreateCampaignParams,
MailchimpCreateCampaignResponse
> = {
id: 'mailchimp_create_campaign',
name: 'Create Campaign in Mailchimp',
description: 'Create a new campaign in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignType: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Campaign type: "regular", "plaintext", "absplit", "rss", or "variate"',
},
campaignSettings: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'JSON object of campaign settings (e.g., {"subject_line": "Newsletter", "from_name": "Acme", "reply_to": "news@acme.com"})',
},
recipients: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of recipients (e.g., {"list_id": "abc123"})',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, '/campaigns'),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {
type: params.campaignType,
}
if (params.campaignSettings) {
try {
body.settings = JSON.parse(params.campaignSettings)
} catch (error) {
logger.warn('Failed to parse campaign settings', { error })
}
}
if (params.recipients) {
try {
body.recipients = JSON.parse(params.recipients)
} catch (error) {
logger.warn('Failed to parse recipients', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_campaign')
}
const data = await response.json()
return {
success: true,
output: {
campaign: data,
campaign_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created campaign data',
properties: {
campaign: { type: 'json', description: 'Created campaign object' },
campaign_id: { type: 'string', description: 'Created campaign ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+103
View File
@@ -0,0 +1,103 @@
import type { MailchimpInterest } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpCreateInterestParams {
apiKey: string
listId: string
interestCategoryId: string
interestName: string
}
export interface MailchimpCreateInterestResponse {
success: boolean
output: {
interest: MailchimpInterest
interest_id: string
success: boolean
}
}
export const mailchimpCreateInterestTool: ToolConfig<
MailchimpCreateInterestParams,
MailchimpCreateInterestResponse
> = {
id: 'mailchimp_create_interest',
name: 'Create Interest in Mailchimp Interest Category',
description: 'Create a new interest in an interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
interestName: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The name of the interest (e.g., "Weekly Updates")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
name: params.interestName,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_interest')
}
const data = await response.json()
return {
success: true,
output: {
interest: data,
interest_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created interest data',
properties: {
interest: { type: 'json', description: 'Created interest object' },
interest_id: { type: 'string', description: 'Created interest ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,101 @@
import type { MailchimpInterestCategory } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpCreateInterestCategoryParams {
apiKey: string
listId: string
interestCategoryTitle: string
interestCategoryType: string
}
export interface MailchimpCreateInterestCategoryResponse {
success: boolean
output: {
category: MailchimpInterestCategory
interest_category_id: string
success: boolean
}
}
export const mailchimpCreateInterestCategoryTool: ToolConfig<
MailchimpCreateInterestCategoryParams,
MailchimpCreateInterestCategoryResponse
> = {
id: 'mailchimp_create_interest_category',
name: 'Create Interest Category in Mailchimp Audience',
description: 'Create a new interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryTitle: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The title of the interest category (e.g., "Email Preferences")',
},
interestCategoryType: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The type of interest category: "checkboxes", "dropdown", "radio", or "hidden"',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/interest-categories`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
title: params.interestCategoryTitle,
type: params.interestCategoryType,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_interest_category')
}
const data = await response.json()
return {
success: true,
output: {
category: data,
interest_category_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created interest category data',
properties: {
category: { type: 'json', description: 'Created interest category object' },
interest_category_id: { type: 'string', description: 'Created interest category ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,98 @@
import type { MailchimpLandingPage } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpCreateLandingPageParams {
apiKey: string
landingPageType: string
landingPageTitle?: string
}
export interface MailchimpCreateLandingPageResponse {
success: boolean
output: {
landingPage: MailchimpLandingPage
page_id: string
success: boolean
}
}
export const mailchimpCreateLandingPageTool: ToolConfig<
MailchimpCreateLandingPageParams,
MailchimpCreateLandingPageResponse
> = {
id: 'mailchimp_create_landing_page',
name: 'Create Landing Page in Mailchimp',
description: 'Create a new landing page in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
landingPageType: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The type of landing page: "signup"',
},
landingPageTitle: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The title of the landing page (e.g., "Join Our Newsletter")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, '/landing-pages'),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {
type: params.landingPageType,
}
if (params.landingPageTitle) body.title = params.landingPageTitle
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_landing_page')
}
const data = await response.json()
return {
success: true,
output: {
landingPage: data,
page_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created landing page data',
properties: {
landingPage: { type: 'json', description: 'Created landing page object' },
page_id: { type: 'string', description: 'Created landing page ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,101 @@
import type { MailchimpMergeField } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpCreateMergeFieldParams {
apiKey: string
listId: string
mergeName: string
mergeType: string
}
export interface MailchimpCreateMergeFieldResponse {
success: boolean
output: {
mergeField: MailchimpMergeField
merge_id: string
success: boolean
}
}
export const mailchimpCreateMergeFieldTool: ToolConfig<
MailchimpCreateMergeFieldParams,
MailchimpCreateMergeFieldResponse
> = {
id: 'mailchimp_create_merge_field',
name: 'Create Merge Field in Mailchimp Audience',
description: 'Create a new merge field in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
mergeName: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The name of the merge field (e.g., "First Name")',
},
mergeType: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'The type of the merge field: "text", "number", "address", "phone", "date", "url", "imageurl", "radio", "dropdown", "birthday", or "zip"',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
name: params.mergeName,
type: params.mergeType,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_merge_field')
}
const data = await response.json()
return {
success: true,
output: {
mergeField: data,
merge_id: data.merge_id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created merge field data',
properties: {
mergeField: { type: 'json', description: 'Created merge field object' },
merge_id: { type: 'string', description: 'Created merge field ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+116
View File
@@ -0,0 +1,116 @@
import { createLogger } from '@sim/logger'
import type { MailchimpSegment } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpCreateSegment')
export interface MailchimpCreateSegmentParams {
apiKey: string
listId: string
segmentName: string
segmentOptions?: string
}
export interface MailchimpCreateSegmentResponse {
success: boolean
output: {
segment: MailchimpSegment
segment_id: string
success: boolean
}
}
export const mailchimpCreateSegmentTool: ToolConfig<
MailchimpCreateSegmentParams,
MailchimpCreateSegmentResponse
> = {
id: 'mailchimp_create_segment',
name: 'Create Segment in Mailchimp Audience',
description: 'Create a new segment in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentName: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The name of the segment (e.g., "VIP Customers")',
},
segmentOptions: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'JSON object of segment options for saved segments (e.g., {"match": "all", "conditions": [...]})',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {
name: params.segmentName,
}
if (params.segmentOptions) {
try {
const options = JSON.parse(params.segmentOptions)
body.options = options
} catch (error) {
logger.warn('Failed to parse segment options', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_segment')
}
const data = await response.json()
return {
success: true,
output: {
segment: data,
segment_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created segment data',
properties: {
segment: { type: 'json', description: 'Created segment object' },
segment_id: { type: 'string', description: 'Created segment ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,92 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpCreateTemplateParams {
apiKey: string
templateName: string
templateHtml: string
}
export interface MailchimpCreateTemplateResponse {
success: boolean
output: {
template: any
template_id: string
success: boolean
}
}
export const mailchimpCreateTemplateTool: ToolConfig<
MailchimpCreateTemplateParams,
MailchimpCreateTemplateResponse
> = {
id: 'mailchimp_create_template',
name: 'Create Template in Mailchimp',
description: 'Create a new template in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
templateName: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The name of the template (e.g., "Monthly Newsletter")',
},
templateHtml: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The HTML content for the template',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, '/templates'),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
name: params.templateName,
html: params.templateHtml,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'create_template')
}
const data = await response.json()
return {
success: true,
output: {
template: data,
template_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Created template data',
properties: {
template: { type: 'json', description: 'Created template object' },
template_id: { type: 'string', description: 'Created template ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,60 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteAudienceParams {
apiKey: string
listId: string
}
export interface MailchimpDeleteAudienceResponse {
success: boolean
}
export const mailchimpDeleteAudienceTool: ToolConfig<
MailchimpDeleteAudienceParams,
MailchimpDeleteAudienceResponse
> = {
id: 'mailchimp_delete_audience',
name: 'Delete Audience from Mailchimp',
description: 'Delete an audience (list) from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list to delete (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_audience')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the audience was successfully deleted' },
},
}
@@ -0,0 +1,63 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteBatchOperationParams {
apiKey: string
batchId: string
}
export interface MailchimpDeleteBatchOperationResponse {
success: boolean
}
export const mailchimpDeleteBatchOperationTool: ToolConfig<
MailchimpDeleteBatchOperationParams,
MailchimpDeleteBatchOperationResponse
> = {
id: 'mailchimp_delete_batch_operation',
name: 'Delete Batch Operation from Mailchimp',
description: 'Delete a batch operation from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
batchId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the batch operation to delete (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/batches/${params.batchId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_batch_operation')
}
return {
success: true,
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the batch operation was successfully deleted',
},
},
}
@@ -0,0 +1,60 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteCampaignParams {
apiKey: string
campaignId: string
}
export interface MailchimpDeleteCampaignResponse {
success: boolean
}
export const mailchimpDeleteCampaignTool: ToolConfig<
MailchimpDeleteCampaignParams,
MailchimpDeleteCampaignResponse
> = {
id: 'mailchimp_delete_campaign',
name: 'Delete Campaign from Mailchimp',
description: 'Delete a campaign from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign to delete (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_campaign')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the campaign was successfully deleted' },
},
}
@@ -0,0 +1,78 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteInterestParams {
apiKey: string
listId: string
interestCategoryId: string
interestId: string
}
export interface MailchimpDeleteInterestResponse {
success: boolean
}
export const mailchimpDeleteInterestTool: ToolConfig<
MailchimpDeleteInterestParams,
MailchimpDeleteInterestResponse
> = {
id: 'mailchimp_delete_interest',
name: 'Delete Interest from Mailchimp Interest Category',
description: 'Delete an interest from an interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
interestId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest to delete (e.g., "def456")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests/${params.interestId}`
),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_interest')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the interest was successfully deleted' },
},
}
@@ -0,0 +1,74 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteInterestCategoryParams {
apiKey: string
listId: string
interestCategoryId: string
}
export interface MailchimpDeleteInterestCategoryResponse {
success: boolean
}
export const mailchimpDeleteInterestCategoryTool: ToolConfig<
MailchimpDeleteInterestCategoryParams,
MailchimpDeleteInterestCategoryResponse
> = {
id: 'mailchimp_delete_interest_category',
name: 'Delete Interest Category from Mailchimp Audience',
description: 'Delete an interest category from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category to delete (e.g., "xyz789")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}`
),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_interest_category')
}
return {
success: true,
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the interest category was successfully deleted',
},
},
}
@@ -0,0 +1,60 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteLandingPageParams {
apiKey: string
pageId: string
}
export interface MailchimpDeleteLandingPageResponse {
success: boolean
}
export const mailchimpDeleteLandingPageTool: ToolConfig<
MailchimpDeleteLandingPageParams,
MailchimpDeleteLandingPageResponse
> = {
id: 'mailchimp_delete_landing_page',
name: 'Delete Landing Page from Mailchimp',
description: 'Delete a landing page from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
pageId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the landing page to delete (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_landing_page')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the landing page was successfully deleted' },
},
}
+68
View File
@@ -0,0 +1,68 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteMemberParams {
apiKey: string
listId: string
subscriberEmail: string
}
export interface MailchimpDeleteMemberResponse {
success: boolean
}
export const mailchimpDeleteMemberTool: ToolConfig<
MailchimpDeleteMemberParams,
MailchimpDeleteMemberResponse
> = {
id: 'mailchimp_delete_member',
name: 'Delete Member from Mailchimp Audience',
description: 'Delete a member from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_member')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the member was successfully deleted' },
},
}
@@ -0,0 +1,68 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteMergeFieldParams {
apiKey: string
listId: string
mergeId: string
}
export interface MailchimpDeleteMergeFieldResponse {
success: boolean
}
export const mailchimpDeleteMergeFieldTool: ToolConfig<
MailchimpDeleteMergeFieldParams,
MailchimpDeleteMergeFieldResponse
> = {
id: 'mailchimp_delete_merge_field',
name: 'Delete Merge Field from Mailchimp Audience',
description: 'Delete a merge field from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
mergeId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the merge field to delete (e.g., "1" or "FNAME")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields/${params.mergeId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_merge_field')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the merge field was successfully deleted' },
},
}
@@ -0,0 +1,68 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteSegmentParams {
apiKey: string
listId: string
segmentId: string
}
export interface MailchimpDeleteSegmentResponse {
success: boolean
}
export const mailchimpDeleteSegmentTool: ToolConfig<
MailchimpDeleteSegmentParams,
MailchimpDeleteSegmentResponse
> = {
id: 'mailchimp_delete_segment',
name: 'Delete Segment from Mailchimp Audience',
description: 'Delete a segment from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the segment to delete (e.g., "12345")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments/${params.segmentId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_segment')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the segment was successfully deleted' },
},
}
@@ -0,0 +1,60 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpDeleteTemplateParams {
apiKey: string
templateId: string
}
export interface MailchimpDeleteTemplateResponse {
success: boolean
}
export const mailchimpDeleteTemplateTool: ToolConfig<
MailchimpDeleteTemplateParams,
MailchimpDeleteTemplateResponse
> = {
id: 'mailchimp_delete_template',
name: 'Delete Template from Mailchimp',
description: 'Delete a template from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
templateId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the template to delete (e.g., "12345")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/templates/${params.templateId}`),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'delete_template')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the template was successfully deleted' },
},
}
+79
View File
@@ -0,0 +1,79 @@
import type { MailchimpAudience } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetAudienceParams {
apiKey: string
listId: string
}
export interface MailchimpGetAudienceResponse {
success: boolean
output: {
list: MailchimpAudience
list_id: string
}
}
export const mailchimpGetAudienceTool: ToolConfig<
MailchimpGetAudienceParams,
MailchimpGetAudienceResponse
> = {
id: 'mailchimp_get_audience',
name: 'Get Audience from Mailchimp',
description: 'Retrieve details of a specific audience (list) from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_audience')
}
const data = await response.json()
return {
success: true,
output: {
list: data,
list_id: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the audience was successfully retrieved' },
output: {
type: 'object',
description: 'Audience data',
properties: {
list: { type: 'json', description: 'Audience/list object' },
list_id: { type: 'string', description: 'The unique ID of the audience' },
},
},
},
}
+101
View File
@@ -0,0 +1,101 @@
import type { MailchimpAudience } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetAudiencesParams {
apiKey: string
count?: string
offset?: string
}
export interface MailchimpGetAudiencesResponse {
success: boolean
output: {
lists: MailchimpAudience[]
total_items: number
total_returned: number
}
}
export const mailchimpGetAudiencesTool: ToolConfig<
MailchimpGetAudiencesParams,
MailchimpGetAudiencesResponse
> = {
id: 'mailchimp_get_audiences',
name: 'Get Audiences from Mailchimp',
description: 'Retrieve a list of audiences (lists) from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/lists')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_audiences')
}
const data = await response.json()
const lists = data.lists || []
return {
success: true,
output: {
lists,
total_items: data.total_items || lists.length,
total_returned: lists.length,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the audiences were successfully retrieved' },
output: {
type: 'object',
description: 'Audiences data',
properties: {
lists: { type: 'json', description: 'Array of audience/list objects' },
total_items: { type: 'number', description: 'Total number of lists' },
total_returned: {
type: 'number',
description: 'Number of lists returned in this response',
},
},
},
},
}
@@ -0,0 +1,79 @@
import type { MailchimpAutomation } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetAutomationParams {
apiKey: string
workflowId: string
}
export interface MailchimpGetAutomationResponse {
success: boolean
output: {
automation: MailchimpAutomation
workflow_id: string
}
}
export const mailchimpGetAutomationTool: ToolConfig<
MailchimpGetAutomationParams,
MailchimpGetAutomationResponse
> = {
id: 'mailchimp_get_automation',
name: 'Get Automation from Mailchimp',
description: 'Retrieve details of a specific automation from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
workflowId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the automation workflow (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/automations/${params.workflowId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_automation')
}
const data = await response.json()
return {
success: true,
output: {
automation: data,
workflow_id: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the automation was successfully retrieved' },
output: {
type: 'object',
description: 'Automation data',
properties: {
automation: { type: 'json', description: 'Automation object' },
workflow_id: { type: 'string', description: 'The unique ID of the automation workflow' },
},
},
},
}
+104
View File
@@ -0,0 +1,104 @@
import type { MailchimpAutomation } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetAutomationsParams {
apiKey: string
count?: string
offset?: string
}
export interface MailchimpGetAutomationsResponse {
success: boolean
output: {
automations: MailchimpAutomation[]
total_items: number
total_returned: number
}
}
export const mailchimpGetAutomationsTool: ToolConfig<
MailchimpGetAutomationsParams,
MailchimpGetAutomationsResponse
> = {
id: 'mailchimp_get_automations',
name: 'Get Automations from Mailchimp',
description: 'Retrieve a list of automations from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/automations')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_automations')
}
const data = await response.json()
const automations = data.automations || []
return {
success: true,
output: {
automations,
total_items: data.total_items || automations.length,
total_returned: automations.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the automations were successfully retrieved',
},
output: {
type: 'object',
description: 'Automations data',
properties: {
automations: { type: 'json', description: 'Array of automation objects' },
total_items: { type: 'number', description: 'Total number of automations' },
total_returned: {
type: 'number',
description: 'Number of automations returned in this response',
},
},
},
},
}
@@ -0,0 +1,82 @@
import type { MailchimpBatchOperation } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetBatchOperationParams {
apiKey: string
batchId: string
}
export interface MailchimpGetBatchOperationResponse {
success: boolean
output: {
batch: MailchimpBatchOperation
batch_id: string
}
}
export const mailchimpGetBatchOperationTool: ToolConfig<
MailchimpGetBatchOperationParams,
MailchimpGetBatchOperationResponse
> = {
id: 'mailchimp_get_batch_operation',
name: 'Get Batch Operation from Mailchimp',
description: 'Retrieve details of a specific batch operation from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
batchId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the batch operation (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/batches/${params.batchId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_batch_operation')
}
const data = await response.json()
return {
success: true,
output: {
batch: data,
batch_id: data.id,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the batch operation was successfully retrieved',
},
output: {
type: 'object',
description: 'Batch operation data',
properties: {
batch: { type: 'json', description: 'Batch operation object' },
batch_id: { type: 'string', description: 'The unique ID of the batch operation' },
},
},
},
}
@@ -0,0 +1,104 @@
import type { MailchimpBatchOperation } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetBatchOperationsParams {
apiKey: string
count?: string
offset?: string
}
export interface MailchimpGetBatchOperationsResponse {
success: boolean
output: {
batches: MailchimpBatchOperation[]
total_items: number
total_returned: number
}
}
export const mailchimpGetBatchOperationsTool: ToolConfig<
MailchimpGetBatchOperationsParams,
MailchimpGetBatchOperationsResponse
> = {
id: 'mailchimp_get_batch_operations',
name: 'Get Batch Operations from Mailchimp',
description: 'Retrieve a list of batch operations from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/batches')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_batch_operations')
}
const data = await response.json()
const batches = data.batches || []
return {
success: true,
output: {
batches,
total_items: data.total_items || batches.length,
total_returned: batches.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the batch operations were successfully retrieved',
},
output: {
type: 'object',
description: 'Batch operations data',
properties: {
batches: { type: 'json', description: 'Array of batch operation objects' },
total_items: { type: 'number', description: 'Total number of batch operations' },
total_returned: {
type: 'number',
description: 'Number of batch operations returned in this response',
},
},
},
},
}
+82
View File
@@ -0,0 +1,82 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaign,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetCampaignParams {
apiKey: string
campaignId: string
}
export interface MailchimpGetCampaignResponse {
success: boolean
output: {
campaign: MailchimpCampaign
campaign_id: string
}
}
export const mailchimpGetCampaignTool: ToolConfig<
MailchimpGetCampaignParams,
MailchimpGetCampaignResponse
> = {
id: 'mailchimp_get_campaign',
name: 'Get Campaign from Mailchimp',
description: 'Retrieve details of a specific campaign from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_campaign')
}
const data = await response.json()
return {
success: true,
output: {
campaign: data,
campaign_id: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the campaign was successfully retrieved' },
output: {
type: 'object',
description: 'Campaign data',
properties: {
campaign: { type: 'json', description: 'Campaign object' },
campaign_id: { type: 'string', description: 'The unique ID of the campaign' },
},
},
},
}
@@ -0,0 +1,82 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaignContent,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetCampaignContentParams {
apiKey: string
campaignId: string
}
export interface MailchimpGetCampaignContentResponse {
success: boolean
output: {
content: MailchimpCampaignContent
}
}
export const mailchimpGetCampaignContentTool: ToolConfig<
MailchimpGetCampaignContentParams,
MailchimpGetCampaignContentResponse
> = {
id: 'mailchimp_get_campaign_content',
name: 'Get Campaign Content from Mailchimp',
description: 'Retrieve the HTML and plain-text content for a Mailchimp campaign',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/content`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_campaign_content')
}
const data = await response.json()
return {
success: true,
output: {
content: data,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the campaign content was successfully retrieved',
},
output: {
type: 'object',
description: 'Campaign content data',
properties: {
content: { type: 'json', description: 'Campaign content object' },
},
},
},
}
@@ -0,0 +1,85 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaignReport,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetCampaignReportParams {
apiKey: string
campaignId: string
}
export interface MailchimpGetCampaignReportResponse {
success: boolean
output: {
report: MailchimpCampaignReport
campaign_id: string
}
}
export const mailchimpGetCampaignReportTool: ToolConfig<
MailchimpGetCampaignReportParams,
MailchimpGetCampaignReportResponse
> = {
id: 'mailchimp_get_campaign_report',
name: 'Get Campaign Report from Mailchimp',
description: 'Retrieve the report for a specific campaign from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/reports/${params.campaignId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_campaign_report')
}
const data = await response.json()
return {
success: true,
output: {
report: data,
campaign_id: data.campaign_id,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the campaign report was successfully retrieved',
},
output: {
type: 'object',
description: 'Campaign report data',
properties: {
report: { type: 'json', description: 'Campaign report object' },
campaign_id: { type: 'string', description: 'The unique ID of the campaign' },
},
},
},
}
@@ -0,0 +1,107 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaignReport,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetCampaignReportsParams {
apiKey: string
count?: string
offset?: string
}
export interface MailchimpGetCampaignReportsResponse {
success: boolean
output: {
reports: MailchimpCampaignReport[]
total_items: number
total_returned: number
}
}
export const mailchimpGetCampaignReportsTool: ToolConfig<
MailchimpGetCampaignReportsParams,
MailchimpGetCampaignReportsResponse
> = {
id: 'mailchimp_get_campaign_reports',
name: 'Get Campaign Reports from Mailchimp',
description: 'Retrieve a list of campaign reports from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/reports')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_campaign_reports')
}
const data = await response.json()
const reports = data.reports || []
return {
success: true,
output: {
reports,
total_items: data.total_items || reports.length,
total_returned: reports.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the campaign reports were successfully retrieved',
},
output: {
type: 'object',
description: 'Campaign reports data',
properties: {
reports: { type: 'json', description: 'Array of campaign report objects' },
total_items: { type: 'number', description: 'Total number of reports' },
total_returned: {
type: 'number',
description: 'Number of reports returned in this response',
},
},
},
},
}
+121
View File
@@ -0,0 +1,121 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaign,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetCampaignsParams {
apiKey: string
campaignType?: string
status?: string
count?: string
offset?: string
}
export interface MailchimpGetCampaignsResponse {
success: boolean
output: {
campaigns: MailchimpCampaign[]
total_items: number
total_returned: number
}
}
export const mailchimpGetCampaignsTool: ToolConfig<
MailchimpGetCampaignsParams,
MailchimpGetCampaignsResponse
> = {
id: 'mailchimp_get_campaigns',
name: 'Get Campaigns from Mailchimp',
description: 'Retrieve a list of campaigns from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignType: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Filter by campaign type: "regular", "plaintext", "absplit", "rss", or "variate"',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by status: "save", "paused", "schedule", "sending", or "sent"',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.campaignType) queryParams.append('type', params.campaignType)
if (params.status) queryParams.append('status', params.status)
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/campaigns')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_campaigns')
}
const data = await response.json()
const campaigns = data.campaigns || []
return {
success: true,
output: {
campaigns,
total_items: data.total_items || campaigns.length,
total_returned: campaigns.length,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the campaigns were successfully retrieved' },
output: {
type: 'object',
description: 'Campaigns data',
properties: {
campaigns: { type: 'json', description: 'Array of campaign objects' },
total_items: { type: 'number', description: 'Total number of campaigns' },
total_returned: {
type: 'number',
description: 'Number of campaigns returned in this response',
},
},
},
},
}
+98
View File
@@ -0,0 +1,98 @@
import type { MailchimpInterest } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetInterestParams {
apiKey: string
listId: string
interestCategoryId: string
interestId: string
}
export interface MailchimpGetInterestResponse {
success: boolean
output: {
interest: MailchimpInterest
interest_id: string
}
}
export const mailchimpGetInterestTool: ToolConfig<
MailchimpGetInterestParams,
MailchimpGetInterestResponse
> = {
id: 'mailchimp_get_interest',
name: 'Get Interest from Mailchimp Interest Category',
description:
'Retrieve details of a specific interest from an interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
interestId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest (e.g., "def456")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests/${params.interestId}`
),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_interest')
}
const data = await response.json()
return {
success: true,
output: {
interest: data,
interest_id: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the interest was successfully retrieved' },
output: {
type: 'object',
description: 'Interest data',
properties: {
interest: { type: 'json', description: 'Interest object' },
interest_id: { type: 'string', description: 'The unique ID of the interest' },
},
},
},
}
@@ -0,0 +1,110 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetInterestCategoriesParams {
apiKey: string
listId: string
count?: string
offset?: string
}
export interface MailchimpGetInterestCategoriesResponse {
success: boolean
output: {
categories: any[]
total_items: number
total_returned: number
}
}
export const mailchimpGetInterestCategoriesTool: ToolConfig<
MailchimpGetInterestCategoriesParams,
MailchimpGetInterestCategoriesResponse
> = {
id: 'mailchimp_get_interest_categories',
name: 'Get Interest Categories from Mailchimp Audience',
description: 'Retrieve a list of interest categories from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/interest-categories`)
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_interest_categories')
}
const data = await response.json()
const categories = data.categories || []
return {
success: true,
output: {
categories,
total_items: data.total_items || categories.length,
total_returned: categories.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the interest categories were successfully retrieved',
},
output: {
type: 'object',
description: 'Interest categories data',
properties: {
categories: { type: 'json', description: 'Array of interest category objects' },
total_items: { type: 'number', description: 'Total number of categories' },
total_returned: {
type: 'number',
description: 'Number of categories returned in this response',
},
},
},
},
}
@@ -0,0 +1,96 @@
import type { MailchimpInterestCategory } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetInterestCategoryParams {
apiKey: string
listId: string
interestCategoryId: string
}
export interface MailchimpGetInterestCategoryResponse {
success: boolean
output: {
category: MailchimpInterestCategory
interest_category_id: string
}
}
export const mailchimpGetInterestCategoryTool: ToolConfig<
MailchimpGetInterestCategoryParams,
MailchimpGetInterestCategoryResponse
> = {
id: 'mailchimp_get_interest_category',
name: 'Get Interest Category from Mailchimp Audience',
description: 'Retrieve details of a specific interest category from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}`
),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_interest_category')
}
const data = await response.json()
return {
success: true,
output: {
category: data,
interest_category_id: data.id,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the interest category was successfully retrieved',
},
output: {
type: 'object',
description: 'Interest category data',
properties: {
category: { type: 'json', description: 'Interest category object' },
interest_category_id: {
type: 'string',
description: 'The unique ID of the interest category',
},
},
},
},
}
+117
View File
@@ -0,0 +1,117 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetInterestsParams {
apiKey: string
listId: string
interestCategoryId: string
count?: string
offset?: string
}
export interface MailchimpGetInterestsResponse {
success: boolean
output: {
interests: any[]
total_items: number
total_returned: number
}
}
export const mailchimpGetInterestsTool: ToolConfig<
MailchimpGetInterestsParams,
MailchimpGetInterestsResponse
> = {
id: 'mailchimp_get_interests',
name: 'Get Interests from Mailchimp Interest Category',
description: 'Retrieve a list of interests from an interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests`
)
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_interests')
}
const data = await response.json()
const interests = data.interests || []
return {
success: true,
output: {
interests,
total_items: data.total_items || interests.length,
total_returned: interests.length,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the interests were successfully retrieved' },
output: {
type: 'object',
description: 'Interests data',
properties: {
interests: { type: 'json', description: 'Array of interest objects' },
total_items: { type: 'number', description: 'Total number of interests' },
total_returned: {
type: 'number',
description: 'Number of interests returned in this response',
},
},
},
},
}
@@ -0,0 +1,82 @@
import type { MailchimpLandingPage } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetLandingPageParams {
apiKey: string
pageId: string
}
export interface MailchimpGetLandingPageResponse {
success: boolean
output: {
landingPage: MailchimpLandingPage
page_id: string
}
}
export const mailchimpGetLandingPageTool: ToolConfig<
MailchimpGetLandingPageParams,
MailchimpGetLandingPageResponse
> = {
id: 'mailchimp_get_landing_page',
name: 'Get Landing Page from Mailchimp',
description: 'Retrieve details of a specific landing page from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
pageId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the landing page (e.g., "abc123def4")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_landing_page')
}
const data = await response.json()
return {
success: true,
output: {
landingPage: data,
page_id: data.id,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the landing page was successfully retrieved',
},
output: {
type: 'object',
description: 'Landing page data',
properties: {
landingPage: { type: 'json', description: 'Landing page object' },
page_id: { type: 'string', description: 'The unique ID of the landing page' },
},
},
},
}
@@ -0,0 +1,104 @@
import type { MailchimpLandingPage } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetLandingPagesParams {
apiKey: string
count?: string
offset?: string
}
export interface MailchimpGetLandingPagesResponse {
success: boolean
output: {
landingPages: MailchimpLandingPage[]
total_items: number
total_returned: number
}
}
export const mailchimpGetLandingPagesTool: ToolConfig<
MailchimpGetLandingPagesParams,
MailchimpGetLandingPagesResponse
> = {
id: 'mailchimp_get_landing_pages',
name: 'Get Landing Pages from Mailchimp',
description: 'Retrieve a list of landing pages from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/landing-pages')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_landing_pages')
}
const data = await response.json()
const landingPages = data.landing_pages || []
return {
success: true,
output: {
landingPages,
total_items: data.total_items || landingPages.length,
total_returned: landingPages.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the landing pages were successfully retrieved',
},
output: {
type: 'object',
description: 'Landing pages data',
properties: {
landingPages: { type: 'json', description: 'Array of landing page objects' },
total_items: { type: 'number', description: 'Total number of landing pages' },
total_returned: {
type: 'number',
description: 'Number of landing pages returned in this response',
},
},
},
},
}
+93
View File
@@ -0,0 +1,93 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetMemberParams {
apiKey: string
listId: string
subscriberEmail: string
}
export interface MailchimpGetMemberResponse {
success: boolean
output: {
member: MailchimpMember
subscriber_hash: string
}
}
export const mailchimpGetMemberTool: ToolConfig<
MailchimpGetMemberParams,
MailchimpGetMemberResponse
> = {
id: 'mailchimp_get_member',
name: 'Get Member from Mailchimp Audience',
description: 'Retrieve details of a specific member from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_member')
}
const data = await response.json()
return {
success: true,
output: {
member: data,
subscriber_hash: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the member was successfully retrieved' },
output: {
type: 'object',
description: 'Member data',
properties: {
member: { type: 'json', description: 'Member object' },
subscriber_hash: {
type: 'string',
description: 'The MD5 hash of the member email address',
},
},
},
},
}
@@ -0,0 +1,96 @@
import { buildMailchimpUrl, handleMailchimpError, type MailchimpTag } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetMemberTagsParams {
apiKey: string
listId: string
subscriberEmail: string
}
export interface MailchimpGetMemberTagsResponse {
success: boolean
output: {
tags: MailchimpTag[]
total_items: number
total_returned: number
}
}
export const mailchimpGetMemberTagsTool: ToolConfig<
MailchimpGetMemberTagsParams,
MailchimpGetMemberTagsResponse
> = {
id: 'mailchimp_get_member_tags',
name: 'Get Member Tags from Mailchimp',
description: 'Retrieve tags associated with a member in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/members/${params.subscriberEmail}/tags`
),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_member_tags')
}
const data = await response.json()
const tags = data.tags || []
return {
success: true,
output: {
tags,
total_items: data.total_items || tags.length,
total_returned: tags.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the member tags were successfully retrieved',
},
output: {
type: 'object',
description: 'Member tags data',
properties: {
tags: { type: 'json', description: 'Array of tag objects' },
total_items: { type: 'number', description: 'Total number of tags' },
total_returned: { type: 'number', description: 'Number of tags returned in this response' },
},
},
},
}
+119
View File
@@ -0,0 +1,119 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetMembersParams {
apiKey: string
listId: string
status?: string
count?: string
offset?: string
}
export interface MailchimpGetMembersResponse {
success: boolean
output: {
members: MailchimpMember[]
total_items: number
total_returned: number
}
}
export const mailchimpGetMembersTool: ToolConfig<
MailchimpGetMembersParams,
MailchimpGetMembersResponse
> = {
id: 'mailchimp_get_members',
name: 'Get Members from Mailchimp Audience',
description: 'Retrieve a list of members from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by status: "subscribed", "unsubscribed", "cleaned", or "pending"',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.status) queryParams.append('status', params.status)
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members`)
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_members')
}
const data = await response.json()
const members = data.members || []
return {
success: true,
output: {
members,
total_items: data.total_items || members.length,
total_returned: members.length,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the members were successfully retrieved' },
output: {
type: 'object',
description: 'Members data',
properties: {
members: { type: 'json', description: 'Array of member objects' },
total_items: { type: 'number', description: 'Total number of members' },
total_returned: {
type: 'number',
description: 'Number of members returned in this response',
},
},
},
},
}
@@ -0,0 +1,86 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetMergeFieldParams {
apiKey: string
listId: string
mergeId: string
}
export interface MailchimpGetMergeFieldResponse {
success: boolean
output: {
mergeField: any
merge_id: string
}
}
export const mailchimpGetMergeFieldTool: ToolConfig<
MailchimpGetMergeFieldParams,
MailchimpGetMergeFieldResponse
> = {
id: 'mailchimp_get_merge_field',
name: 'Get Merge Field from Mailchimp Audience',
description: 'Retrieve details of a specific merge field from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
mergeId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the merge field (e.g., "1" or "FNAME")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields/${params.mergeId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_merge_field')
}
const data = await response.json()
return {
success: true,
output: {
mergeField: data,
merge_id: data.merge_id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the merge field was successfully retrieved' },
output: {
type: 'object',
description: 'Merge field data',
properties: {
mergeField: { type: 'json', description: 'Merge field object' },
merge_id: { type: 'string', description: 'The unique ID of the merge field' },
},
},
},
}
@@ -0,0 +1,111 @@
import type { MailchimpMergeField } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetMergeFieldsParams {
apiKey: string
listId: string
count?: string
offset?: string
}
export interface MailchimpGetMergeFieldsResponse {
success: boolean
output: {
mergeFields: MailchimpMergeField[]
total_items: number
total_returned: number
}
}
export const mailchimpGetMergeFieldsTool: ToolConfig<
MailchimpGetMergeFieldsParams,
MailchimpGetMergeFieldsResponse
> = {
id: 'mailchimp_get_merge_fields',
name: 'Get Merge Fields from Mailchimp Audience',
description: 'Retrieve a list of merge fields from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields`)
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_merge_fields')
}
const data = await response.json()
const mergeFields = data.merge_fields || []
return {
success: true,
output: {
mergeFields,
total_items: data.total_items || mergeFields.length,
total_returned: mergeFields.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the merge fields were successfully retrieved',
},
output: {
type: 'object',
description: 'Merge fields data',
properties: {
mergeFields: { type: 'json', description: 'Array of merge field objects' },
total_items: { type: 'number', description: 'Total number of merge fields' },
total_returned: {
type: 'number',
description: 'Number of merge fields returned in this response',
},
},
},
},
}
+87
View File
@@ -0,0 +1,87 @@
import type { MailchimpSegment } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetSegmentParams {
apiKey: string
listId: string
segmentId: string
}
export interface MailchimpGetSegmentResponse {
success: boolean
output: {
segment: MailchimpSegment
segment_id: string
}
}
export const mailchimpGetSegmentTool: ToolConfig<
MailchimpGetSegmentParams,
MailchimpGetSegmentResponse
> = {
id: 'mailchimp_get_segment',
name: 'Get Segment from Mailchimp Audience',
description: 'Retrieve details of a specific segment from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the segment (e.g., "12345")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments/${params.segmentId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_segment')
}
const data = await response.json()
return {
success: true,
output: {
segment: data,
segment_id: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the segment was successfully retrieved' },
output: {
type: 'object',
description: 'Segment data',
properties: {
segment: { type: 'json', description: 'Segment object' },
segment_id: { type: 'string', description: 'The unique ID of the segment' },
},
},
},
}
@@ -0,0 +1,121 @@
import type { MailchimpMember } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetSegmentMembersParams {
apiKey: string
listId: string
segmentId: string
count?: string
offset?: string
}
export interface MailchimpGetSegmentMembersResponse {
success: boolean
output: {
members: MailchimpMember[]
total_items: number
total_returned: number
}
}
export const mailchimpGetSegmentMembersTool: ToolConfig<
MailchimpGetSegmentMembersParams,
MailchimpGetSegmentMembersResponse
> = {
id: 'mailchimp_get_segment_members',
name: 'Get Segment Members from Mailchimp',
description: 'Retrieve members of a specific segment from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the segment (e.g., "12345")',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/segments/${params.segmentId}/members`
)
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_segment_members')
}
const data = await response.json()
const members = data.members || []
return {
success: true,
output: {
members,
total_items: data.total_items || members.length,
total_returned: members.length,
},
}
},
outputs: {
success: {
type: 'boolean',
description: 'Whether the segment members were successfully retrieved',
},
output: {
type: 'object',
description: 'Segment members data',
properties: {
members: { type: 'json', description: 'Array of member objects' },
total_items: { type: 'number', description: 'Total number of members' },
total_returned: {
type: 'number',
description: 'Number of members returned in this response',
},
},
},
},
}
+107
View File
@@ -0,0 +1,107 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetSegmentsParams {
apiKey: string
listId: string
count?: string
offset?: string
}
export interface MailchimpGetSegmentsResponse {
success: boolean
output: {
segments: any[]
total_items: number
total_returned: number
}
}
export const mailchimpGetSegmentsTool: ToolConfig<
MailchimpGetSegmentsParams,
MailchimpGetSegmentsResponse
> = {
id: 'mailchimp_get_segments',
name: 'Get Segments from Mailchimp Audience',
description: 'Retrieve a list of segments from a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments`)
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_segments')
}
const data = await response.json()
const segments = data.segments || []
return {
success: true,
output: {
segments,
total_items: data.total_items || segments.length,
total_returned: segments.length,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the segments were successfully retrieved' },
output: {
type: 'object',
description: 'Segments data',
properties: {
segments: { type: 'json', description: 'Array of segment objects' },
total_items: { type: 'number', description: 'Total number of segments' },
total_returned: {
type: 'number',
description: 'Number of segments returned in this response',
},
},
},
},
}
+79
View File
@@ -0,0 +1,79 @@
import type { MailchimpTemplate } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetTemplateParams {
apiKey: string
templateId: string
}
export interface MailchimpGetTemplateResponse {
success: boolean
output: {
template: MailchimpTemplate
template_id: string
}
}
export const mailchimpGetTemplateTool: ToolConfig<
MailchimpGetTemplateParams,
MailchimpGetTemplateResponse
> = {
id: 'mailchimp_get_template',
name: 'Get Template from Mailchimp',
description: 'Retrieve details of a specific template from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
templateId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the template (e.g., "12345")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/templates/${params.templateId}`),
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_template')
}
const data = await response.json()
return {
success: true,
output: {
template: data,
template_id: data.id,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the template was successfully retrieved' },
output: {
type: 'object',
description: 'Template data',
properties: {
template: { type: 'json', description: 'Template object' },
template_id: { type: 'string', description: 'The unique ID of the template' },
},
},
},
}
+101
View File
@@ -0,0 +1,101 @@
import type { MailchimpTemplate } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpGetTemplatesParams {
apiKey: string
count?: string
offset?: string
}
export interface MailchimpGetTemplatesResponse {
success: boolean
output: {
templates: MailchimpTemplate[]
total_items: number
total_returned: number
}
}
export const mailchimpGetTemplatesTool: ToolConfig<
MailchimpGetTemplatesParams,
MailchimpGetTemplatesResponse
> = {
id: 'mailchimp_get_templates',
name: 'Get Templates from Mailchimp',
description: 'Retrieve a list of templates from Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
count: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to return (default: 10, max: 1000)',
},
offset: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Number of results to skip for pagination',
},
},
request: {
url: (params) => {
const queryParams = new URLSearchParams()
if (params.count) queryParams.append('count', params.count)
if (params.offset) queryParams.append('offset', params.offset)
const query = queryParams.toString()
const url = buildMailchimpUrl(params.apiKey, '/templates')
return query ? `${url}?${query}` : url
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'get_templates')
}
const data = await response.json()
const templates = data.templates || []
return {
success: true,
output: {
templates,
total_items: data.total_items || templates.length,
total_returned: templates.length,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the templates were successfully retrieved' },
output: {
type: 'object',
description: 'Templates data',
properties: {
templates: { type: 'json', description: 'Array of template objects' },
total_items: { type: 'number', description: 'Total number of templates' },
total_returned: {
type: 'number',
description: 'Number of templates returned in this response',
},
},
},
},
}
+88
View File
@@ -0,0 +1,88 @@
// Audience/List tools
export { mailchimpAddMemberTool } from './add_member'
export { mailchimpAddMemberTagsTool } from './add_member_tags'
export { mailchimpAddOrUpdateMemberTool } from './add_or_update_member'
export { mailchimpAddSegmentMemberTool } from './add_segment_member'
export { mailchimpAddSubscriberToAutomationTool } from './add_subscriber_to_automation'
export { mailchimpArchiveMemberTool } from './archive_member'
export { mailchimpCreateAudienceTool } from './create_audience'
export { mailchimpCreateBatchOperationTool } from './create_batch_operation'
export { mailchimpCreateCampaignTool } from './create_campaign'
export { mailchimpCreateInterestTool } from './create_interest'
export { mailchimpCreateInterestCategoryTool } from './create_interest_category'
export { mailchimpCreateLandingPageTool } from './create_landing_page'
export { mailchimpCreateMergeFieldTool } from './create_merge_field'
export { mailchimpCreateSegmentTool } from './create_segment'
export { mailchimpCreateTemplateTool } from './create_template'
export { mailchimpDeleteAudienceTool } from './delete_audience'
export { mailchimpDeleteBatchOperationTool } from './delete_batch_operation'
export { mailchimpDeleteCampaignTool } from './delete_campaign'
export { mailchimpDeleteInterestTool } from './delete_interest'
export { mailchimpDeleteInterestCategoryTool } from './delete_interest_category'
export { mailchimpDeleteLandingPageTool } from './delete_landing_page'
export { mailchimpDeleteMemberTool } from './delete_member'
export { mailchimpDeleteMergeFieldTool } from './delete_merge_field'
export { mailchimpDeleteSegmentTool } from './delete_segment'
export { mailchimpDeleteTemplateTool } from './delete_template'
export { mailchimpGetAudienceTool } from './get_audience'
export { mailchimpGetAudiencesTool } from './get_audiences'
export { mailchimpGetAutomationTool } from './get_automation'
// Automation tools
export { mailchimpGetAutomationsTool } from './get_automations'
export { mailchimpGetBatchOperationTool } from './get_batch_operation'
// Batch operation tools
export { mailchimpGetBatchOperationsTool } from './get_batch_operations'
export { mailchimpGetCampaignTool } from './get_campaign'
// Campaign content tools
export { mailchimpGetCampaignContentTool } from './get_campaign_content'
export { mailchimpGetCampaignReportTool } from './get_campaign_report'
// Report tools
export { mailchimpGetCampaignReportsTool } from './get_campaign_reports'
// Campaign tools
export { mailchimpGetCampaignsTool } from './get_campaigns'
export { mailchimpGetInterestTool } from './get_interest'
// Interest category tools
export { mailchimpGetInterestCategoriesTool } from './get_interest_categories'
export { mailchimpGetInterestCategoryTool } from './get_interest_category'
// Interest tools
export { mailchimpGetInterestsTool } from './get_interests'
export { mailchimpGetLandingPageTool } from './get_landing_page'
// Landing page tools
export { mailchimpGetLandingPagesTool } from './get_landing_pages'
export { mailchimpGetMemberTool } from './get_member'
// Tag tools
export { mailchimpGetMemberTagsTool } from './get_member_tags'
// Member tools
export { mailchimpGetMembersTool } from './get_members'
export { mailchimpGetMergeFieldTool } from './get_merge_field'
// Merge field tools
export { mailchimpGetMergeFieldsTool } from './get_merge_fields'
export { mailchimpGetSegmentTool } from './get_segment'
export { mailchimpGetSegmentMembersTool } from './get_segment_members'
// Segment tools
export { mailchimpGetSegmentsTool } from './get_segments'
export { mailchimpGetTemplateTool } from './get_template'
// Template tools
export { mailchimpGetTemplatesTool } from './get_templates'
export { mailchimpPauseAutomationTool } from './pause_automation'
export { mailchimpPublishLandingPageTool } from './publish_landing_page'
export { mailchimpRemoveMemberTagsTool } from './remove_member_tags'
export { mailchimpRemoveSegmentMemberTool } from './remove_segment_member'
export { mailchimpReplicateCampaignTool } from './replicate_campaign'
export { mailchimpScheduleCampaignTool } from './schedule_campaign'
export { mailchimpSendCampaignTool } from './send_campaign'
export { mailchimpSetCampaignContentTool } from './set_campaign_content'
export { mailchimpStartAutomationTool } from './start_automation'
export { mailchimpUnarchiveMemberTool } from './unarchive_member'
export { mailchimpUnpublishLandingPageTool } from './unpublish_landing_page'
export { mailchimpUnscheduleCampaignTool } from './unschedule_campaign'
export { mailchimpUpdateAudienceTool } from './update_audience'
export { mailchimpUpdateCampaignTool } from './update_campaign'
export { mailchimpUpdateInterestTool } from './update_interest'
export { mailchimpUpdateInterestCategoryTool } from './update_interest_category'
export { mailchimpUpdateLandingPageTool } from './update_landing_page'
export { mailchimpUpdateMemberTool } from './update_member'
export { mailchimpUpdateMergeFieldTool } from './update_merge_field'
export { mailchimpUpdateSegmentTool } from './update_segment'
export { mailchimpUpdateTemplateTool } from './update_template'
@@ -0,0 +1,77 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpPauseAutomationParams {
apiKey: string
workflowId: string
}
export interface MailchimpPauseAutomationResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpPauseAutomationTool: ToolConfig<
MailchimpPauseAutomationParams,
MailchimpPauseAutomationResponse
> = {
id: 'mailchimp_pause_automation',
name: 'Pause Automation in Mailchimp',
description: 'Pause all emails in a Mailchimp automation workflow',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
workflowId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the automation workflow (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/automations/${params.workflowId}/actions/pause-all-emails`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'pause_automation')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Pause confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,74 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpPublishLandingPageParams {
apiKey: string
pageId: string
}
export interface MailchimpPublishLandingPageResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpPublishLandingPageTool: ToolConfig<
MailchimpPublishLandingPageParams,
MailchimpPublishLandingPageResponse
> = {
id: 'mailchimp_publish_landing_page',
name: 'Publish Landing Page in Mailchimp',
description: 'Publish a landing page in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
pageId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the landing page (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}/actions/publish`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'publish_landing_page')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Publish confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,105 @@
import { createLogger } from '@sim/logger'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpRemoveMemberTags')
export interface MailchimpRemoveMemberTagsParams {
apiKey: string
listId: string
subscriberEmail: string
tags: string
}
export interface MailchimpRemoveMemberTagsResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpRemoveMemberTagsTool: ToolConfig<
MailchimpRemoveMemberTagsParams,
MailchimpRemoveMemberTagsResponse
> = {
id: 'mailchimp_remove_member_tags',
name: 'Remove Tags from Member in Mailchimp',
description: 'Remove tags from a member in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
tags: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'JSON array of tag objects with inactive status (e.g., [{"name": "VIP", "status": "inactive"}])',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/members/${params.subscriberEmail}/tags`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
let tags = []
try {
tags = JSON.parse(params.tags)
} catch (error) {
logger.warn('Failed to parse tags', { error })
}
return { tags }
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'remove_member_tags')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Tag removal confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,91 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpRemoveSegmentMemberParams {
apiKey: string
listId: string
segmentId: string
subscriberEmail: string
}
export interface MailchimpRemoveSegmentMemberResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpRemoveSegmentMemberTool: ToolConfig<
MailchimpRemoveSegmentMemberParams,
MailchimpRemoveSegmentMemberResponse
> = {
id: 'mailchimp_remove_segment_member',
name: 'Remove Member from Segment in Mailchimp',
description: 'Remove a member from a specific segment in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the segment (e.g., "12345")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/segments/${params.segmentId}/members/${params.subscriberEmail}`
),
method: 'DELETE',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'remove_segment_member')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Removal confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,82 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpReplicateCampaignParams {
apiKey: string
campaignId: string
}
export interface MailchimpReplicateCampaignResponse {
success: boolean
output: {
campaign: unknown
campaign_id: string
success: boolean
}
}
export const mailchimpReplicateCampaignTool: ToolConfig<
MailchimpReplicateCampaignParams,
MailchimpReplicateCampaignResponse
> = {
id: 'mailchimp_replicate_campaign',
name: 'Replicate Campaign in Mailchimp',
description: 'Create a copy of an existing Mailchimp campaign',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign to replicate (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/replicate`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'replicate_campaign')
}
const data = await response.json()
return {
success: true,
output: {
campaign: data,
campaign_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Replicated campaign data',
properties: {
campaign: { type: 'object', description: 'Replicated campaign object' },
campaign_id: { type: 'string', description: 'Campaign ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,71 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpScheduleCampaignParams {
apiKey: string
campaignId: string
scheduleTime: string
}
export interface MailchimpScheduleCampaignResponse {
success: boolean
}
export const mailchimpScheduleCampaignTool: ToolConfig<
MailchimpScheduleCampaignParams,
MailchimpScheduleCampaignResponse
> = {
id: 'mailchimp_schedule_campaign',
name: 'Schedule Campaign in Mailchimp',
description: 'Schedule a Mailchimp campaign to be sent at a specific time',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign to schedule (e.g., "abc123def4")',
},
scheduleTime: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Schedule time in ISO 8601 format (e.g., "2024-12-25T10:00:00Z")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/schedule`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
schedule_time: params.scheduleTime,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'schedule_campaign')
}
return {
success: true,
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the campaign was successfully scheduled' },
},
}
+74
View File
@@ -0,0 +1,74 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpSendCampaignParams {
apiKey: string
campaignId: string
}
export interface MailchimpSendCampaignResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpSendCampaignTool: ToolConfig<
MailchimpSendCampaignParams,
MailchimpSendCampaignResponse
> = {
id: 'mailchimp_send_campaign',
name: 'Send Campaign in Mailchimp',
description: 'Send a Mailchimp campaign',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign to send (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/send`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'send_campaign')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Send confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,112 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaignContent,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpSetCampaignContentParams {
apiKey: string
campaignId: string
html?: string
plainText?: string
templateId?: string
}
export interface MailchimpSetCampaignContentResponse {
success: boolean
output: {
content: MailchimpCampaignContent
success: boolean
}
}
export const mailchimpSetCampaignContentTool: ToolConfig<
MailchimpSetCampaignContentParams,
MailchimpSetCampaignContentResponse
> = {
id: 'mailchimp_set_campaign_content',
name: 'Set Campaign Content in Mailchimp',
description: 'Set the content for a Mailchimp campaign',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign (e.g., "abc123def4")',
},
html: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The HTML content for the campaign',
},
plainText: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The plain-text content for the campaign',
},
templateId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The unique ID of the template to use (e.g., "12345")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/content`),
method: 'PUT',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.html) body.html = params.html
if (params.plainText) body.plain_text = params.plainText
if (params.templateId) body.template = { id: params.templateId }
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'set_campaign_content')
}
const data = await response.json()
return {
success: true,
output: {
content: data,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Campaign content data',
properties: {
content: { type: 'object', description: 'Campaign content object' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,77 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpStartAutomationParams {
apiKey: string
workflowId: string
}
export interface MailchimpStartAutomationResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpStartAutomationTool: ToolConfig<
MailchimpStartAutomationParams,
MailchimpStartAutomationResponse
> = {
id: 'mailchimp_start_automation',
name: 'Start Automation in Mailchimp',
description: 'Start all emails in a Mailchimp automation workflow',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
workflowId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the automation workflow (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/automations/${params.workflowId}/actions/start-all-emails`
),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'start_automation')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Start confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+419
View File
@@ -0,0 +1,419 @@
import { createLogger } from '@sim/logger'
const logger = createLogger('Mailchimp')
// Base params
interface MailchimpBaseParams {
apiKey: string // API key with server prefix (e.g., "key-us19")
}
interface MailchimpPaginationParams {
count?: string
offset?: string
}
interface MailchimpPagingInfo {
total_items: number
}
interface MailchimpResponse<T> {
success: boolean
output: {
data?: T
paging?: MailchimpPagingInfo
metadata?: {
[key: string]: unknown
}
success: boolean
}
}
// Member/Subscriber
export interface MailchimpMember {
id: string
email_address: string
unique_email_id?: string
status: 'subscribed' | 'unsubscribed' | 'cleaned' | 'pending'
merge_fields?: Record<string, unknown>
interests?: Record<string, boolean>
stats?: {
avg_open_rate?: number
avg_click_rate?: number
}
ip_signup?: string
timestamp_signup?: string
ip_opt?: string
timestamp_opt?: string
member_rating?: number
last_changed?: string
language?: string
vip?: boolean
email_client?: string
location?: {
latitude?: number
longitude?: number
gmtoff?: number
dstoff?: number
country_code?: string
timezone?: string
}
tags?: Array<{ id: number; name: string }>
[key: string]: unknown
}
// Audience/List
export interface MailchimpAudience {
id: string
name: string
contact: {
company: string
address1: string
address2?: string
city: string
state: string
zip: string
country: string
phone?: string
}
permission_reminder: string
campaign_defaults: {
from_name: string
from_email: string
subject: string
language: string
}
email_type_option: boolean
stats?: {
member_count?: number
unsubscribe_count?: number
cleaned_count?: number
member_count_since_send?: number
unsubscribe_count_since_send?: number
cleaned_count_since_send?: number
campaign_count?: number
campaign_last_sent?: string
merge_field_count?: number
avg_sub_rate?: number
avg_unsub_rate?: number
target_sub_rate?: number
open_rate?: number
click_rate?: number
last_sub_date?: string
last_unsub_date?: string
}
date_created?: string
list_rating?: number
subscribe_url_short?: string
subscribe_url_long?: string
visibility?: string
[key: string]: unknown
}
// Campaign
export interface MailchimpCampaign {
id: string
type: 'regular' | 'plaintext' | 'absplit' | 'rss' | 'variate'
create_time?: string
archive_url?: string
long_archive_url?: string
status: 'save' | 'paused' | 'schedule' | 'sending' | 'sent'
emails_sent?: number
send_time?: string
content_type?: string
recipients?: {
list_id: string
list_name?: string
segment_text?: string
recipient_count?: number
}
settings?: {
subject_line?: string
preview_text?: string
title?: string
from_name?: string
reply_to?: string
use_conversation?: boolean
to_name?: string
folder_id?: string
authenticate?: boolean
auto_footer?: boolean
inline_css?: boolean
auto_tweet?: boolean
fb_comments?: boolean
timewarp?: boolean
template_id?: number
drag_and_drop?: boolean
}
tracking?: {
opens?: boolean
html_clicks?: boolean
text_clicks?: boolean
goal_tracking?: boolean
ecomm360?: boolean
google_analytics?: string
clicktale?: string
}
[key: string]: unknown
}
// Campaign Content
export interface MailchimpCampaignContent {
html?: string
plain_text?: string
archive_html?: string
[key: string]: unknown
}
// Campaign Report
export interface MailchimpCampaignReport {
id: string
campaign_title?: string
type?: string
emails_sent?: number
abuse_reports?: number
unsubscribed?: number
send_time?: string
bounces?: {
hard_bounces?: number
soft_bounces?: number
syntax_errors?: number
}
forwards?: {
forwards_count?: number
forwards_opens?: number
}
opens?: {
opens_total?: number
unique_opens?: number
open_rate?: number
last_open?: string
}
clicks?: {
clicks_total?: number
unique_clicks?: number
unique_subscriber_clicks?: number
click_rate?: number
last_click?: string
}
list_stats?: {
sub_rate?: number
unsub_rate?: number
open_rate?: number
click_rate?: number
}
[key: string]: unknown
}
// Automation
export interface MailchimpAutomation {
id: string
create_time?: string
start_time?: string
status: 'save' | 'paused' | 'sending'
emails_sent?: number
recipients?: {
list_id: string
list_name?: string
segment_opts?: unknown
}
settings?: {
title?: string
from_name?: string
reply_to?: string
use_conversation?: boolean
to_name?: string
authenticate?: boolean
auto_footer?: boolean
inline_css?: boolean
}
tracking?: {
opens?: boolean
html_clicks?: boolean
text_clicks?: boolean
goal_tracking?: boolean
ecomm360?: boolean
google_analytics?: string
clicktale?: string
}
[key: string]: unknown
}
// Segment
export interface MailchimpSegment {
id: number
name: string
member_count?: number
type: 'saved' | 'static' | 'fuzzy'
created_at?: string
updated_at?: string
options?: {
match?: 'any' | 'all'
conditions?: Array<{
condition_type?: string
field?: string
op?: string
value?: unknown
}>
}
list_id?: string
[key: string]: unknown
}
// Template
export interface MailchimpTemplate {
id: number
type: string
name: string
drag_and_drop?: boolean
responsive?: boolean
category?: string
date_created?: string
date_edited?: string
created_by?: string
edited_by?: string
active?: boolean
folder_id?: string
thumbnail?: string
share_url?: string
[key: string]: unknown
}
// Landing Page
export interface MailchimpLandingPage {
id: string
name: string
title?: string
description?: string
template_id?: number
status: 'draft' | 'published' | 'unpublished'
list_id?: string
store_id?: string
web_id?: number
created_at?: string
published_at?: string
unpublished_at?: string
updated_at?: string
url?: string
tracking?: {
opens?: boolean
html_clicks?: boolean
text_clicks?: boolean
goal_tracking?: boolean
ecomm360?: boolean
google_analytics?: string
clicktale?: string
}
[key: string]: unknown
}
// Interest Category
export interface MailchimpInterestCategory {
list_id?: string
id: string
title: string
display_order?: number
type: 'checkboxes' | 'dropdown' | 'radio' | 'hidden'
[key: string]: unknown
}
// Interest
export interface MailchimpInterest {
category_id?: string
list_id?: string
id: string
name: string
subscriber_count?: string
display_order?: number
[key: string]: unknown
}
// Merge Field
export interface MailchimpMergeField {
merge_id?: number
tag: string
name: string
type:
| 'text'
| 'number'
| 'address'
| 'phone'
| 'date'
| 'url'
| 'imageurl'
| 'radio'
| 'dropdown'
| 'birthday'
| 'zip'
required?: boolean
default_value?: string
public?: boolean
display_order?: number
options?: {
default_country?: number
phone_format?: string
date_format?: string
choices?: string[]
size?: number
}
help_text?: string
list_id?: string
[key: string]: unknown
}
// Batch Operation
export interface MailchimpBatchOperation {
id: string
status: 'pending' | 'preprocessing' | 'started' | 'finalizing' | 'finished'
total_operations?: number
finished_operations?: number
errored_operations?: number
submitted_at?: string
completed_at?: string
response_body_url?: string
[key: string]: unknown
}
// Tag
export interface MailchimpTag {
id: number
name: string
[key: string]: unknown
}
// Error Response
interface MailchimpErrorResponse {
type?: string
title?: string
status?: number
detail?: string
instance?: string
errors?: Array<{
field?: string
message?: string
}>
}
// Helper function to extract server prefix from API key
export function extractServerPrefix(apiKey: string): string {
const parts = apiKey.split('-')
if (parts.length < 2) {
throw new Error('Invalid Mailchimp API key format. Expected format: key-dc (e.g., abc123-us19)')
}
return parts[parts.length - 1]
}
// Helper function to build Mailchimp API URLs
export function buildMailchimpUrl(apiKey: string, path: string): string {
const serverPrefix = extractServerPrefix(apiKey)
return `https://${serverPrefix}.api.mailchimp.com/3.0${path}`
}
// Helper function for consistent error handling
export function handleMailchimpError(data: unknown, status: number, operation: string): never {
logger.error(`Mailchimp API request failed for ${operation}`, { data, status })
const errorData = data as Record<string, unknown>
const errorMessage =
errorData.detail || errorData.title || errorData.error || errorData.message || 'Unknown error'
throw new Error(`Mailchimp ${operation} failed: ${errorMessage}`)
}
@@ -0,0 +1,112 @@
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUnarchiveMemberParams {
apiKey: string
listId: string
subscriberEmail: string
emailAddress: string
status: string
}
export interface MailchimpUnarchiveMemberResponse {
success: boolean
output: {
member: MailchimpMember
subscriber_hash: string
success: boolean
}
}
export const mailchimpUnarchiveMemberTool: ToolConfig<
MailchimpUnarchiveMemberParams,
MailchimpUnarchiveMemberResponse
> = {
id: 'mailchimp_unarchive_member',
name: 'Unarchive Member in Mailchimp Audience',
description: 'Restore an archived member to a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
emailAddress: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address (e.g., "user@example.com")',
},
status: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Subscriber status: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional"',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
method: 'PUT',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => ({
email_address: params.emailAddress,
status: params.status,
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'unarchive_member')
}
const data = await response.json()
return {
success: true,
output: {
member: data,
subscriber_hash: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Unarchived member data',
properties: {
member: { type: 'object', description: 'Unarchived member object' },
subscriber_hash: { type: 'string', description: 'Subscriber hash' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,74 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUnpublishLandingPageParams {
apiKey: string
pageId: string
}
export interface MailchimpUnpublishLandingPageResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpUnpublishLandingPageTool: ToolConfig<
MailchimpUnpublishLandingPageParams,
MailchimpUnpublishLandingPageResponse
> = {
id: 'mailchimp_unpublish_landing_page',
name: 'Unpublish Landing Page in Mailchimp',
description: 'Unpublish a landing page in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
pageId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the landing page (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}/actions/unpublish`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'unpublish_landing_page')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Unpublish confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,74 @@
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUnscheduleCampaignParams {
apiKey: string
campaignId: string
}
export interface MailchimpUnscheduleCampaignResponse {
success: boolean
output: {
success: boolean
}
}
export const mailchimpUnscheduleCampaignTool: ToolConfig<
MailchimpUnscheduleCampaignParams,
MailchimpUnscheduleCampaignResponse
> = {
id: 'mailchimp_unschedule_campaign',
name: 'Unschedule Campaign in Mailchimp',
description: 'Unschedule a previously scheduled Mailchimp campaign',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign to unschedule (e.g., "abc123def4")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/unschedule`),
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'unschedule_campaign')
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Unschedule confirmation',
properties: {
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+133
View File
@@ -0,0 +1,133 @@
import { createLogger } from '@sim/logger'
import type { MailchimpAudience } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpUpdateAudience')
export interface MailchimpUpdateAudienceParams {
apiKey: string
listId: string
audienceName?: string
permissionReminder?: string
campaignDefaults?: string
emailTypeOption?: string
}
export interface MailchimpUpdateAudienceResponse {
success: boolean
output: {
list: MailchimpAudience
list_id: string
success: boolean
}
}
export const mailchimpUpdateAudienceTool: ToolConfig<
MailchimpUpdateAudienceParams,
MailchimpUpdateAudienceResponse
> = {
id: 'mailchimp_update_audience',
name: 'Update Audience in Mailchimp',
description: 'Update an existing audience (list) in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
audienceName: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the audience/list (e.g., "Newsletter Subscribers")',
},
permissionReminder: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Permission reminder text shown to subscribers (e.g., "You signed up for updates on our website")',
},
campaignDefaults: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'JSON object of default campaign settings (e.g., {"from_name": "Acme", "from_email": "news@acme.com"})',
},
emailTypeOption: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Support multiple email formats: "true" or "false"',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.audienceName) body.name = params.audienceName
if (params.permissionReminder) body.permission_reminder = params.permissionReminder
if (params.emailTypeOption !== undefined)
body.email_type_option = params.emailTypeOption === 'true'
if (params.campaignDefaults) {
try {
body.campaign_defaults = JSON.parse(params.campaignDefaults)
} catch (error) {
logger.warn('Failed to parse campaign defaults', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_audience')
}
const data = await response.json()
return {
success: true,
output: {
list: data,
list_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated audience data',
properties: {
list: { type: 'object', description: 'Updated audience/list object' },
list_id: { type: 'string', description: 'List ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+124
View File
@@ -0,0 +1,124 @@
import { createLogger } from '@sim/logger'
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpCampaign,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpUpdateCampaign')
export interface MailchimpUpdateCampaignParams {
apiKey: string
campaignId: string
campaignSettings?: string
recipients?: string
}
export interface MailchimpUpdateCampaignResponse {
success: boolean
output: {
campaign: MailchimpCampaign
campaign_id: string
success: boolean
}
}
export const mailchimpUpdateCampaignTool: ToolConfig<
MailchimpUpdateCampaignParams,
MailchimpUpdateCampaignResponse
> = {
id: 'mailchimp_update_campaign',
name: 'Update Campaign in Mailchimp',
description: 'Update an existing campaign in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
campaignId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the campaign (e.g., "abc123def4")',
},
campaignSettings: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'JSON object of campaign settings (e.g., {"subject_line": "Newsletter", "from_name": "Acme"})',
},
recipients: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of recipients (e.g., {"list_id": "abc123"})',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.campaignSettings) {
try {
body.settings = JSON.parse(params.campaignSettings)
} catch (error) {
logger.warn('Failed to parse campaign settings', { error })
}
}
if (params.recipients) {
try {
body.recipients = JSON.parse(params.recipients)
} catch (error) {
logger.warn('Failed to parse recipients', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_campaign')
}
const data = await response.json()
return {
success: true,
output: {
campaign: data,
campaign_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated campaign data',
properties: {
campaign: { type: 'object', description: 'Updated campaign object' },
campaign_id: { type: 'string', description: 'Campaign ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+114
View File
@@ -0,0 +1,114 @@
import type { MailchimpInterest } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUpdateInterestParams {
apiKey: string
listId: string
interestCategoryId: string
interestId: string
interestName?: string
}
export interface MailchimpUpdateInterestResponse {
success: boolean
output: {
interest: MailchimpInterest
interest_id: string
success: boolean
}
}
export const mailchimpUpdateInterestTool: ToolConfig<
MailchimpUpdateInterestParams,
MailchimpUpdateInterestResponse
> = {
id: 'mailchimp_update_interest',
name: 'Update Interest in Mailchimp Interest Category',
description: 'Update an existing interest in an interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
interestId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest (e.g., "def456")',
},
interestName: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the interest (e.g., "Weekly Updates")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests/${params.interestId}`
),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.interestName) body.name = params.interestName
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_interest')
}
const data = await response.json()
return {
success: true,
output: {
interest: data,
interest_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated interest data',
properties: {
interest: { type: 'object', description: 'Updated interest object' },
interest_id: { type: 'string', description: 'Interest ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,107 @@
import type { MailchimpInterestCategory } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUpdateInterestCategoryParams {
apiKey: string
listId: string
interestCategoryId: string
interestCategoryTitle?: string
}
export interface MailchimpUpdateInterestCategoryResponse {
success: boolean
output: {
category: MailchimpInterestCategory
interest_category_id: string
success: boolean
}
}
export const mailchimpUpdateInterestCategoryTool: ToolConfig<
MailchimpUpdateInterestCategoryParams,
MailchimpUpdateInterestCategoryResponse
> = {
id: 'mailchimp_update_interest_category',
name: 'Update Interest Category in Mailchimp Audience',
description: 'Update an existing interest category in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
interestCategoryId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the interest category (e.g., "xyz789")',
},
interestCategoryTitle: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The title of the interest category (e.g., "Email Preferences")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(
params.apiKey,
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}`
),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.interestCategoryTitle) body.title = params.interestCategoryTitle
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_interest_category')
}
const data = await response.json()
return {
success: true,
output: {
category: data,
interest_category_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated interest category data',
properties: {
category: { type: 'object', description: 'Updated interest category object' },
interest_category_id: { type: 'string', description: 'Interest category ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,96 @@
import type { MailchimpLandingPage } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUpdateLandingPageParams {
apiKey: string
pageId: string
landingPageTitle?: string
}
export interface MailchimpUpdateLandingPageResponse {
success: boolean
output: {
landingPage: MailchimpLandingPage
page_id: string
success: boolean
}
}
export const mailchimpUpdateLandingPageTool: ToolConfig<
MailchimpUpdateLandingPageParams,
MailchimpUpdateLandingPageResponse
> = {
id: 'mailchimp_update_landing_page',
name: 'Update Landing Page in Mailchimp',
description: 'Update an existing landing page in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
pageId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the landing page (e.g., "abc123def4")',
},
landingPageTitle: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The title of the landing page (e.g., "Join Our Newsletter")',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.landingPageTitle) body.title = params.landingPageTitle
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_landing_page')
}
const data = await response.json()
return {
success: true,
output: {
landingPage: data,
page_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated landing page data',
properties: {
landingPage: { type: 'object', description: 'Updated landing page object' },
page_id: { type: 'string', description: 'Landing page ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+149
View File
@@ -0,0 +1,149 @@
import { createLogger } from '@sim/logger'
import {
buildMailchimpUrl,
handleMailchimpError,
type MailchimpMember,
} from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpUpdateMember')
export interface MailchimpUpdateMemberParams {
apiKey: string
listId: string
subscriberEmail: string
emailAddress?: string
status?: string
mergeFields?: string
interests?: string
}
export interface MailchimpUpdateMemberResponse {
success: boolean
output: {
member: MailchimpMember
subscriber_hash: string
success: boolean
}
}
export const mailchimpUpdateMemberTool: ToolConfig<
MailchimpUpdateMemberParams,
MailchimpUpdateMemberResponse
> = {
id: 'mailchimp_update_member',
name: 'Update Member in Mailchimp Audience',
description: 'Update an existing member in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
subscriberEmail: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Member email address or MD5 hash of the lowercase email',
},
emailAddress: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New member email address (e.g., "user@example.com")',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Subscriber status: "subscribed", "unsubscribed", "cleaned", "pending", or "transactional"',
},
mergeFields: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of merge fields (e.g., {"FNAME": "John", "LNAME": "Doe"})',
},
interests: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of interest IDs and their boolean values (e.g., {"abc123": true})',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.emailAddress) body.email_address = params.emailAddress
if (params.status) body.status = params.status
if (params.mergeFields) {
try {
body.merge_fields = JSON.parse(params.mergeFields)
} catch (error) {
logger.warn('Failed to parse merge fields', { error })
}
}
if (params.interests) {
try {
body.interests = JSON.parse(params.interests)
} catch (error) {
logger.warn('Failed to parse interests', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_member')
}
const data = await response.json()
return {
success: true,
output: {
member: data,
subscriber_hash: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated member data',
properties: {
member: { type: 'object', description: 'Updated member object' },
subscriber_hash: { type: 'string', description: 'Subscriber hash' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
@@ -0,0 +1,104 @@
import type { MailchimpMergeField } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUpdateMergeFieldParams {
apiKey: string
listId: string
mergeId: string
mergeName?: string
}
export interface MailchimpUpdateMergeFieldResponse {
success: boolean
output: {
mergeField: MailchimpMergeField
merge_id: string
success: boolean
}
}
export const mailchimpUpdateMergeFieldTool: ToolConfig<
MailchimpUpdateMergeFieldParams,
MailchimpUpdateMergeFieldResponse
> = {
id: 'mailchimp_update_merge_field',
name: 'Update Merge Field in Mailchimp Audience',
description: 'Update an existing merge field in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
mergeId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the merge field (e.g., "1" or "FNAME")',
},
mergeName: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the merge field (e.g., "First Name")',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields/${params.mergeId}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.mergeName) body.name = params.mergeName
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_merge_field')
}
const data = await response.json()
return {
success: true,
output: {
mergeField: data,
merge_id: data.merge_id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated merge field data',
properties: {
mergeField: { type: 'object', description: 'Updated merge field object' },
merge_id: { type: 'string', description: 'Merge field ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+123
View File
@@ -0,0 +1,123 @@
import { createLogger } from '@sim/logger'
import type { MailchimpSegment } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('MailchimpUpdateSegment')
export interface MailchimpUpdateSegmentParams {
apiKey: string
listId: string
segmentId: string
segmentName?: string
segmentOptions?: string
}
export interface MailchimpUpdateSegmentResponse {
success: boolean
output: {
segment: MailchimpSegment
segment_id: string
success: boolean
}
}
export const mailchimpUpdateSegmentTool: ToolConfig<
MailchimpUpdateSegmentParams,
MailchimpUpdateSegmentResponse
> = {
id: 'mailchimp_update_segment',
name: 'Update Segment in Mailchimp Audience',
description: 'Update an existing segment in a Mailchimp audience',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
listId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the audience/list (e.g., "abc123def4")',
},
segmentId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the segment (e.g., "12345")',
},
segmentName: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the segment (e.g., "VIP Customers")',
},
segmentOptions: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'JSON object of segment options (e.g., {"match": "all", "conditions": [...]})',
},
},
request: {
url: (params) =>
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments/${params.segmentId}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.segmentName) body.name = params.segmentName
if (params.segmentOptions) {
try {
const options = JSON.parse(params.segmentOptions)
body.options = options
} catch (error) {
logger.warn('Failed to parse segment options', { error })
}
}
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_segment')
}
const data = await response.json()
return {
success: true,
output: {
segment: data,
segment_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated segment data',
properties: {
segment: { type: 'object', description: 'Updated segment object' },
segment_id: { type: 'string', description: 'Segment ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}
+104
View File
@@ -0,0 +1,104 @@
import type { MailchimpTemplate } from '@/tools/mailchimp/types'
import { buildMailchimpUrl, handleMailchimpError } from '@/tools/mailchimp/types'
import type { ToolConfig } from '@/tools/types'
export interface MailchimpUpdateTemplateParams {
apiKey: string
templateId: string
templateName?: string
templateHtml?: string
}
export interface MailchimpUpdateTemplateResponse {
success: boolean
output: {
template: MailchimpTemplate
template_id: string
success: boolean
}
}
export const mailchimpUpdateTemplateTool: ToolConfig<
MailchimpUpdateTemplateParams,
MailchimpUpdateTemplateResponse
> = {
id: 'mailchimp_update_template',
name: 'Update Template in Mailchimp',
description: 'Update an existing template in Mailchimp',
version: '1.0.0',
params: {
apiKey: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'Mailchimp API key with server prefix',
},
templateId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The unique ID for the template (e.g., "12345")',
},
templateName: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The name of the template (e.g., "Monthly Newsletter")',
},
templateHtml: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'The HTML content for the template',
},
},
request: {
url: (params) => buildMailchimpUrl(params.apiKey, `/templates/${params.templateId}`),
method: 'PATCH',
headers: (params) => ({
Authorization: `Bearer ${params.apiKey}`,
'Content-Type': 'application/json',
}),
body: (params) => {
const body: Record<string, unknown> = {}
if (params.templateName) body.name = params.templateName
if (params.templateHtml) body.html = params.templateHtml
return body
},
},
transformResponse: async (response: Response) => {
if (!response.ok) {
const data = await response.json()
handleMailchimpError(data, response.status, 'update_template')
}
const data = await response.json()
return {
success: true,
output: {
template: data,
template_id: data.id,
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Operation success status' },
output: {
type: 'object',
description: 'Updated template data',
properties: {
template: { type: 'object', description: 'Updated template object' },
template_id: { type: 'string', description: 'Template ID' },
success: { type: 'boolean', description: 'Operation success' },
},
},
},
}