92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
/**
|
|
* ActiveCampaign Automation Tools
|
|
*/
|
|
|
|
import { ActiveCampaignClient } from '../client/index.js';
|
|
import { Automation } from '../types/index.js';
|
|
|
|
export function createAutomationTools(client: ActiveCampaignClient) {
|
|
return {
|
|
ac_list_automations: {
|
|
description: 'List all automations',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
status: { type: 'number', description: 'Status filter (0=inactive, 1=active)' },
|
|
limit: { type: 'number', description: 'Max results', default: 20 },
|
|
},
|
|
},
|
|
handler: async (params: any) => {
|
|
const automations = await client.paginate<Automation>('/automations', params, params.limit || 20);
|
|
return { automations, count: automations.length };
|
|
},
|
|
},
|
|
|
|
ac_get_automation: {
|
|
description: 'Get an automation by ID',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', description: 'Automation ID' },
|
|
},
|
|
required: ['id'],
|
|
},
|
|
handler: async (params: { id: string }) => {
|
|
return client.get<{ automation: Automation }>(`/automations/${params.id}`);
|
|
},
|
|
},
|
|
|
|
ac_create_automation: {
|
|
description: 'Create a new automation',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
name: { type: 'string', description: 'Automation name' },
|
|
status: { type: 'number', description: 'Status (0=inactive, 1=active)', default: 0 },
|
|
},
|
|
required: ['name'],
|
|
},
|
|
handler: async (params: Automation) => {
|
|
return client.post<{ automation: Automation }>('/automations', { automation: params });
|
|
},
|
|
},
|
|
|
|
ac_update_automation: {
|
|
description: 'Update an automation',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string', description: 'Automation ID' },
|
|
name: { type: 'string', description: 'Automation name' },
|
|
status: { type: 'number', description: 'Status (0=inactive, 1=active)' },
|
|
},
|
|
required: ['id'],
|
|
},
|
|
handler: async (params: Automation & { id: string }) => {
|
|
const { id, ...automation } = params;
|
|
return client.put<{ automation: Automation }>(`/automations/${id}`, { automation });
|
|
},
|
|
},
|
|
|
|
ac_add_contact_to_automation: {
|
|
description: 'Add a contact to an automation',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
contactId: { type: 'string', description: 'Contact ID' },
|
|
automationId: { type: 'string', description: 'Automation ID' },
|
|
},
|
|
required: ['contactId', 'automationId'],
|
|
},
|
|
handler: async (params: { contactId: string; automationId: string }) => {
|
|
return client.post('/contactAutomations', {
|
|
contactAutomation: {
|
|
contact: params.contactId,
|
|
automation: params.automationId,
|
|
},
|
|
});
|
|
},
|
|
},
|
|
};
|
|
}
|