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.2 KB
Raw Blame
import { createAction } from '@activepieces/pieces-framework';
import { mauticAuth } from '../auth';
import { mauticApi } from '../common/api';
import { mauticProps } from '../common/props';
import { searchMauticCompanyOutputSchema } from '../output-schemas';

export const searchCompanyAction = createAction({
  auth: mauticAuth,
  description: 'Search for a company in Mautic CRM',
  audience: 'human',
  aiMetadata: {
    description:
      'Look up a company in Mautic by matching the supplied field values (combined into a search query), returning the first matching company. Use to find a company or resolve its id before updating, or to verify whether an organization already exists before creating one. Read-only and idempotent.',
    idempotent: true,
  },
  displayName: 'Search Company',
  name: 'search_mautic_company',
  outputSchema: searchMauticCompanyOutputSchema,
  classification: 'SEARCH',
  props: {
    fields: mauticProps.companyFields({ required: true }),
  },
  run: async function (context) {
    const response = await mauticApi.searchCompanies({ auth: context.auth, fields: context.propsValue.fields });
    return Object.values(response.companies)[0];
  },
});