Some checks failed
App Prod-Parity E2E Dispatch / dispatch (push) Failing after 10s
CD Storybook UI / build (push) Failing after 3m25s
CD Storybook UI / dispatch (push) Has been skipped
CD deploy main / website-changed-files (push) Successful in 18m8s
CI Agent Skills / changed-files-check (push) Successful in 18m9s
CI Create App E2E minimal / changed-files-check (push) Successful in 24s
CI Create App / changed-files-check (push) Successful in 26s
CI Docs / changed-files-check (push) Successful in 26s
CI Emails / changed-files-check (push) Successful in 28s
CI Example App Hello World / changed-files-check (push) Successful in 23s
CI Front / changed-files-check (push) Has been skipped
CI Example App Postcard / changed-files-check (push) Successful in 27s
CI UI / changed-files-check (push) Has been skipped
CI Utils Test / changed-files-check (push) Successful in 45s
CI Twenty Apps / discover (push) Successful in 1m3s
CD deploy main / deploy-main (push) Failing after 3s
CI Agent Skills / agent-skills-validate (push) Has been skipped
CI Create App / create-app-test (lint) (push) Has been skipped
CI Emails / emails-test (push) Has been skipped
CI Front / front-task (lingui:compile) (push) Has been skipped
CI Front / front-task (lint) (push) Has been skipped
CI Example App Postcard / example-app-postcard (push) Has been skipped
CI UI / ui-task (lint) (push) Has been skipped
CI UI / ui-task (pack-size) (push) Has been skipped
CI UI / ui-task (size) (push) Has been skipped
CI UI / ui-task (test) (push) Has been skipped
CI UI / ui-task (typecheck) (push) Has been skipped
CI Utils Test / utils-test (push) Has been skipped
CI Twenty Apps / ${{ matrix.app.name }} (push) Has been skipped
CI Emails / ci-emails-status-check (push) Successful in 2s
CI Example App Hello World / ci-example-app-hello-world-status-check (push) Successful in 2s
CI Example App Postcard / ci-example-app-postcard-status-check (push) Successful in 3s
CI UI / ui-sb-test (push) Has been skipped
CI Utils Test / ci-utils-test-status-check (push) Successful in 2s
CI Twenty Apps / ci-twenty-apps-status-check (push) Successful in 2s
CI UI / ci-ui-status-check (push) Successful in 2s
CI Desktop / desktop (push) Failing after 1m8s
Push docs to Crowdin / Push documentation to Crowdin (push) Failing after 55s
Push translations to Crowdin / Extract and upload translations (push) Failing after 5s
Push website translations to Crowdin / Extract and upload website translations (push) Failing after 5s
CI Create App / create-app-test (test) (push) Has been skipped
CI Create App / create-app-test (typecheck) (push) Has been skipped
CI Docs / docs-lint (push) Has been skipped
CI Example App Hello World / example-app-hello-world (push) Has been skipped
CI Front / front-task (lingui:extract) (push) Has been skipped
CI Front / front-task (test) (push) Has been skipped
CI Front / front-task (typecheck) (push) Has been skipped
CI UI / ui-sb-build (push) Failing after 1m32s
CI Twenty Apps / ${{ matrix.app.name }} (${{ matrix.server-source }}) (push) Has been skipped
CI Agent Skills / agent-skills-publish (push) Has been skipped
CI Create App / ci-create-app-status-check (push) Successful in 2s
CI Agent Skills / agent-skills-remote-source (push) Has been skipped
CI Create App E2E minimal / create-app-e2e-minimal (push) Has been cancelled
CI E2E Main / e2e-test (push) Has been cancelled
CI Front / front-sb-build (push) Has been cancelled
CI Front / front-build (push) Has been cancelled
CI Create App E2E minimal / ci-create-app-e2e-minimal-status-check (push) Has been cancelled
CI E2E Main / ci-e2e-main-status-check (push) Has been cancelled
CI E2E Main / notify-main-ci-failure (push) Has been cancelled
CI E2E Main / qa-scout-comment (push) Has been cancelled
CI Front / front-sb-test (push) Has been cancelled
CI Front / front-sb-screenshots (push) Has been cancelled
CI Front / ci-front-status-check (push) Has been cancelled
DPA Sub-Processor Sync / sync-subprocessors (push) Failing after 3s
AI Catalog Sync / sync-catalog (push) Failing after 2s
169 lines
4.2 KiB
Plaintext
169 lines
4.2 KiB
Plaintext
---
|
|
title: Set Up a Webhook Trigger
|
|
description: Receive data from external services to trigger workflows.
|
|
---
|
|
|
|
Webhook triggers allow external services to start your workflows by sending data to a unique URL. Use them to connect forms, third-party apps, and custom integrations.
|
|
|
|
## When to Use Webhooks
|
|
|
|
| Use Case | Example |
|
|
|----------|---------|
|
|
| **Web forms** | Contact form submissions create leads |
|
|
| **Third-party apps** | Stripe payment → create customer record |
|
|
| **Custom integrations** | Your app → Twenty automation |
|
|
| **No-code tools** | Zapier, Make, n8n connections |
|
|
|
|
## Step-by-Step Setup
|
|
|
|
### Step 1: Create the Workflow
|
|
|
|
1. Go to **Settings → Workflows**
|
|
2. Click **+ New Workflow**
|
|
3. Name it (e.g., "Website Form Submission")
|
|
|
|
### Step 2: Configure the Webhook Trigger
|
|
|
|
1. Click on the trigger block
|
|
2. Select **Webhook**
|
|
3. You'll receive a unique webhook URL like:
|
|
```
|
|
https://api.twenty.com/webhooks/workflow/abc123...
|
|
```
|
|
4. Copy this URL—you'll need it for your external service
|
|
|
|
### Step 3: Define Expected Data Structure
|
|
|
|
For **POST** requests, define the expected body structure:
|
|
|
|
1. Click **Define expected body**
|
|
2. Enter a sample JSON that matches what your service will send:
|
|
|
|
```json
|
|
{
|
|
"firstName": "John",
|
|
"lastName": "Doe",
|
|
"email": "john@example.com",
|
|
"company": "Acme Inc",
|
|
"message": "Interested in your product"
|
|
}
|
|
```
|
|
|
|
3. Click **Save**—this creates variables you can use in subsequent steps
|
|
|
|
### Step 4: Add Actions
|
|
|
|
Now add actions that use the webhook data:
|
|
|
|
**Example: Create a Person record**
|
|
|
|
1. Add **Create Record** action
|
|
2. Select **People** object
|
|
3. Map fields:
|
|
|
|
| Field | Value |
|
|
|-------|-------|
|
|
| First Name | `{{trigger.body.firstName}}` |
|
|
| Last Name | `{{trigger.body.lastName}}` |
|
|
| Email | `{{trigger.body.email}}` |
|
|
| Company | Search or create based on `{{trigger.body.company}}` |
|
|
|
|
### Step 5: Test the Webhook
|
|
|
|
Before activating, test your webhook:
|
|
|
|
**Using cURL**:
|
|
```bash
|
|
curl -X POST https://api.twenty.com/webhooks/workflow/abc123... \
|
|
-H "Content-Type: application/json" \
|
|
-d '{"firstName":"Test","lastName":"User","email":"test@example.com"}'
|
|
```
|
|
|
|
**Using Postman or similar**:
|
|
1. Create a POST request to your webhook URL
|
|
2. Set Content-Type header to `application/json`
|
|
3. Add your test JSON body
|
|
4. Send and check workflow runs
|
|
|
|
### Step 6: Activate
|
|
|
|
Once tested, click **Activate** to make the workflow live.
|
|
|
|
## Handling Different Data Structures
|
|
|
|
### Nested Data
|
|
|
|
If your webhook sends nested data:
|
|
```json
|
|
{
|
|
"contact": {
|
|
"name": "John Doe",
|
|
"email": "john@example.com"
|
|
},
|
|
"source": "website"
|
|
}
|
|
```
|
|
|
|
Reference with: `{{trigger.body.contact.email}}`
|
|
|
|
### Arrays
|
|
|
|
If data includes arrays:
|
|
```json
|
|
{
|
|
"items": [
|
|
{"name": "Product A", "qty": 2},
|
|
{"name": "Product B", "qty": 1}
|
|
]
|
|
}
|
|
```
|
|
|
|
How you handle arrays depends on your use case:
|
|
|
|
**Unknown number of items → Use Iterator**
|
|
|
|
If you need to process each item in the array (e.g., create a record for each), add a **Code** action to parse the array, then use **Iterator**:
|
|
|
|
```javascript
|
|
export const main = async (params: { items: any }) => {
|
|
const items = typeof params.items === "string"
|
|
? JSON.parse(params.items)
|
|
: params.items;
|
|
return { items };
|
|
};
|
|
```
|
|
|
|
Then use Iterator to loop through: `{{code.items}}`
|
|
|
|
**Known/specific fields → Extract to named fields**
|
|
|
|
If the array contains specific fields you want to access individually (e.g., form answers where position 0 is always "first name", position 1 is always "last name"), add a **Code** action to extract them:
|
|
|
|
```javascript
|
|
export const main = async (params: { items: any }) => {
|
|
const items = typeof params.items === "string"
|
|
? JSON.parse(params.items)
|
|
: params.items;
|
|
|
|
return {
|
|
product: {
|
|
name: items[0]?.name || "",
|
|
qty: items[0]?.qty || 0
|
|
}
|
|
};
|
|
};
|
|
```
|
|
|
|
Now you can select `product.name` and `product.qty` individually in subsequent steps.
|
|
|
|
<Tip>
|
|
For more details on handling arrays, see [Handle Arrays in Code Actions](/user-guide/workflows/how-tos/advanced-configurations/handle-arrays-in-code-actions).
|
|
</Tip>
|
|
|
|
|
|
## Related
|
|
|
|
- [Workflow Triggers](/user-guide/workflows/capabilities/workflow-triggers)
|
|
- [Workflow Actions](/user-guide/workflows/capabilities/workflow-actions)
|
|
|