Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.3 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { clickfunnelsAuth } from '../common/constants';
import { teamsDropdown, workspacesDropdown } from '../common/props';
import { clickfunnelsApiService } from '../common/requests';

export const searchContacts = createAction({
  auth: clickfunnelsAuth,
  name: 'searchContacts',
  displayName: 'Search Contacts',
  description: 'Look up contacts by ID or email',
  audience: 'both',
  aiMetadata: {
    description:
      'Looks up contacts within a ClickFunnels workspace by a single search term, which is auto-detected as an email address (filters on email) when it contains "@", or otherwise as a contact ID. Use to resolve a contact record or its ID before another action. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    teamId: teamsDropdown(['auth']),
    workspaceId: workspacesDropdown(['auth', 'teamId']),
    searchTerm: Property.ShortText({
      displayName: 'Search Query',
      description: 'Filter contacts by either email or id',
      required: true,
    }),
  },
  async run({ auth, propsValue }) {
    const response = await clickfunnelsApiService.fetchContactByEmailSearch(
      auth.props,
      propsValue.workspaceId as string,
      propsValue.searchTerm as string
    );
    
    return response;
  },
});