Integrations
Sources
Segment

Segment source

Receive Segment webhook events in Knock to trigger workflows and keep user data in sync with track and identify events.

The Segment source enables you to receive Segment webhook events directly in Knock. Segment sends webhook callbacks when track and identify events flow through your workspace. Knock verifies each payload using your Segment webhook signing secret, identifies the event type, and executes the actions you configure.

This integration is useful for triggering notification workflows from track events, such as alerting users when key actions happen in your product, or syncing user data into Knock from identify events so recipient profiles stay up to date.

Knock supports ingesting any of Segment's supported events, so you can map them to actions as your needs evolve.

Prerequisites

#
  • A Knock account with at least one environment configured.
  • A Segment workspace with access to webhook or destination settings.

Getting started

#
1

Create the source in Knock

Navigate to Platform > Sources in the Knock dashboard. Make sure you're in the correct environment. Select the Segment template as the source type.

The Sources page in the Knock dashboard
2

Select default action mappings

Once you've selected Segment as a source, you can select your desired action mappings. These are helpful defaults to get you started, but Knock can ingest any event Segment sends and you can adjust your mappings at any time. Click the Connect Segment button to continue.

The Segment source creation modal showing default action mappings for incoming events
3

Copy the webhook URL

After creating the source, Knock displays a setup wizard. Copy the event ingestion URL from step 1 of the wizard. You will paste this into your Segment destination configuration in a later step.

The Segment source setup wizard showing the event ingestion URL to copy
4

Add a webhook destination in Segment

In your Segment workspace, navigate to Destinations and click "Add Destination." Search for Webhooks (Actions) and select it. Choose the data source you want to receive events from, give the destination a name, and click "Create Destination."

5

Select events to send to Knock

In the Segment destination, navigate to the Mappings tab and click "New Mapping." Under Actions, click "Send." Configure the event conditions to determine which events are forwarded to Knock. For example, you can add conditions for Event type is Track and Event type is Identify, and set the top operator to any to send both event types.

6

Map the webhook URL in Segment

After selecting your events, proceed to the Map fields step. Paste the Knock event ingestion URL you copied earlier into the URL field and set the Method to POST.

The Segment Map fields step showing the Knock webhook URL in the URL field
7

Configure the signing secret

Unlike other webhook providers, Segment does not auto-generate a signing secret. You need to generate your own secret and enter it in both Segment and Knock.

In your Segment destination, navigate to the Settings tab. Enter your generated secret in the Shared Secret field and click "Save Changes."

The Segment Webhooks (Actions) destination Settings page showing the Shared Secret field

Then, back in Knock, paste the same secret into the Signing secret field in step 2 of the setup wizard, or in the source environment configuration under the Settings tab.

Once configured, Segment sends webhook events to Knock in real time. You can verify that events are arriving by checking the event logs on the source environment page.

Pre-configured events

#

Segment sends events based on the Segment spec. Below are common event types you might map to actions in Knock.

Event typeDescription
trackA user performed an action
identifyUser traits were created or updated

See the Segment spec documentation for the full list of available event types and their schemas.

Customization

#

You can modify the default action mappings or add new ones for any event type Knock receives from Segment. For details on how field mapping works with dot-notation paths, see the custom source page.

If you need to map Segment events to actions beyond triggering workflows, see the full list of available actions in the sources overview.

Event idempotency

#

Knock uses the messageId field from the Segment event spec as the idempotency key. Segment includes a messageId in every track and identify event by default, so no additional field configuration is needed.

You can change the idempotency key field or disable idempotency checks from the Settings tab in your source environment configuration. Events without an idempotency key attribute are processed normally.

For details on how Knock handles idempotent events, key validation rules, and the default 24-hour idempotency window, see the source event idempotency section of the sources overview.

New chat