多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

15 KiB

title description
Webhooks Webhooks allows user to trigger on certain operations on following database operations

Overview

You can employ webhooks to notify external systems whenever there are additions, updates, or removals of rows within NocoDB. This feature allows you to receive instantaneous notifications for any changes made to your database. NocoDB also offers webhooks for bulk endpoints for creating, updating, or deleting multiple records simultaneously.

Note that, Webhooks currently are specific for associated table.

Configure Webhook

To setup a new Webhook

  1. Open Details tab in topbar,
  2. Click on Webhooks tab
  3. Click Add New Webhook

webhook

Webhook configuration

webhook config

  1. Name

  2. Event

    1. After Insert
    2. After Update
    3. After Delete
    4. After Bulk Insert
    5. After Bulk Update
    6. After Bulk Delete
  3. Type

Trigger Details
Email Send email to certain email addresses
Slack Notify via Slack channel
Microsoft Teams Notify via Microsoft Teams channel
Discord Notify via Discord channel
Mattermost Notify via Mattermost channel
Twilio Send SMS to certain mobile numbers
Whatsapp Twilio Send Whatsapp messages to numbers using Twilio
URL Invoke an HTTP API
  1. Action

    1. GET
    2. POST
    3. DELETE
    4. PUT
    5. HEAD
    6. PATCH
  2. Type specific configuration : additional configuration details depending on webhook type selected
    Example: Link for type URL

  3. [Optional] Headers & Parameters : Configure Request headers & parameters (if any)

  4. [Optional] Condition : Only records meeting the criteria will trigger webhook

  5. [Optional] Test : Test webhook (with sample payload) to verify if parameter are configured appropriately

  6. Save

Enable/Disable Webhook

To disable a Webhook

  • Open Webhook tab to find list of webhooks created
  • Toggle Activate button to enable/disable

Screenshot 2023-09-01 at 3 59 28 PM

Delete Webhook

To delete a Webhook

  • Open Webhook tab to find list of webhooks created
  • Click on ... actions button associated with the webhook to be deleted
  • Select Delete

Screenshot 2023-09-01 at 4 01 46 PM

Duplicate Webhook

To duplicate a Webhook

  • Open Webhook tab to find list of webhooks created
  • Click on ... actions button associated with the webhook to be duplicate
  • Select Duplicate

Screenshot 2023-09-01 at 4 01 46 PM

A copy of the webhook will be created (disabled by default) with a suffix - Copy

Webhook Response Sample

Insert

{
  "type": "records.after.insert",
  "id": "9dac1c54-b3be-49a1-a676-af388145fa8c",
  "data": {
    "table_id": "md_xzru7dcqrecc60",
    "table_name": "Film",
    "view_id": "vw_736wrpoas7tr0c",
    "view_name": "Film",
    "rows": [
      {
        "FilmId": 1011,
        "Title": "FOO",
        "Language": {
          "LanguageId": 1,
          "Name": "English"
        },
      }
    ]
  }
}

Update

{
  "type": "records.after.update",
  "id": "6a6ebfe4-b0b5-434e-b5d6-5212adbf82fa",
  "data": {
    "table_id": "md_xzru7dcqrecc60",
    "table_name": "Film",
    "view_id": "vw_736wrpoas7tr0c",
    "view_name": "Film",
    "previous_rows": [
      {
        "FilmId": 1,
        "Title": "ACADEMY DINOSAUR",
        "Description": "A Epic Drama of a Feminist in The Canadian Rockies",
        "Actor List": [
          {
            "ActorId": 10,
            "FirstName": "CHRISTIAN"
          }
        ],
      }
    ],
    "rows": [
      {
        "FilmId": 1,
        "Title": "ACADEMY DINOSAUR (Edited)",
        "Actor List": [
          {
            "ActorId": 10,
            "FirstName": "CHRISTIAN"
          }
        ],
      }
    ]
  }
}

Delete

{
  "type": "records.after.delete",
  "id": "e593079f-70e5-4965-8944-5ff7aeed005c",
  "data": {
    "table_id": "md_xzru7dcqrecc60",
    "table_name": "Film",
    "view_id": "vw_736wrpoas7tr0c",
    "view_name": "Film",
    "rows": [
      {
        "FilmId": 1010,
        "Title": "ALL-EDITED",
        "Language": {
          "LanguageId": 1,
          "Name": "English"
        },
      }
    ]
  }
}

Bulk Insert

{
  "type": "records.after.bulkInsert",
  "id": "f8397b06-a399-4a3a-b6b0-6d1c0c2f7578",
  "data": {
    "table_id": "md_xzru7dcqrecc60",
    "table_name": "Film",
    "view_id": "vw_3fq2e9q8drkblw",
    "view_name": "GridView",
    "rows_inserted": 2
  }
}

Bulk Update

{
  "type": "records.after.bulkUpdate",
  "id": "e983cea5-8e38-438e-96a0-048751f6830b",
  "data": {
    "table_id": "md_xzru7dcqrecc60",
    "table_name": "Film",
    "view_id": "vw_3fq2e9q8drkblw",
    "view_name": "Sheet-1",
    "previous_rows": [
      [
        {
          "FilmId": 1005,
          "Title": "Q",
          "Language": {
            "LanguageId": 1,
            "Name": "English"
          },
        },
        {
          "FilmId": 1004,
          "Title": "P",
          "Language": {
            "LanguageId": 1,
            "Name": "English"
          }
        }
      ]
    ],
    "rows": [
      [
        {
          "FilmId": 1005,
          "Title": "Q-EDITED",
          "Language": {
            "LanguageId": 1,
            "Name": "English"
          }
        },
        {
          "FilmId": 1004,
          "Title": "P-EDITED",
          "Language": {
            "LanguageId": 1,
            "Name": "English"
          },
        }
      ]
    ]
  }
}

Bulk Delete

{
  "type": "records.after.bulkDelete",
  "id": "e7f1f4e5-7052-4ca2-9355-241ceb836f43",
  "data": {
    "table_id": "md_xzru7dcqrecc60",
    "table_name": "Film",
    "view_id": "vw_3fq2e9q8drkblw",
    "view_name": "Sheet-1",
    "rows": [
      [
        {
          "FilmId": 1022,
          "Title": "x",
          "Language": {
            "LanguageId": 1,
            "Name": "English"
          },
        },
        {
          "FilmId": 1023,
          "Title": "x",
          "Language": {
            "LanguageId": 1,
            "Name": "English"
          },
        }
      ]
    ]
  }
}

Call Log

Call Log allows user to check the call history of the hook. By default, it has been disabled. However, it can be configured by using environment variable NC_AUTOMATION_LOG_LEVEL.

  • NC_AUTOMATION_LOG_LEVEL=OFF: No logs will be displayed and no history will be inserted to meta database.
  • NC_AUTOMATION_LOG_LEVEL=ERROR: only error logs will be displayed and history of error logs will be inserted to meta database.
  • NC_AUTOMATION_LOG_LEVEL=ALL: Both error and success logs will be displayed and history of both types of logs will be inserted to meta database. This option is only available for Enterprise Edition.

image

Triggers

Webhooks allows user to trigger on certain operations on following database operations

  • AFTER INSERT
  • AFTER UPDATE
  • AFTER DELETE

The triggers will trigger asynchronously without blocking the actual operation.

Applications/services

Trigger Details
Email Send email to certain email addresses
Slack Notify via Slack channel
Microsoft Teams Notify via Microsoft Teams channel
Discord Notify via Discord channel
Mattermost Notify via Mattermost channel
Twilio Send SMS to certain mobile numbers
Whatsapp Twilio Send Whatsapp messages to numbers using Twilio
URL Invoke an HTTP API

Accessing Data: Handlebars

:::warning

You can accessing data using handlebars for v1 webhooks only.

:::

The current row data and other details will be available in the hooks payload so the user can use handlebar syntax to use data.

We are using Handlebars library to parse the payload internally.

Example

For a table with column names (id, title, created_at, updated_at).
For INSERT/ UPDATE based triggers, use following handlebars to access corresponding data fields.

  • {{ data.id }}
  • {{ data.title }}
  • {{ data.created_at }}
  • {{ data.updated_at }}

Note that, for Update trigger - all the fields in the ROW will be accessible, not just the field updated. For DELETE based triggers, only {{ data.id }} is accessible representing ID of the column deleted.

JSON format

Use {{ json data }} to dump complete data & user information available in JSON format

Additional references:

Handlebar Guide.

Application Guide

Discord

1. Create WebHook

  • On Discord, open your Server Settings and head into the Integrations tab:
  • Click the "Create Webhook" button to create a new webhook!

Screenshot 2022-02-22 at 1 21 59 PM

  • Choose channel to which this webhook will post to.
  • Copy webhook URL

Screenshot 2022-02-22 at 1 23 18 PM

(Sample webhook URL: https://discord.com/api/webhooks/945558283756908644/GNUtiGuzfOky6wZ4ce30XuXc1sbPK3Od7EC-4t6hihh5Fovv6oU9OsdT6mGuoL1QlTzj).
Detailed procedure for discord webhook described here.

2. Install Plugin

  • Open 'App Store' (under Settings), hover over Discord tile. Click 'Install'.

Screenshot 2022-09-14 at 10 47 59 AM

  • Provide a name of your choice (not to be confused with Discord Channel name).
  • Paste Discord Webhook URL copied from Step (1.) above.

Screenshot 2022-09-14 at 10 52 14 AM

3. Configure

  • Open project and choose a table.
  • Click 'More' > 'Webhooks'.
  • Click 'Create webhook'
  • Configure webhook
    • Title: Name of your choice to identify this Webhook.
    • Event: Trigger event. Choose between.
      • After Insert: Trigger event for new ROW insertion.
      • After Update: Trigger event for existing ROW updation.
      • After Delete: Trigger event for ROW deletion
    • On Condition: [Optional] Enable if you wish to associate additional condition/constraint with the trigger configured above.
    • Notification: Select 'Discord'.
    • Select Discord Channels: Select from the drop down list, channel name configured in Step (2). Please click on 'Reload' if drop down list is empty.
    • Body: Message to be posted over Discord channel, via webhooks on trigger of configured event.
      • Body can contain plain text &
      • Handlebars {{ }}

Slack

1. Create WebHook

  • Details to create slack webhook are captured here

2. Install Plugin

  • Procedure remain same as listed for DISCORD channel configuration above

3. Configure Webhook

  • Procedure remain same as listed for DISCORD channel configuration above

Microsoft Teams

1. Create WebHook

  • On Teams, open your channel, click on three-dots menu (far right) and select 'Connectors'
154971352-6912d53b-cf71-4edd-a319-1c85be85f0c5
  • Select incoming webhook & click 'Configure'
154971434-0ced97f7-205a-4e2e-8f88-17092cb7771a
  • Create webhook, Copy webhook URL

154971683-db16be7f-4f07-4447-8f2e-ac50e133bef8

2. Install Plugin

  • Open 'App Store' (under Settings), hover over 'Microsoft Teams' tile. Click 'Install'.

Screenshot 2022-09-14 at 10 53 22 AM

  • Provide a name of your choice (not to be confused with Teams Channel name).
  • Paste MS Teams Webhook URL copied from Step (1.) above.

Screenshot 2022-09-14 at 10 53 31 AM

3. Configure

  • Open project and choose a table.
  • Click 'More' > 'Webhooks'.
  • Click 'Create webhook'
  • Configure webhook
    • Title: Name of your choice to identify this Webhook.
    • Event: Trigger event. Choose between.
      • After Insert: Trigger event for new ROW insertion.
      • After Update: Trigger event for existing ROW updation.
      • After Delete: Trigger event for ROW deletion
    • On Condition: [Optional] Enable if you wish to associate additional condition/constraint with the trigger configured above.
    • Notification: Select 'Microsoft Teams'.
    • Select Teams Channels: Select from the drop down list, channel name configured in Step (2). Please click on 'Reload' if drop down list is empty.
    • Body: Message to be posted over Teams channel, via webhooks on trigger of configured event.
      • Body can contain plain text &
      • Handlebars {{ }}

Webhook V2

Webhook v2 is available after v0.106.0. Here's the differences.

  • Response Payload has been predefined and cannot configure in Body using Handlebars. The payload can be referenced under Sample Payload in Hook detail page.
  • Support the following bulk operations:
    • AFTER BULK INSERT
    • AFTER BULK UPDATE
    • AFTER BULK DELETE