Zapier Integration
Relevant source files
The following files were used as context for generating this wiki page:
- packages/twenty-zapier/src/index.ts
- packages/twenty-zapier/src/triggers/trigger_record.ts
- packages/twenty-zapier/src/creates/crud_record.ts
- packages/twenty-zapier/src/authentication.ts
- packages/twenty-zapier/src/test/authentication.test.ts
- packages/twenty-zapier/package.json
- packages/twenty-front/src/modules/settings/integrations/constants/SettingsIntegrationZapier.ts
The Twenty Zapier integration allows users to connect their Twenty CRM workspace with thousands of other applications to automate workflows. It is built using the zapier-platform-core library and provides a set of triggers and actions to facilitate data synchronization and process automation between Twenty and other services. The integration is defined within the twenty-zapier package.
The primary purpose is to "Effortlessly sync Twenty with 3000+ apps. Automate tasks, boost productivity, and supercharge your customer relationships!". This is achieved by providing triggers that react to events in Twenty (like creating a new record) and actions that can manipulate data within Twenty (like creating or updating a record).
Sources: packages/twenty-zapier/package.json:3-3, packages/twenty-zapier/src/index.ts
Architecture
The Zapier integration is a self-contained application within the packages/twenty-zapier directory. It is structured as a standard Zapier Platform app, defining authentication, triggers, and creates (actions).
Sources: packages/twenty-zapier/src/index.ts:15-25
Core Components
The integration is composed of three main parts: Authentication, Triggers, and Creates.
This diagram shows the high-level components of the Zapier integration and their interaction with the Twenty CRM's GraphQL API.
Sources: packages/twenty-zapier/src/index.ts:15-25
The main components are registered in the index.ts file:
| Component Type | Key | Description | Source File |
|---|---|---|---|
| Authentication | authentication | Handles connection and authentication to the Twenty API. | authentication.ts |
| Trigger | new_or_updated_record | Triggers when a record is created or updated. | trigger_record.ts |
| Trigger | find_object_names_singular | A hidden trigger to fetch a list of object names for dropdowns. | triggers/find_object_names_singular.ts |
| Trigger | list_record_ids | A hidden trigger to fetch a list of record IDs for dropdowns. | triggers/list_record_ids.ts |
| Create | crud_record | An action to create, update, or find a record. | crud_record.ts |
Sources: packages/twenty-zapier/src/index.ts:16-24
Authentication
Authentication is handled via a custom scheme that requires a Twenty API Key. The user must also provide the URL of their Twenty instance, which defaults to http://localhost:3000 if not specified.
The authentication process involves two main fields:
apiKey: The user's API key from their Twenty workspace.apiUrl: The base URL of the Twenty instance.
Sources: packages/twenty-zapier/src/authentication.ts:7-22, packages/twenty-zapier/src/test/authentication.test.ts:31-35
Authentication Test Flow
To verify the credentials, the integration sends a GraphQL query to the provided apiUrl to fetch the currentWorkspace. A successful response confirms that the API key and URL are valid.
This sequence diagram illustrates the process of testing the user's authentication credentials.
Sources: packages/twenty-zapier/src/authentication.ts:24-34, packages/twenty-zapier/src/test/authentication.test.ts:26-30
An invalid API URL or an incorrect API key will result in an UNAUTHENTICATED error.
Sources: packages/twenty-zapier/src/test/authentication.test.ts:37-59
Triggers
Triggers are used to start a Zap when a specific event occurs in Twenty.
New or Updated Record (trigger_record)
This is the primary trigger. It fires whenever a new record is created or an existing one is updated for a specified object type (e.g., Company, Person). It works by polling the Twenty API for records sorted by their updatedAt timestamp in descending order.
Sources: packages/twenty-zapier/src/triggers/trigger_record.ts:16-17, packages/twenty-zapier/src/triggers/trigger_record.ts:75-81
The trigger requires the user to select an objectName from a dynamic dropdown populated by the find_object_names_singular helper trigger.
Sources: packages/twenty-zapier/src/triggers/trigger_record.ts:22-26
trigger_record Flow
This diagram shows the polling logic for the "New or Updated Record" trigger.
Sources: packages/twenty-zapier/src/triggers/trigger_record.ts:63-82
Actions (Creates)
Actions are steps in a Zap that perform an operation in Twenty.
Create/Update/Find Record (crud_record)
This is a versatile action that can perform one of three operations on a Twenty record: CREATE, UPDATE, or FIND. The user selects the desired operation and object type.
Sources: packages/twenty-zapier/src/creates/crud_record.ts:16-17, packages/twenty-zapier/src/creates/crud_record.ts:28-40
The action dynamically generates input fields based on the selected objectName and its corresponding fields in the Twenty data model. This allows users to map data from previous Zap steps to any field on a Twenty object.
Sources: packages/twenty-zapier/src/creates/crud_record.ts:107-133
crud_record Flow
This diagram outlines the logic for the crud_record action, branching based on the selected operation.
Sources: packages/twenty-zapier/src/creates/crud_record.ts:135-156
Example Integrations
The Twenty frontend suggests several pre-built "Zaps" to help users get started with the Zapier integration.
| From | To | Description | Link |
|---|---|---|---|
| Twenty | Slack | Post to Slack when a company is updated | https://zapier.com/apps/twenty/integrations/slack |
| Cal.com | Twenty | Create a person when Cal.com event is created | https://zapier.com/apps/twenty/integrations/calcom |
| Mailchimp | Twenty | Create a person when a MailChimp sub is created | https://zapier.com/apps/twenty/integrations/mailchimp |
| Tally | Twenty | Create a company when a Tally form is sent | https://zapier.com/apps/twenty/integrations/tally |
Sources: packages/twenty-front/src/modules/settings/integrations/constants/SettingsIntegrationZapier.ts:8-49
Summary
The Twenty Zapier integration provides a powerful way to connect the CRM to other applications. It uses a secure API key authentication method. The core functionality is centered around a single, powerful trigger (trigger_record) for detecting new or updated data, and a flexible action (crud_record) for creating, updating, or finding records. This allows for a wide range of automation possibilities, from simple notifications to complex, multi-step data synchronization workflows.
Sources: packages/twenty-zapier/src/index.ts, packages/twenty-zapier/src/triggers/trigger_record.ts, packages/twenty-zapier/src/creates/crud_record.ts