Skip to content

Commit aaddf47

Browse files
authored
Merge pull request #265 from nocodb/docs/webhook-trigger
Docs/webhook trigger
2 parents 88f8280 + 0e51c0d commit aaddf47

File tree

3 files changed

+65
-51
lines changed

3 files changed

+65
-51
lines changed

content/docs/automation/webhook/create-webhook.mdx

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
2727
- **Record** - Triggers when a record is inserted, updated, or deleted, or for all actions if “Send me everything” is selected.
2828
- **Manual Trigger / Button Trigger** - Trigger runs when a user manually clicks a webhook configured button.
2929

30-
3130
3. Select **Trigger Event** type : Refer table [here](#trigger-source-and-event) for available events for each source
3231
4. [Optional] **Trigger based on condition** : details [here](#webhook-with-conditions)
3332
> Conditions are not applicable for Manual Trigger webhook
@@ -39,24 +38,35 @@ import { Tab, Tabs } from 'fumadocs-ui/components/tabs';
3938
> This is only applicable for `After Update` event.
4039
- Select the fields for which webhook should be triggered.
4140
- If no field is selected, any field update will trigger webhook
42-
6. **Method & URL** : Specify the endpoint that the webhook will call when triggered. You can choose from the following HTTP methods: GET, POST, PUT, DELETE, PATCH, and HEAD.
43-
7. [Optional] **Headers & Parameters** : Configure Request headers & parameters
44-
8. [Optional] **Body** : Configure request body. You can use [handlebar syntax](https://handlebarsjs.com/guide/#simple-expressions) to access and manipulate the data easily. For example, `{{ json event }}` will give you the complete event data (default behaviour if body not configured).
45-
9. [Optional] Click **Test** webhook button to verify if parameter are configured appropriately (with sample payload)
46-
10. Click **Create Webhook** button to complete webhook creation
41+
42+
6. [Optional] **Trigger only when specific form submitted**: details [here](#webhook-on-specific-form-submission-)
43+
> This is only applicable for `After Insert` event.
44+
- Select the form for which webhook should be triggered.
45+
46+
7. **Webhook Action** : Select the action to be performed when webhook is triggered. Action can be one of the following:
47+
- **HTTP Request** : Send an HTTP request to a specified URL. You can configure the HTTP method, headers, parameters, and body of the request.
48+
- **Method & URL** : Specify the endpoint that the webhook will call when triggered. You can choose from the following HTTP methods: GET, POST, PUT, DELETE, PATCH, and HEAD.
49+
- **Headers & Parameters** : Configure Request headers & parameters
50+
- **Body** : Configure request body. You can use [handlebar syntax](https://handlebarsjs.com/guide/#simple-expressions) to access and manipulate the data easily. For example, `{{ json event }}` will give you the complete event data (default behaviour if body not configured).
51+
52+
- **Run Script** : Run a custom script using NocoDB's built-in scripting engine. You can write JavaScript code to perform various actions when the webhook is triggered.
53+
- **Script** : Select the script to be executed when the webhook is triggered. You can create and manage scripts in the `Scripts` tab in the left sidebar.
54+
55+
8. [Optional] Click **Test** webhook button to verify if parameter are configured appropriately (with sample payload)
56+
9. Click **Create Webhook** button to complete webhook creation
4757

4858

4959
### Trigger Source and Event
5060

5161
Webhooks in NocoDB can be configured based on the source of the trigger and the type of event. The table below outlines the available combinations:
5262

53-
| **Trigger Source** | **Trigger Event** | **Description** |
54-
| ------------------ | ------------------ | --------------------------------------------------- |
63+
| **Trigger Source** | **Trigger Event** | **Description** |
64+
|--------------------|--------------------|------------------------------------------------------------|
5565
| Record | Send Me Everything | Triggers on any record insert, update, or delete operation |
56-
| | After Insert | Triggers after one or more records are inserted |
57-
| | After Update | Triggers after one or more records are updated |
58-
| | After Delete | Triggers after one or more records are deleted |
59-
| Button Trigger || Triggers when a button field is clicked |
66+
| | After Insert | Triggers after one or more records are inserted |
67+
| | After Update | Triggers after one or more records are updated |
68+
| | After Delete | Triggers after one or more records are deleted |
69+
| Button Trigger || Triggers when a button field is clicked |
6070

6171
> For more details on using **Button Trigger** webhooks with the **Button** field, see the [Button field documentation](/docs/product-docs/fields/field-types/custom-types/button).
6272
@@ -71,20 +81,56 @@ A webhook will only be triggered if the condition transitions from **not met** t
7181

7282
**In short**, a webhook is triggered only when the condition changes from **false** (old record) to **true** (new record).
7383

74-
<Callout type="note">
75-
**Note:** Conditions are not applicable for Manual Trigger webhook.
76-
</Callout>
84+
<Callout type="note">Conditions are not applicable for Manual Trigger webhook.</Callout>
7785

7886
### Webhook on field changes ☁
7987

80-
<Callout type="note">
81-
**Note:** This feature is only available in the paid plans, in both cloud & self-hosted.
82-
</Callout>
88+
<Callout type="note">This feature is only available in the paid plans, in both cloud & self-hosted.</Callout>
8389

8490
For **After Update** event, you can configure webhook to trigger only when **certain fields are updated**. For example, trigger webhook only when `Status` is updated. You can also configure multiple fields.
8591

8692
![Webhook on field changes](/img/v2/webhook/create-webhook-field-changes.png)
87-
93+
94+
95+
### Webhook on specific form submission ☁
96+
<Callout type="note">This feature is only available in the paid plans, in both cloud & self-hosted.</Callout>
97+
98+
For **After Insert** event, you can configure webhook to trigger only when a **specific form is submitted**. For example, if you have multiple forms for a table, you can choose to trigger webhook only when `Form A` is submitted.
99+
100+
![Webhook on specific form submission](/img/v2/webhook/create-webhook-form-submission.png)
101+
102+
103+
### Webhook with custom payload ☁
104+
105+
<Callout type="note">
106+
This feature is only available in the paid plans, in both cloud & self-hosted.
107+
</Callout>
108+
109+
In the enterprise edition, you can set up a personalized payload for your webhook. Just head to the `Body` tab to make the necessary configurations. Users can utilize [handlebar syntax](https://handlebarsjs.com/guide/#simple-expressions), which allows you to access and manipulate the data easily.
110+
111+
Use `{{ json event }}` to access the event data. Sample response is as follows
112+
```json
113+
{
114+
"type": "records.after.insert",
115+
"id": "0698517a-d83a-4e72-bf7a-75f46b704ad1",
116+
"version": "v3",
117+
"data": {
118+
"table_id": "m969t01blwprpef",
119+
"table_name": "Table-2",
120+
"view_id": "vwib3bvfxdqgymun",
121+
"view_name": "Table-2",
122+
"rows": [
123+
{
124+
"Id": 1,
125+
"Tags": "Sample Text",
126+
"CreatedAt": "2024-04-11T10:40:20.998Z",
127+
"UpdatedAt": "2024-04-11T10:40:20.998Z"
128+
}
129+
]
130+
}
131+
}
132+
```
133+
88134

89135
### Webhook response sample
90136

@@ -210,38 +256,6 @@ For **After Update** event, you can configure webhook to trigger only when **cer
210256
</Tabs>
211257

212258

213-
### Webhook with custom payload ☁
214-
215-
<Callout type="note">
216-
This feature is only available in the paid plans, in both cloud & self-hosted.
217-
</Callout>
218-
219-
In the enterprise edition, you can set up a personalized payload for your webhook. Just head to the `Body` tab to make the necessary configurations. Users can utilize [handlebar syntax](https://handlebarsjs.com/guide/#simple-expressions), which allows you to access and manipulate the data easily.
220-
221-
Use `{{ json event }}` to access the event data. Sample response is as follows
222-
```json
223-
{
224-
"type": "records.after.insert",
225-
"id": "0698517a-d83a-4e72-bf7a-75f46b704ad1",
226-
"version": "v3",
227-
"data": {
228-
"table_id": "m969t01blwprpef",
229-
"table_name": "Table-2",
230-
"view_id": "vwib3bvfxdqgymun",
231-
"view_name": "Table-2",
232-
"rows": [
233-
{
234-
"Id": 1,
235-
"Tags": "Sample Text",
236-
"CreatedAt": "2024-04-11T10:40:20.998Z",
237-
"UpdatedAt": "2024-04-11T10:40:20.998Z"
238-
}
239-
]
240-
}
241-
}
242-
```
243-
244-
245259
#### Discord Webhook
246260
Discord webhook can be configured to send messages to a Discord channel. Discord request body should contain content, embeds or attachments, otherwise request will fail. Below is an example of Discord webhook payload. More details can be found [here](https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html)
247261

112 KB
Loading
-44 KB
Loading

0 commit comments

Comments
 (0)