actions/list-all-contacts/list-all-contacts.mjs
import activecampaign from "../../activecampaign.app.mjs"; export default { key: "activecampaign-list-all-contacts", name: "List All Contacts", description: "Retrieve all existing contacts. See the docs [here](https://developers.activecampaign.com/reference/list-all-contacts).", version: "0.2.1", annotations: { destructiveHint: false, openWorldHint: true, readOnlyHint: true, }, type: "action", props: { activecampaign, ids: { type: "string", label: "IDs", description: "Filter contacts by ID. Can be repeated for multiple IDs. Example: ids[]=1&ids[]=2&ids[]=42", optional: true, }, email: { type: "string", label: "Email", description: "Email address of the contact you want to get", optional: true, }, emailLike: { type: "string", label: "Email Like", description: "Filter contacts that contain the given value in the email address", optional: true, }, exclude: { type: "string", label: "Excluded Contact ID", description: "Exclude from the response the contact with the given ID", optional: true, }, formid: { type: "string", label: "Form ID", description: "Filter contacts associated with the given form", optional: true, }, idGreater: { type: "string", label: "Greater Contact ID", description: "Only include contacts with an ID greater than the given ID", optional: true, }, idLess: { type: "string", label: "Less Contact ID", description: "Only include contacts with an ID less than the given ID", optional: true, }, listid: { type: "string", label: "List ID", description: "Filter contacts associated with the given list", optional: true, }, organization: { type: "string", label: "Organization", description: "(Deprecated) Please use Account-Contact end points. Filter contacts associated with the given organization ID", optional: true, }, search: { type: "string", label: "Search", description: "Filter contacts that match the given value in the contact names, organization, phone or email", optional: true, }, segmentid: { type: "string", label: "Segment ID", description: "Return only contacts that match a list segment (this param initially returns segment information, when it is run a second time it will return contacts that match the segment)", optional: true, }, seriesid: { type: "string", label: "Series ID", description: "Filter contacts associated with the given automation", optional: true, }, status: { type: "string", label: "Status", description: "See [available values](https://developers.activecampaign.com/reference#section-contact-parameters-available-values)", optional: true, }, tagid: { type: "string", label: "Tag ID", description: "Filter contacts associated with the given tag", optional: true, }, createdBefore: { type: "string", label: "Created Before", description: "Filter contacts that were created prior to this date", optional: true, }, createdAfter: { type: "string", label: "Created After", description: "Filter contacts that were created after this date", optional: true, }, updatedBefore: { type: "string", label: "Updated Before", description: "Filter contacts that were updated before this date", optional: true, }, updatedAfter: { type: "string", label: "Updated After", description: "Filter contacts that were updated after this date", optional: true, }, waitid: { type: "string", label: "Wait ID", description: "Filter by contacts in the wait queue of an automation block", optional: true, }, orderByCreationDate: { type: "string", label: "Order By Creation Date", description: "Order contacts by creation date", optional: true, options: [ "ASC", "DESC", ], }, orderByEmail: { type: "string", label: "Order By Email", description: "Order contacts by email", optional: true, options: [ "ASC", "DESC", ], }, orderByFirstName: { type: "string", label: "Order By First Name", description: "Order contacts by first name", optional: true, options: [ "ASC", "DESC", ], }, orderByLastName: { type: "string", label: "Order By Last Name", description: "Order contacts by last name", optional: true, options: [ "ASC", "DESC", ], }, orderByName: { type: "string", label: "Order By Name", description: "Order contacts by full name", optional: true, options: [ "ASC", "DESC", ], }, orderByScore: { type: "string", label: "Order By Score", description: "Order contacts by score", optional: true, options: [ "ASC", "DESC", ], }, inGroupLists: { type: "string", label: "In Group Lists", description: "Set this to `true` in order to return only contacts that the current user has permissions to see.", optional: true, }, }, async run({ $ }) { const { ids, email, emailLike, exclude, formid, idGreater, idLess, listid, organization, search, segmentid, seriesid, status, tagid, createdBefore, createdAfter, updatedBefore, updatedAfter, waitid, orderByCreationDate, orderByEmail, orderByFirstName, orderByLastName, orderByName, orderByScore, inGroupLists, } = this; const response = await this.activecampaign.listContacts({ params: { ids, email, "email_like": emailLike, exclude, formid, "id_greater": idGreater, "id_less": idLess, listid, organization, search, segmentid, seriesid, status, tagid, "filters[created_before]": createdBefore, "filters[created_after]": createdAfter, "filters[updated_before]": updatedBefore, "filters[updated_after]": updatedAfter, waitid, "orders[cdate]": orderByCreationDate, "orders[email]": orderByEmail, "orders[first_name]": orderByFirstName, "orders[last_name]": orderByLastName, "orders[name]": orderByName, "orders[score]": orderByScore, "in_group_lists": inGroupLists, }, }); $.export("$summary", `Successfully listed ${response.contacts.length} contact(s)`); return response; }, };